2011-12-13 4 views
0

나는라는 간단한 WCF 방법이 'test은'WCF를 사용하여 webHttpBinding - 매개 변수를 취하는 방법?

나는 그러나 나는 하나의 매개 변수로 단지 문자열을 보내려면, 고급 매개 변수없이에 HTTP POST를 할 수 있습니다 (WCF 서비스는 webHttpBinding 구성됩니다) 하지만 이걸 성취하는 것 같지 않아? 예를 들어

, 나는 데이터 소용 'hello world''&s=hello world'test에 게시 시도 test(string s){};

방법.

편집 :

당신은 당신의 요청 본문의 일부로서이를 게시하려고 할 수
[OperationContract] 
[WebInvoke(UriTemplate = "test", Method = "POST", RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)] 
string test(string s); 

답변

-1

:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Hello World</string> 

당신은 피들러에서 시도 할 수 test의 인터페이스는 같이 보입니다. 당신은 .NET 클라이언트에서 게시 할 경우 또는 당신은

+0

제 3 자 API를 다운로드해야한다고 생각하지 않습니까? – maxp

+0

@maxp : 위에 게시 된 코드를 사용하여 RestSharp가 필요하다고 말씀 드렸습니다. 나는 결코 의무적으로 말하지 않았다. – Rajesh

1

test(Stream s)test(string s)이 고정 변경 작업을 위의 코드에 대한 RestSharp라는 API를 다운로드해야

var client = new RestClient(); 
client.BaseUrl = serviceBaseUrl; 
var request = new RestRequest(method){RequestFormat = DataFormat.Xml};  
request.Resource = resourceUrl; 
request.AddParameter("text/xml", requestBody, ParameterType.RequestBody); 
var response = client.Execute(request); 

@ 아래 코드를 사용합니다.

관련 문제