WCF收不到POST传值,求解
调用方法如下
[OperationContract(Name = "SendMessage")]
[WebInvoke(Method= "POST",ResponseFormat=WebMessageFormat.Json,RequestFormat=WebMessageFormat.Json,UriTemplate = "SendMessage?message={message}", BodyStyle = WebMessageBodyStyle.Wrapped)]
String SendMessage(String message);
JAVA中调用:
HttpPost post = new HttpPost(BASE_URL+"/SendMessage?message=");
List<NameValuePair> value=new ArrayList<NameValuePair>();
value.add(new BasicNameValuePair("message","hello"));
try
{
HttpEntity httpcode=new UrlEncodedFormEntity(value,HTTP.UTF_8);
post.setEntity(httpcode);
HttpResponse httpResponse = client.execute(post);
statusCode = httpResponse.getStatusLine().getStatusCode();
if(statusCode==HttpStatus.SC_OK)
{
result = retrieveInputStream(httpResponse.getEntity());
}
}catch(Exception e)
{
}
可以调用,但String SendMessage(String message);中message值为空