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>