Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
WCF服务错误400错误请求_Wcf_Service_Request - Fatal编程技术网

WCF服务错误400错误请求

WCF服务错误400错误请求,wcf,service,request,Wcf,Service,Request,我一直在搜索这个问题,我发现了其他用户发布的类似问题,但我尝试的一切都不起作用,问题是我使用的是IIS上托管的WCF服务,以及一个试图在字符串上上载序列化图像的客户端,图像的大小为9mb,其他一切都正常,我可以发送数据没有问题,除了图像 我已启用tracelog,错误消息显示MaxReceivedMessageSize超过 以下是我的服务配置: <system.diagnostics> <sources> <source name="System.Servi

我一直在搜索这个问题,我发现了其他用户发布的类似问题,但我尝试的一切都不起作用,问题是我使用的是IIS上托管的WCF服务,以及一个试图在字符串上上载序列化图像的客户端,图像的大小为9mb,其他一切都正常,我可以发送数据没有问题,除了图像

我已启用tracelog,错误消息显示MaxReceivedMessageSize超过

以下是我的服务配置:

<system.diagnostics>
<sources>
    <source name="System.ServiceModel"
        switchValue="Information, ActivityTracing"
        propagateActivity="true" >
        <listeners>
            <add name="xml"/>
        </listeners>
    </source>
    <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="xml"/>
        </listeners>
    </source>
    <source name="myUserTraceSource"
        switchValue="Information, ActivityTracing, All">
        <listeners>
            <add name="xml"/>
        </listeners>
    </source>
</sources>
<trace autoflush="true"  />
<sharedListeners>
  <add name="xml"
       type="System.Diagnostics.XmlWriterTraceListener"
       initializeData="ErrorSvcLog.svclog" />
</sharedListeners>
</system.diagnostics>

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IServicioSalud" closeTimeout="10:01:00" 
                maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
                maxReceivedMessageSize="2147483647" openTimeout="10:01:00"
                receiveTimeout="10:10:00" sendTimeout="10:01:00"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
                    maxNameTableCharCount="2147483647" />
            </binding>
        </basicHttpBinding>
</bindings>
<services>
    <service behaviorConfiguration="ServiceBehavior" name="ServicioSalud">
        <endpoint address="" binding="basicHttpBinding" contract="IServicioSalud" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
</services>
<behaviors>
    <serviceBehaviors>
        <behavior name="ServiceBehavior">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
            <dataContractSerializer maxItemsInObjectGraph="200000" />
        </behavior>
    </serviceBehaviors>
</behaviors>
<diagnostics>
    <messageLogging
        logEntireMessage="true"
        logMalformedMessages="false"
        logMessagesAtServiceLevel="true"
        logMessagesAtTransportLevel="false"
        maxMessagesToLog="3000"
        maxSizeOfMessageToLog="2000"/>
</diagnostics>
</system.serviceModel>
</configuration>

和客户端配置

<system.serviceModel>
    <bindings>
        <basicHttpBinding> 
            <binding name="BasicHttpBinding_IServicioSalud" closeTimeout="10:01:00"
                openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true" 
                <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                    maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://xxx.xxx.x.xxx:xxxx/wcfservicesalud/Service.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServicioSalud"
            contract="IServicioSalud" name="BasicHttpBinding_IServicioSalud" />
    </client>
</system.serviceModel>


在配置文件中,您尚未分配所创建的绑定配置,因此将使用
BasicHttpBinding
的默认值。您需要显式地将您定义的绑定(BasicHttpBinding_IServicioSalud)分配给端点,如下所示:

<endpoint address="" bindingConfiguration="BasicHttpBinding_IServicioSalud" binding="basicHttpBinding" contract="IServicioSalud" />


为您的服务配置执行此操作,因为服务需要设置为接受更大的数据。

这是我的版本。确保已在所需服务中指定了绑定配置。在我的例子中,我必须指定名称basicHttpBinding



对我来说,原因是在我的请求中我没有设置内容类型。

您需要通过
bindingConfiguration
属性将服务端点设置为您定义的绑定配置(BasicHttpBinding\u IServicioSalud)。
<bindings>
   <basicHttpBinding>
    <binding name="basicHttpBinding" maxBufferSize="64000000" maxReceivedMessageSize="64000000" maxBufferPoolSize="64000000">
      <readerQuotas maxDepth="64000000" maxStringContentLength="64000000" maxArrayLength="64000000" maxBytesPerRead="64000000" />
      <security mode="None"/>
    </binding>
    </basicHttpBinding>
</bindings>


<services>
      <service behaviorConfiguration="WS.Service1Behavior" name="WS.EasyStockWS">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="WS.IEasyStockWS">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
</services>