Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.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# 从桌面应用程序(.Net 2)调用Web服务(WCF)时的消息大小_C#_.net_Web Services_Wcf_Soap - Fatal编程技术网

C# 从桌面应用程序(.Net 2)调用Web服务(WCF)时的消息大小

C# 从桌面应用程序(.Net 2)调用Web服务(WCF)时的消息大小,c#,.net,web-services,wcf,soap,C#,.net,Web Services,Wcf,Soap,我有一个Web服务(WCF),它将接收到的文件存储在数据库中。 当我从.NET 4.5 web应用程序调用它时,我只需在客户端的web.config文件中指定: <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_NameOfWS" maxBufferSize="2147483647" maxReceivedMessageSi

我有一个Web服务(WCF),它将接收到的文件存储在数据库中。 当我从.NET 4.5 web应用程序调用它时,我只需在客户端的web.config文件中指定:

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_NameOfWS"  
             maxBufferSize="2147483647" 
             maxReceivedMessageSize="2147483647" />
  </basicHttpBinding>
</bindings>
但我没有Web.config文件可供配置,因为它不是Web应用程序

我的app.config看起来像:

<applicationSettings>
    <NameOfProject.Properties.Settings>
        <setting name="NameOfProject_NameOfWebReference_NameOfWS"
            serializeAs="String">
            <value>http://myURL/NameOfWS.svc</value>
        </setting>
    </NameOfProject.Properties.Settings>
</applicationSettings>

http://myURL/NameOfWS.svc
并且NameOfWS.wsdl文件没有maxBufferSize或maxReceivedMessageSize参数

我遗漏了什么吗


提前感谢。

有关app.config绑定配置示例

请尝试以下几种方法

 <binding name="bindingName" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="Transport" />
    </binding>

在你的.net 2 app.config上写下这个,它必须是接收文件,但我建议你将.net 4 app.config标记复制到.net 2 app.config上,它必须工作


已解决

如果有人需要解决这样的问题,我会发布我如何让它工作

我的服务项目中的Web.config

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_MyWCFInterface"  maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="MyProject.MyWCFClass" >
        <endpoint address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="BasicHttpBinding_MyWCFInterface"
                  contract="MyProject.MyWCFInterface"/>
      </service>
    </services>
</system.serviceModel>

我的客户端项目中的App.config

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
          <binding name="BasicHttpBinding_MyWCFInterface" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://localhost:myPort/MyService.svc" 
              binding="basicHttpBinding" 
              bindingConfiguration="BasicHttpBinding_MyWCFInterface" 
              contract="NameOfCreatedService.MyWCFInterface" 
              name="BasicHttpBinding_MyWCFInterface" />
  </client>
</system.serviceModel>

我不知道并且一直是最后一步的是,在客户端解决方案的主项目的App.config中复制这个App.config配置,如果不是的话,配置在启动时没有加载,消息大小配置也不起作用

我希望它能帮助任何人


感谢那些花了一些时间处理这个问题的人。

我尝试过这个配置,但不起作用,我刚刚看到BasicHttpBinding从.Net 3.0开始就可以工作:(它不起作用,我刚刚看到BasicHttpBinding从.Net 3.0开始就可以工作……完成了,我不知道这个策略:)
<system.serviceModel>
  <bindings>
    <basicHttpBinding>
          <binding name="BasicHttpBinding_MyWCFInterface" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://localhost:myPort/MyService.svc" 
              binding="basicHttpBinding" 
              bindingConfiguration="BasicHttpBinding_MyWCFInterface" 
              contract="NameOfCreatedService.MyWCFInterface" 
              name="BasicHttpBinding_MyWCFInterface" />
  </client>
</system.serviceModel>