wcf http post方法由android获取null请求

时间:2013-06-23 07:54:41

标签: android wcf

我有一个方法作为帖子

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "UpdateCheckListParagraphs", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    Boolean  UpdateCheckListParagraphs( Stream   Result);//

我通过c#获取请求但是通过android我得到“Type =”System.ServiceModel.Channels.NullMessage“”

web.config

<system.serviceModel>    
<bindings>
  <webHttpBinding>
    <binding name="default" />
  </webHttpBinding>
</bindings>
<services>
  <service name="spcWcfService.Testit" behaviorConfiguration="TestitBehaviors">
    <endpoint binding="webHttpBinding" indingNamespace="http://mnet.co.il/spcWcfService.svc" contract="spcWcfService.ITestit" behaviorConfiguration="GetEndpointBehavior">
    </endpoint>
    <endpoint name="mexHttpBinding" address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
 </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="GetEndpointBehavior">
      <webHttp helpEnabled="true" automaticFormatSelectionEnabled="true" />
    </behavior>       
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="TestitBehaviors">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>       
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

                   

android调用

public String postGetJson2(String dataToSend, String serviceUri) {
    // Log.d("dataToSend", dataToSend);

    StringEntity entity = null;
    HttpPost httpPost = new HttpPost(serviceUri);
    httpPost.setHeader("Accept", "application/json");
    httpPost.setHeader("Content-type", "application/json");
    httpPost.setHeader("Accept-Charset", "UTF-8");
    String result = null;
    try {
        if (dataToSend != null) {
            entity = new StringEntity(dataToSend, "UTF-8");
            httpPost.setEntity(entity);
        }

        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpResponse response = null;
        try {
            response = httpClient.execute(httpPost);
            result = EntityUtils.toString(response.getEntity());

        } finally {
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
    }

    return result;
谁能帮助我吗?请...

0 个答案:

没有答案