WCF의 HTTP 포스트 서비스를 통해 문자열 값을 클라이언트에 반환하려고합니다.C# WCF 서비스를 통한 출력 값 반환
나는 다음을 통해 괜찮아 상태 코드를 반환 할 수 있습니다
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK;
... 그러나 문자열 값을 클라이언트에 반환하는 방법에 대해서는 잘 모르겠습니다.
모든 포인터가 많이 감사하겠습니다.
감사
닉
namespace TextWCF
{
[ServiceContract]
public interface IShortMessageService
{
[WebInvoke(UriTemplate = "invoke", Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
[OperationContract]
void PostSMS(Stream input);
}
}
[OperationBehavior]
public void PostSMS(Stream input)
{
StreamReader sr = new StreamReader(input);
string s = sr.ReadToEnd();
sr.Dispose();
NameValueCollection qs = HttpUtility.ParseQueryString(s);
string user = Convert.ToString(qs["user"]);
string password = qs["password"];
string api_id = qs["api_id"];
string to = qs["to"];
string text = qs["text"];
string from = qs["from"];
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK;
WebOperationContext.Current.OutgoingResponse. = HttpStatusCode.OK;
}
처럼 보이게하기 위해 메서드 서명을 변경합니다. 예를 들어 메소드 선언을 변경할 수 있습니다. 'string'을 반환하고 싶다면'public string PostSMS (Stream input)'을 사용하십시오. –