加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 调用服务引用会导致“远程服务器返回错误:(400)错误请求

发布时间:2020-12-15 21:17:00 所属栏目:百科 来源:网络整理
导读:edit3:我从服务器添加了webconfig edit2:我运行了日志,这是出现的错误消息: 已超出传入邮件的最大邮件大小限额(65536).要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性. 因为它仅用于2000记录的测试,而不是200的测试,我决定更改应用程序
edit3:我从服务器添加了webconfig

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

已超出传入邮件的最大邮件大小限额(65536).要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性.

因为它仅用于2000记录的测试,而不是200的测试,我决定更改应用程序设置,假设它超过了65535的标准限制.不幸的是这没有帮助并且搜索我发现那里有两个此问题的其他类型的来源,一个是服务本身的设置,另一个是端点中的设置.

开发服务的开发人员表示他的方面还可以,而且这个问题只是我身边的一个环境,他曾做过自己但不记得了.

我已经在端点上添加了应用程序配置数据,人们已经说过,如果端点不匹配,将会使用默认设置创建默认端点,从而使用65K限制.如果这是问题我该怎么解决?

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

编辑:我按照建议将更改添加到应用配置中

<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

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="FilePath" value="162.27.51.43DOWNLOADRPAMailsortAuto" />
  </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:logsTraces.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>

解决方法

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

您是否将端点指向行为?

<endpoint address="http:blah/MyService.svc" behaviorConfiguration="MyServiceBehavior".

目前的配置适用于200而不是2000?如果是这样,你可以尝试修改你的服务绑定到最大,如下所示,看看是否有帮助,(你也会在服务端反映相同的属性)?

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读