我有一个接受JSON字符串实体的WCF服务,这是方法:
更新:我解决了这个问题,因为这与WCF服务无关,而是与我正在使用的GSON格式有关,因为它没有形成像“ù”这样的特殊字符,服务器拒绝接受这个字符。
<WebInvoke(UriTemplate:="UpdateUser", ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json, Method:="POST", BodyStyle:=WebMessageBodyStyle.WrappedRequest)> _
Public Function UpdateUser(user As String) As Stream Implements IService1.UpdateUser
End Function
如果我尝试通过JAVA HttpClient发布一个带有下面代码和短JSON字符串的JSON字符串都可以正常工作,但是如果JSON字符串的大小更大,那么IIS 7.5响应:
-MODULE_SET_RESPONSE_ERROR_STATUS ModuleName ManagedPipelineHandler 通知128 HttpStatus 400 HttpReason不良请求 HttpSubStatus 0 ErrorCode 0 ConfigExceptionInfo 通知 EXECUTE_REQUEST_HANDLER 错误代码 Operazione completata。 (为0x0)
我已尝试使用Max.ReceivedMessageSize和Web.Config中的其他大小设置,但没有成功。
这是我的Web.Config文件
<services>
<service name="WBVoice4Facebook.Service1" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="StreamedRequestWebBinding" contract="WBVoice4Facebook.IService1" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netMsmqBinding>
<binding name="NewBinding0">
<security>
<transport msmqAuthenticationMode="None" msmqProtectionLevel="None" />
</security>
</binding>
</netMsmqBinding>
<webHttpBinding>
<binding name="StreamedRequestWebBinding"
openTimeout="10:15:00"
receiveTimeout="10:15:00"
sendTimeout="10:15:00"
bypassProxyOnLocal="true"
hostNameComparisonMode="WeakWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
transferMode="Streamed"
useDefaultWebProxy="false">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="InheritedFromHost" />
</security>
</binding>
</webHttpBinding>
</bindings>