2011-05-31 112 views
0

使用Visual Studio 2010中,我開發一個Web應用程序託管的第三方使用WCF服務。他們告訴我他們不能調用它。爲了測試,他們將我重定向到Altova XmlSpy,並指出,在創建新的SOAP請求時,如果他們選擇「作爲SOAP + XML發送(SOAP 1.2)」,請在「更改SOAP請求參數」菜單項中選中,以下兩個警報對話框:無法發送WCF服務請求作爲SOAP + XML

HTTP error: could not POST file ‘/TurniArc/WebServices/Processi.svc’ on server ’10.51.0.108’ (415) 

Error sending the soap data to ‘http://10.51.0.108/TurniArc/WebServices/Processi.svc’ HTTP error: could not POST file ‘/TurniArc/WebServices/Processi.svc’ on server ’10.51.0.108’ (415) 

我確實證實了這一點。 取消選中該選項,請求按需要提交。我從來沒有用soapUI來調用我的web服務,這是我一直用於內部測試的軟件。

這是第一個Web服務創建,開始沒有任何中的理論知識(但我想每個人都沒有:-)),所以我甚至不知道從哪裏閒逛來解決這個問題。問題在於綁定嗎?我創建使用添加/新項目/ WCF服務,保留所有默認選項的服務,所以應該basicHttpBinding的

這是我的web.config的serviceModel部分

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name=""> 
       <serviceMetadata httpGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/> 
<!--other bindings related to proxies to other services I'm invoking --> 
</system.serviceModel> 

我的接口只有在

[ServiceContract(Namespace="http://www.archinet.it/HRSuite/Processi/")] 

屬性和類實現它具有

[ServiceBehavior(IncludeExceptionDetailInFaults = true, Namespace = "http://www.archinet.it/HRSuite/Processi/")] 
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 

個屬性

謝謝

編輯:第三方是否正在使用Oracle SOA中間件

回答

2

BasicHttpBinding使用SOAP 1.1,所以你不能在SOAP 1.2請求發送到使用此綁定的端點。 HTTP狀態碼415表示不支持的媒體類型,這也暗示了這一點,因爲SOAP 1.1使用text/xml內容類型,而SOAP 1.2使用application/soap + xml內容類型。

如果你想basicHttpBinding的等效採用SOAP 1.2,沒有任何其他的WS- *的東西包含在WsHttpBinding的你需要創建自定義綁定。最簡單的版本是這樣的:

<bindings> 
    <customBinding> 
    <binding name="soap12"> 
     <textMessageEncoding messageVersion="Soap12" /> 
     <httpTransport /> 
    </binding> 
    </customBinding> 
</bindings> 

然後,你必須手動定義爲您服務端點(此刻的你正在使用默認端點):

<services> 
    <service name="YourNamespace.YourServiceClass"> 
    <endpoint address="" binding="customBinding" bindingConfiguration="soap12" 
       contract="YourNamespace.YourServiceContractInterface" /> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
</services> 

無論如何,我很難相信,重新配置SOAP版本因爲在Oracle SOA中間件中使用您的服務需要幾分鐘的時間。

+0

那麼什麼是正確的綁定? WsHttpBinding的? – Piddu 2011-05-31 12:29:11

+0

沒有以正確的方式是向您發送SOAP 1.1 – 2011-05-31 12:34:29

+0

請求正如我剛纔在郵件中寫道,他們正在使用Oracle SOA,所以,只要它們能夠改變請求格式,他們必須做出每個小編輯是一個長期的昂重的事情。由於我的身體更加敏捷,我認爲我的軟件是一致的;今天早上我研究了一下,wsHttpBinding整體看起來更好。是嗎? – Piddu 2011-05-31 12:50:28