我已經使用VS2010中的「添加服務引用」對話框成功添加了服務引用。然而,當我嘗試訪問所述Web服務方法,我得到以下的ProtocolException:使用VS2010中的「添加服務引用」生成WsHttpBinding而不是BasicHttpBinding
Test method Test.Entities.DocumentumServiceClient_Tests.Can_Read_Client_Message threw
exception: System.ServiceModel.ProtocolException: The content type multipart/related;
type="application/xop+xml"; boundary="uuid:976dd31d-c531-4298-b12c-e799c8eb4bed";
start="<[email protected]>"; start-info="text/xml" of the response message
does not match the content type of the binding (text/xml; charset=utf-8).
If using a custom encoder, be sure that the IsContentTypeSupported method is implemented
properly. The first 919 bytes of the response were: <code>
'--uuid:976dd31d-c531-4298-b12c-e799c8eb4bed
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns8:getRepositoryNameResponse
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dfs-dm-core-profiles="http://irrelevant.com/"
xmlns:dfs-dm-core-context="http://irrelevant2.com/"
xmlns:dfs-dm-core-properties="http://irrelevant3.com/"
xmlns:dfs-dm-core-content="irrelevant4.com/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns8="http://irrelevant5.com/">
<return>to the Dagobah system</return>
</ns8:getRepositoryNameResponse>
</soap:Body>
</soap:Envelope>
--uuid:976dd31d-c531-4298-b12c-e799c8eb4bed--'.
這一切似乎,一個廣泛的谷歌搜索後,將在服務器和SOAP的SOAP 1.2之間的不匹配1.1在我的項目中。我應該顯然是使用WSHttpBinding而不是BasicHttpBinding。這裏的app.config的生成相關的部分:
<system.serviceModel>
<client>
<endpoint address="http://irrelevant.com/Service"
binding="basicHttpBinding"
bindingConfiguration="CMSPersistantManagerServiceServiceSoapBinding"
contract="DocumentumService.CMSPersistentManagerService"
name="CMSPersistentManagerServicePort" />
</client>
<bindings>
<basicHttpBinding>
<binding name="DfsAgentService" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="1000000" maxBufferPoolSize="10000000" maxReceivedMessageSize="1000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="DfsContextRegistryService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="1000000" maxBufferPoolSize="10000000" maxReceivedMessageSize="1000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="DfsDefaultService" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="1000000" maxBufferPoolSize="10000000" maxReceivedMessageSize="1000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="CMSPersistantManagerServiceServiceSoapBinding"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
有什麼不同,我應該怎樣做才能告訴服務引用對話框生成一個1.2版本的WSHttpBinding?這是WSDL的錯嗎?任何援助將不勝感激,因爲我在我的谷歌繩索的末尾。
它應該使用任何服務器正在使用。 –
是的,我知道這一點。但是,正如我所說的,「添加服務引用」對話框不會生成兼容的服務(顯然)。我知道他們應該匹配,我只是不明白,如果它正確讀取WSDL,選擇正確的綁定太愚蠢。 –