2
我可能错过了明显的,但我怎么能使它,以便我的WCF服务上的一个方法,PutMessage,可以接受GZip'd和正常请求?现在,我从我的服务看到此错误:WCF服务接受GZip消息
Cannot process the message because the content type 'application/gzip' was not the expected type 'text/xml; charset=utf-8'.
我已经尝试添加自定义与binaryMessageCoding/compressionFormat =“压缩”和httpTransport结合。这是否需要配置多个绑定和多个端点?还是多个绑定和一个端点?一个端点和一个绑定?
我无法更改发送代码,因为它是我无权访问的第三方。
这是到目前为止我的web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="UserNameAuthenticationBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="API.Star.XXXUsernamePasswordValidator, API" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="API.Star.starTransport">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Basic" />
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="API.Star.starTransportGzip">
<binaryMessageEncoding compressionFormat="GZip" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="API.Star.StarWebService" behaviorConfiguration="UserNameAuthenticationBehaviour">
<endpoint name="StarWebServiceEndpoint" address="" binding="basicHttpBinding" bindingConfiguration="API.Star.starTransport" contract="API.Star.operations" bindingNamespace="http://www.starstandards.org/webservices/2005/10/transport" />
<endpoint name="StarWebServiceEndpointGzip" address="" binding="customBinding" bindingConfiguration="API.Star.starTransportGzip" contract="API.Star.operations" bindingNamespace="http://www.starstandards.org/webservices/2005/10/transport" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
我认为这可能是我困惑的地方。 IIS设置似乎围绕GZip *响应*,而不是*请求*。 – MattGWagner
我确保在IIS上启用压缩,并将*/*作为启用的动态类型,但错误仍在发生。 – MattGWagner
请求由客户端生成,而不是服务生成。客户需要创建一个使用GZip的请求。 –