开发者

The remote server returned an unexpected response: (400) Bad Request

I get the exception "The remote server returned an unexpected response: (400) Bad Request" and i dont have any clue why. 开发者_如何学Python

The web.config look fine - but maybe i dont see the problem

<configuration>

  <system.web>
      <compilation debug="true" targetFramework="4.0" />
      <httpRuntime maxRequestLength="524288" />
  </system.web>

 <system.serviceModel>
   <services>
      <service name="ServiceLibrary.ServiceProxy"                                              behaviorConfiguration="ServiceBehavior">

    <endpoint address="" binding="wsHttpBinding" contract="ServiceLibrary.IServiceProxy">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>  


<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <!-- 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="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

The code ( server )

[ServiceContract]
public interface IServiceProxy
{
    [OperationContract]   
    ImageData GetImgInfo( byte[] analyzingTargetBitmap );   
}

[DataContract]
public class ImageData { ... }

Client code

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IServiceProxy" closeTimeout="00:15:00"
                openTimeout="00:15:00" receiveTimeout="00:10:00" sendTimeout="00:15:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:15:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:50025/ServiceProxy.svc" binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_IServiceProxy" contract="ServiceReference1.IServiceProxy"
            name="WSHttpBinding_IServiceProxy">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>


The WCF error is really not explaining the problem but i had a similar issue. It might be that the object you are sending through is too big or it has too many items in the array.

You have to change the config to accept bigger messages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜