首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调用服务引用将导致“远程服务器返回错误:(400)坏请求”错误

调用服务引用将导致“远程服务器返回错误:(400)坏请求”错误
EN

Stack Overflow用户
提问于 2011-03-28 13:23:07
回答 3查看 1.1K关注 0票数 4

edit3:我从服务器添加了webconfig

edit2:我运行了日志,这是出现的错误消息:

已超过传入邮件(65536)的最大邮件大小配额。若要增加配额,请在适当的绑定元素.上使用MaxReceivedMessageSize属性。

由于它只用于2000条记录的测试,而不是200条的测试,所以我决定更改应用程序设置,前提是它超过了65535的标准限制。不幸的是,这并没有帮助和搜索周围,我发现在那里有另外两种类型的起源这个问题,一个是在服务本身的设置和一个在端点。

做这项服务的开发人员说,他的这一边没问题,问题只是我这边的一个设置,他曾经自己做过,但不记得了。

我在端点中添加了app配置数据,有人说,如果端点不匹配,将使用默认设置创建默认端点,从而使用65K限制。如果这就是问题所在,我该如何解决呢?

如果你需要任何额外的代码或信息,请告诉我。

编辑:我按照建议向应用程序配置添加了更改

代码语言:javascript
复制
<behaviors>
  <endpointBehaviors>
    <behavior name="MetadataBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </endpointBehaviors>
</behaviors>


    <binding name="BasicHttpBinding_IMailSortService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>


    <endpoint behaviorConfiguration="MetadataBehavior" address="http://remote-access/MailSort/MailSortService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailSortService"
        contract="MailSortServiceReference.IMailSortService" name="BasicHttpBinding_IMailSortService" />

服务器上的webconfig

代码语言:javascript
复制
<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="FilePath" value="\\162.27.51.43\DOWNLOAD\RPA\Mailsort\Auto" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>

   <system.diagnostics>
      <sources>
            <source name="System.ServiceModel" 
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="traceListener" 
                   type="System.Diagnostics.XmlWriterTraceListener" 
                   initializeData= "c:\logs\Traces.svclog" />
            </listeners>
         </source>
      </sources>
   </system.diagnostics>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>  
</configuration>
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-05-05 08:08:12

解决方案是下面的app配置设置。

当通过WCF发送大型消息时,需要将以下代码添加到服务器上的web.config和本地应用程序的app.config中。这将使服务器和本地信任使用用户定义的消息大小。

包括内部的部分。

代码语言:javascript
复制
<protocolMapping>
<remove scheme="http" />
<add scheme="http" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailSortService" />
</protocolMapping>
票数 0
EN

Stack Overflow用户

发布于 2011-03-28 15:01:33

评论变得太大了,转而回答:

你把端点指向行为了吗?

代码语言:javascript
复制
<endpoint address="http:blah/MyService.svc" behaviorConfiguration="MyServiceBehavior". 

当前配置可用于200,但不适用于2000?如果是这样,您是否可以尝试将您的服务绑定修改为下面这样的最大值,看看这是否有帮助(您也会在服务端反映相同的属性)?

代码语言:javascript
复制
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
票数 1
EN

Stack Overflow用户

发布于 2011-04-15 16:56:10

我不认为这篇文章启用了评论。

我不是在评论,而是回答。

根据下面的帖子,请确保您正在使用完全限定的名称空间作为服务合同。

http://forums.silverlight.net/forums/p/191589/442378.aspx

代码语言:javascript
复制
<endpoint behaviorConfiguration="MetadataBehavior" address="http://remote-access/MailSort/MailSortService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailSortService"
        contract="FullyQualifiedNamespace.IMailSortService" name="BasicHttpBinding_IMailSortService" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5459605

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档