2017-10-24 8 views
2

私の要件は、SOAMANAGER経由で作成されたSAP Webサービスを介してSAPにSAPに接続することです。可能なSOAPバージョンの不一致:エンベロープ名前空間 - C#のSAP Webサービス

私はこのブログに従っている - https://blogs.sap.com/2013/03/08/create-an-sap-web-service-call-web-service-from-net-application-passing-user-credentials/

私は以下の例外メッセージを取得していたコードを実行します。そのサイズ大きいので、私はカットされている。ここ

<?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コードをショート:

ここ
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()); 

がSOAMANAGER経由で作成したWSDLコードです:

An unhandled exception of type 'System.Web.Services.Protocols.SoapException' 
occurred in System.Web.Services.dll 

Additional information: Possible SOAP version mismatch: Envelope namespace 
http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting 
http://schemas.xmlsoap.org/soap/envelope/. 

はここに私のC#のコードです。 これを解決するために誰も助けてください。

答えて

0

プロファイルをに変更して、上記の問題を解決しました。SAPでWebサービスを作成するときに、ユーザーとパスワードによる認証、トランスポートの保証なし、およびSOAMANAGERでトランスポートチャネル認証をユーザーID /パスワードとして変更します。

Transport Method

のC#:app.configを

の変化バインディングURLは私の上記の問題を解決します。

関連する問題