WCF Web.config,客户端和服务器端的命名空间,maxReceivedMessageSize

时间:2014-01-16 10:28:33

标签: asp.net vb.net wcf web-services soap

我不是VB开发人员,我在使用Namespace进行Web服务时遇到了一些问题。我拥有这个客户端和服务器端,所以我没有问题更改设置。

我正在尝试连接到Web服务,同时这样做会得到MaxReceivedMessageSize异常。

我这样做是因为我有一个带有“web项目”和更多“类项目”的解决方案,在我的一个“类项目”中,我有一个服务引用和一个app.config文件,我在那里进行设置。

我已经读过我需要在我的应用程序中设置app.config并在服务器web.config上为Web服务添加设置。我对在服务器端的web.service的web.config中设置的名称空间感到困惑。有人可以帮帮我吗?我用这个设置

(服务器)

<system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="Erp_QueryServiceSoap" maxReceivedMessageSize="2147483647">
                  <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </binding>
          </wsHttpBinding>
        </bindings>
        <services>
            <service name="WebService.Erp_QueryService.Erp_QueryServiceSoap">
              <endpoint address="Erp_QueryService.Erp_QueryServiceSoap"
                  binding="wsHttpBinding" bindingConfiguration="Erp_QueryServiceSoap"
                  contract="Erp_QueryService.Erp_QueryServiceSoap" name="Erp_QueryServiceSoap" />
            </service>
        </services>
    </system.serviceModel>

(客户端)

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="Erp_QueryServiceSoap" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="CONNECTION TO SERVICE"
          binding="wsHttpBinding" bindingConfiguration="Erp_QueryServiceSoap"
          contract="ServiceQuery.Erp_QueryServiceSoap" name="Erp_QueryServiceSoap" />
    </client>
  </system.serviceModel>

1 个答案:

答案 0 :(得分:0)

我认为可能问题不在于名称空间。 尝试将maxItemsInObjectGraph设置为以下内容。

行为部分

<behavior name="YourServiceNameBehaviour">
  <serviceMetadata httpGetEnabled="true" />
  <serviceDebug includeExceptionDetailInFaults="true" />
  **<dataContractSerializer maxItemsInObjectGraph="2147483647" />**
</behavior>

我认为你已经添加了除

之外的代码
 **<dataContractSerializer maxItemsInObjectGraph="2147483647" />**

尝试添加此代码行。