2012-12-07 108 views
1

我正在寻找解决方案来处理我的WCF错误400错误请求,并且SOAP请求长于64K。我知道当我谷歌它有很多解决方案。但是,我仍然不能成功地修复我的网站。因此,我正在寻求专业意见。WCF大型SOAP请求异常400错误请求

客户端代码:

Private Sub Calculate() 
    Dim svc As New XXXService.XXXServiceClient 
    Dim i As Integer 
    Dim attributes As List(Of XXXService.AttributesStruct) 
    Dim calculateSingleResponse As XXXService.SingleXXXResponseStruct 

    Try 
     attributes = New List(Of XXXService.AttributesStruct) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_One", .AttributesValue = "1"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Two", .AttributesValue = "XXX"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Three", .AttributesValue = "1"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Four", .AttributesValue = "0"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Five", .AttributesValue = "1"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Six", .AttributesValue = "70"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Seven", .AttributesValue = "80"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Eight", .AttributesValue = "09.12.2012"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Nine", .AttributesValue = "12.12.2012"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Ten", .AttributesValue = "15.11.2012"}) 
     i = 0 
     While i < 80 
      attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Eleven[" & i.ToString & "]", .AttributesValue = "2"}) 
      attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Twelve[" & i.ToString & "]", .AttributesValue = "5"}) 
      attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Thirteen[" & i.ToString & "]", .AttributesValue = "1"}) 
      attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Fourteen[" & i.ToString & "]", .AttributesValue = "NA"}) 
      attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Fifteen[" & i.ToString & "]", .AttributesValue = "0"}) 
      attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Sixteen[" & i.ToString & "]", .AttributesValue = "0"}) 
      i = i + 1 
     End While 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Seventeen", .AttributesValue = "0"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Eighteen", .AttributesValue = "0"}) 
     attributes.Add(New XXXService.AttributesStruct With {.AttributesKey = "A_Nineteen", .AttributesValue = "0"}) 
     calculateSingleResponse = _ 
      svc.Calculate("Test", True, "XXX", attributes.ToArray(),{"P_XXX"})     
     svc.Close() 
     Response.Write("********************************************<br/>") 
     Response.Write("[ErrorCode: " & calculateSingleResponse.ErrorCode & "]<br/>") 
     Response.Write("[ErrorDescription: " & calculateSingleResponse.ErrorDescription & "]<br/>") 

    Catch ex As Exception 
     Response.Write("EXCEPTION:" & "<br/>" & ex.Message & "<br/>" & ex.StackTrace & "<br/>") 
     If Not ex.InnerException Is Nothing Then 
      Response.Write("INNER EXCEPTION:" & "<br/>" & ex.InnerException.Message & "<br/>" & ex.InnerException.StackTrace) 
     End If 
    End Try 

End Sub 

客户端配置:

<system.web> 
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" /> 
    <httpRuntime maxRequestLength="2147483647" /> 
</system.web> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 
<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="BasicHttpBinding_IXXXService" closeTimeout="10:01:00" 
     openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00" 
     allowCookies="false" bypassProxyOnLocal="true" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
     messageEncoding="Text" textEncoding="utf-8" 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> 
    </basicHttpBinding> 
</bindings> 
<behaviors> 
    <endpointBehaviors> 
     <behavior name="BasicHttpBehaviour_IXXXService"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 
     </behavior> 
    </endpointBehaviors> 
</behaviors> 
<client> 
    <endpoint address="http://127.0.0.1:999/XXXService.svc" 
    behaviorConfiguration="BasicHttpBehaviour_IXXXService" binding="basicHttpBinding" 
    bindingConfiguration="BasicHttpBinding_IXXXService" contract="XXXService.IXXXService" 
    name="BasicHttpBinding_IXXXService" /> 
</client> 
</system.serviceModel> 

服务器端配置:

<system.serviceModel> 
    <services> 
     <service name="WcfClient.XXXService"> 
      <endpoint address="" binding="wsHttpBinding" bindingConfiguration="BasicHttpBinding_IXXXService" 
       contract="WcfClient.IXXXService" /> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
      <host> 
       <timeouts closeTimeout="00:01:10" openTimeout="00:01:00" /> 
      </host> 
     </service> 
    </services> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="BasicHttpBinding_IXXXService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
       allowCookies="false"> 
       <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <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"/> 
       <!-- For wcf caller 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"/> 
       <dataContractSerializer maxItemsInObjectGraph="2147483646"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
</system.serviceModel> 

回答

1

我已经找到了问题我自己:

  1. 服务器端和客户端之间的结合必须是相同的,因此我改变既basicHttpBinding的
  2. 服务名称是区分大小写的,我改变了“WcfClient.XXXService”到“ wcfClient.XXXService“,它现在可以工作。

希望这可以帮助其他人同样的困难=)