我想從SAP上的.NET環境中使用webservices。 但是當我嘗試創建了SAP SOAMANAGER邏輯端口出現錯誤:如何更改.NET WSDL以使其與SAP兼容?
SRT-Framework-Ausnahme: Initialer Wert "consumer context table" in Methode IF_SRT_WSP_CONFIG_REGISTRY~CREATE_CONTEXTS_FROM_WS der Klasse CL_SRT_WSP_CONFIG_REGISTRY
的WSDL分析儀顯示2不支持的元素:
<http:BasicAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
和
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xml:base="https://external-server.com/Webservice.svc?singlewsdl"><wsp:ExactlyOne><wsp:All><sp:TransportToken><wsp:Policy xml:base="https://external-server.com/Webservice.svc?singlewsdl"><wsp:ExactlyOne><wsp:All><sp:HttpsToken RequireClientCertificate="false"/></wsp:All></wsp:ExactlyOne></wsp:Policy></sp:TransportToken><sp:AlgorithmSuite><wsp:Policy xml:base="https://external-server.com/Webservice.svc?singlewsdl"><wsp:ExactlyOne><wsp:All><sp:Basic256/></wsp:All></wsp:ExactlyOne></wsp:Policy></sp:AlgorithmSuite><sp:Layout><wsp:Policy xml:base="https://external-server.com/Webservice.svc?singlewsdl"><wsp:ExactlyOne><wsp:All><sp:Strict/></wsp:All></wsp:ExactlyOne></wsp:Policy></sp:Layout></wsp:All></wsp:ExactlyOne></wsp:Policy></sp:TransportBinding>
於是我詳細地看了一下WSDL文件並刪除了wsp:All標籤的內容,那就是:
<http:BasicAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http"/>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
創建從離線編輯WDSL文件中的邏輯端口現在工作!所以我猜,這個問題起源於BasicAuthentication和TransportBinding標籤。
當然原始的外部WDSL文件必須改編。
在.NET環境中,爲了生成SAP兼容的WSDL文件,我需要做些什麼改變?我必須修改web.config文件嗎?
只需在服務中使用'basicHttpBinding'。它目前使用'wsHttpBinding'。 –
@JohnSaunders目前我正在使用basicHttp ** s綁定。這被選中,因爲WebService應該只能通過HTTPS進行通信。我是否可以使用其他綁定,例如你的建議basicHttpBinding和通過HTTPS溝通,無論如何? –
@JohnSaunders我在我的Web.config中用'basicHttpBinding'替換'basicHttpsBinding'。通過HTTPS調用WDSL文件仍然有效,但另一方面,它並沒有解決我的問題。 –