簡體   English   中英

使用 SAP Web 服務時可能 SOAP 版本不匹配

[英]Possible SOAP version mismatch while consuming SAP web-service

我的要求是通過 SOAMANAGER 創建的 SAP Web 服務將 C# 連接到 SAP。

我關注了這個博客,但是當我執行代碼時

 NetworkCredential cred = new NetworkCredential();
        cred.UserName = "XXXXX";
        cred.Password = "*****";
        HELLO_WORLD_2_WSDL.z_HELLO_WORLD_2 hello_world = new HELLO_WORLD_2_WSDL.z_HELLO_WORLD_2();
        HELLO_WORLD_2_WSDL.ZTEST_WEB_SERVICE hello_world_input = new HELLO_WORLD_2_WSDL.ZTEST_WEB_SERVICE();
        HELLO_WORLD_2_WSDL.ZTEST_WEB_SERVICEResponse hello_world_response = new HELLO_WORLD_2_WSDL.ZTEST_WEB_SERVICEResponse();
        hello_world.Proxy = new WebProxy("domain", 8000);
        hello_world.PreAuthenticate = true;
        hello_world.Credentials = cred;
        hello_world_response = hello_world.ZTEST_WEB_SERVICE(hello_world_input);
        Console.WriteLine(hello_world_response.ToString());

我收到以下異常消息。

System.Web.Services.dll 中發生類型為“System.Web.Services.Protocols.SoapException”的未處理異常

附加信息:可能的 SOAP 版本不匹配:信封命名空間http://schemas.xmlsoap.org/wsdl/是意外的。 期待http://schemas.xmlsoap.org/soap/envelope/

這是來自 SOAMANAGER 的 WSDL:

  <?xml version="1.0" encoding="utf8" ?> 
  <wsdl:definitions targetNamespace="urn:sapcom:document:sap:rfc:functions" 
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
  xmlns:tns="urn:sapcom:document:sap:rfc:functions" 
  xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
  <wsdl:documentation>
  <sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl" /> 
  </wsdl:documentation>
  <wsp:UsingPolicy wsdl:required="true" /> 
  <wsp:Policy wsu:Id="BN__Z_HELLO_WORLD_2">
 <wsp:Policy wsu:Id="IF__Z_hello_world_2">
 <wsp:ExactlyOne>
 <wsp:All>

 <wsp:Policy wsu:Id="OP__ZTEST_WEB_SERVICE">
 <wsp:ExactlyOne>
 <wsp:All>
  </wsp:ExactlyOne>
  </wsp:Policy>
 <wsdl:types>
 <xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sapcom:document:sap:rfc:functions">
 <xsd:simpleType name="char20">
 <xsd:restriction base="xsd:string">
  <xsd:maxLength value="20" /> 
  </xsd:restriction>
  </xsd:simpleType>
 <xsd:element name="ZTEST_WEB_SERVICE">
 <xsd:complexType>
  <xsd:sequence /> 
  </xsd:complexType>
  </xsd:element>
 <xsd:element name="ZTEST_WEB_SERVICEResponse">
 <xsd:complexType>
 <xsd:sequence>
  <xsd:element name="O_MSG" type="tns:char20" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
  </xsd:schema>
  </wsdl:types>
 <wsdl:message name="ZTEST_WEB_SERVICE">
  <wsdl:part name="parameters" element="tns:ZTEST_WEB_SERVICE" /> 
  </wsdl:message>
 <wsdl:message name="ZTEST_WEB_SERVICEResponse">
  <wsdl:part name="parameter" element="tns:ZTEST_WEB_SERVICEResponse" /> 
  </wsdl:message>
 <wsdl:portType name="Z_hello_world_2">
 <wsp:Policy>
  <wsp:PolicyReference URI="#IF__Z_hello_world_2" /> 
  </wsp:Policy>
 <wsdl:operation name="ZTEST_WEB_SERVICE">
 <wsp:Policy>
  <wsp:PolicyReference URI="#OP__ZTEST_WEB_SERVICE" /> 
  </wsp:Policy>
  <wsdl:input message="tns:ZTEST_WEB_SERVICE" /> 
  <wsdl:output message="tns:ZTEST_WEB_SERVICEResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
 <wsdl:binding name="Z_HELLO_WORLD_2" type="tns:Z_hello_world_2">
 <wsp:Policy>
  <wsp:PolicyReference URI="#BN__Z_HELLO_WORLD_2" /> 
  </wsp:Policy>
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
 <wsdl:operation name="ZTEST_WEB_SERVICE">
  <soap:operation soapAction="urn:sapcom:document:sap:rfc:functions:Z_hello_world_2:ZTEST_WEB_SERVICERequest" style="document" /> 
 <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
 <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
 <wsdl:binding name="Z_HELLO_WORLD_2_soap12" type="tns:Z_hello_world_2">
 <wsp:Policy>
  <wsp:PolicyReference URI="#BN__Z_HELLO_WORLD_2_soap12" /> 
  </wsp:Policy>
  <wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
 <wsdl:operation name="ZTEST_WEB_SERVICE">
  <wsoap12:operation soapAction="urn:sapcom:document:sap:rfc:functions:Z_hello_world_2:ZTEST_WEB_SERVICERequest" style="document" /> 
 <wsdl:input>
  <wsoap12:body use="literal" /> 
  </wsdl:input>
 <wsdl:output>
  <wsoap12:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
 <wsdl:service name="z_HELLO_WORLD_2">
 <wsdl:port name="Z_HELLO_WORLD_2" binding="tns:Z_HELLO_WORLD_2">
  <soap:address location="http://domainXXX:8000/sap/bc/srt/rfc/sap/z_hello_world_2/199/z_hello_world_2/z_hello_world_2" /> 
  </wsdl:port>
 <wsdl:port name="Z_HELLO_WORLD_2_soap12" binding="tns:Z_HELLO_WORLD_2_soap12">
  <wsoap12:address location="http://domainXXX:8000/sap/bc/srt/rfc/sap/z_hello_world_2/199/z_hello_world_2/z_hello_world_2" /> 
  </wsdl:port>
  </wsdl:service>
      </wsdl:definitions>

在這里,我縮短了我的 XML 代碼,因為它的大小很大。 請幫助任何人解決這個問題。

我通過在 SAP 中創建 Web 服務時將 Profile 更改為Authentication with User and Password ,No Transport Guarantee ,並在 SOAMANAGER 中,將 Transport Channel Authentication 更改為 User ID/Password 解決了上述問題。

運輸方式

C#:更改 App.Config 中的綁定 URL

解決了我的上述問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM