Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF接收HTTP响应时出错_C#_.net_Wcf - Fatal编程技术网

C# WCF接收HTTP响应时出错

C# WCF接收HTTP响应时出错,c#,.net,wcf,C#,.net,Wcf,我收到此错误:类型为“System.ServiceModel.CommunicationException”的未处理异常 错误的完整描述: 类型的未处理异常 mscorlib.dll中出现“System.ServiceModel.CommunicationException” 其他信息:接收HTTP时出错 回应 . 这可能是由于服务端点绑定未使用HTTP 协议这也可能是由于HTTP请求上下文被删除 服务器中止(可能是由于服务关闭)。看见 服务器日志了解更多详细信息 在clien中时,我尝试使用流

我收到此错误:
类型为“System.ServiceModel.CommunicationException”的未处理异常

错误的完整描述:

类型的未处理异常 mscorlib.dll中出现“System.ServiceModel.CommunicationException”

其他信息:接收HTTP时出错 回应 . 这可能是由于服务端点绑定未使用HTTP 协议这也可能是由于HTTP请求上下文被删除 服务器中止(可能是由于服务关闭)。看见 服务器日志了解更多详细信息

在clien中时,我尝试使用流数据获取响应

  SnUpdateService.Service1Client SnService = new     SnUpdateService.Service1Client();
       SnUpdateService.UpdateFiles com = new SnUpdateService.UpdateFiles();
       com.Path = "C:\\temp";
       com.SearchType = 1;
       com.Version = "20150101";
       SnUpdateService.UpdateFiles comReturn = new SnUpdateService.UpdateFiles();
       comReturn = SnService.GetUpdateFiles(com);//here error
如果没有流数据,所有工作正常

我做错了什么

这是我的客户端配置

<?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_IService1" maxBufferPoolSize="200000000"
              maxReceivedMessageSize="200000000" />
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:8733/Design_Time_Addresses/SnUpdateService/Service1/"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
            contract="SnUpdateService.IService1" name="BasicHttpBinding_IService1" />
        </client>
      </system.serviceModel>
    </configuration>

这是我的服务器网络配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="SnUpdateService.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8733/Design_Time_Addresses/SnUpdateService/Service1/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="" binding="basicHttpBinding" contract="SnUpdateService.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

我认为您缺少客户端配置文件中绑定配置的定义


此外,还可以将includeExceptionDetailInFaults=“False”设置为“true”,以获得更详细的堆栈跟踪。这有助于您进行调试。

不久前,我遇到了同样的问题,并通过在我的服务所在的应用程序池中启用32位应用程序解决了这个问题

你能举例说明你的答案吗?