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的請求。 –