【问题标题】:.NET consume SAP web service.NET 使用 SAP Web 服务
【发布时间】:2015-11-18 07:36:26
【问题描述】:

我正在尝试弄清楚如何使用 SAP 网络服务。我有一个在 SAP 中查找某些信息的 .WSDL 文件。

我的 .WSDL 文件:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="Customer_Out" targetNamespace="..." xmlns:p1="...." xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:documentation/>
    <wsp:UsingPolicy wsdl:required="true"/>
    <wsp:Policy wsu:Id="OP_CustomerRead_sync"/>
    <wsdl:types>
        <xsd:schema targetNamespace="..." xmlns="..." xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <xsd:element name="MT_CustomerRead_response" type="DT_CustomerRead_response"/>
            <xsd:element name="FMT_Customer">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="standard" type="ExchangeFaultData"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="MT_CustomerRead_request" type="DT_CustomerRead_request"/>
            <xsd:complexType name="ExchangeFaultData">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/VersionID">..</xsd:appinfo>
                </xsd:annotation>
                <xsd:sequence>
                    <xsd:element name="faultText" type="xsd:string"/>
                    <xsd:element name="faultUrl" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="faultDetail" type="ExchangeLogData" minOccurs="0" maxOccurs="unbounded"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="DT_Customer">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
                </xsd:annotation>
                <xsd:sequence>
                    <xsd:element name="BpId" type="xsd:string">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="Name" type="xsd:string">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="AccountGroup" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="Street" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="Number" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="City" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="Country" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="Region" type="xsd:string" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="DT_CustomerRead_request">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
                </xsd:annotation>
                <xsd:sequence>
                    <xsd:element name="RowLimit" type="xsd:integer"/>
                    <xsd:element name="BpId" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                        <xsd:simpleType>
                            <xsd:restriction base="xsd:string">
                                <xsd:maxLength value="10"/>
                            </xsd:restriction>
                        </xsd:simpleType>
                    </xsd:element>
                    <xsd:element name="Name" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="ExternalCustomer" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="AccountGroup" type="xsd:string" minOccurs="0">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ExchangeLogData">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
                </xsd:annotation>
                <xsd:sequence>
                    <xsd:element name="severity" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="text" type="xsd:string"/>
                    <xsd:element name="url" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="id" type="xsd:string" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="DT_CustomerRead_response">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
                </xsd:annotation>
                <xsd:sequence>
                    <xsd:element name="Customer" type="DT_Customer" minOccurs="0" maxOccurs="unbounded">
                        <xsd:annotation>
                            <xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element name="Remark" type="xsd:string" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="MT_CustomerRead_request">
        <wsdl:documentation/>
        <wsdl:part name="MT_CustomerRead_request" element="p1:MT_CustomerRead_request"/>
    </wsdl:message>
    <wsdl:message name="MT_CustomerRead_response">
        <wsdl:documentation/>
        <wsdl:part name="MT_CustomerRead_response" element="p1:MT_CustomerRead_response"/>
    </wsdl:message>
    <wsdl:message name="FMT_Customer">
        <wsdl:documentation/>
        <wsdl:part name="FMT_Customer" element="p1:FMT_Customer"/>
    </wsdl:message>
    <wsdl:portType name="Customer_Out">
        <wsdl:documentation/>
        <wsdl:operation name="CustomerRead_sync">
            <wsdl:documentation/>
            <wsp:Policy>
                <wsp:PolicyReference URI="#OP_CustomerRead_sync"/>
            </wsp:Policy>
            <wsdl:input message="p1:MT_CustomerRead_request"/>
            <wsdl:output message="p1:MT_CustomerRead_response"/>
            <wsdl:fault name="FMT_Customer" message="p1:FMT_Customer"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="Customer_OutBinding" type="p1:Customer_Out">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
        <wsdl:operation name="CustomerRead_sync">
            <soap:operation soapAction="http://sap.com/xi/WebService/soap1.1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
            <wsdl:input>
                <soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
            </wsdl:output>
            <wsdl:fault name="FMT_Customer">
                <soap:fault use="literal" name="FMT_Customer" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="Customer_OutService">
        <wsdl:port name="HTTP_Port" binding="p1:Customer_OutBinding">
            <soap:address location="..." xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
        </wsdl:port>        
    </wsdl:service>
</wsdl:definitions>

我已经向我的 .NET 项目添加了一个服务引用,它引用了 .WSDL 文件。这将创建一个命名空间,允许我创建几个类(总共 9 个)的实例。

我似乎找不到如何传递请求并接收相应的响应。我应该解析这些请求/响应吗?我知道this 教程,但它与我正在处理的文件并不真正对应。

请求如下所示:

<man:MT_CustomerRead_request>
         <RowLimit>100</RowLimit>
         <!--Optional:-->
         <!-- <CustomerId>?
         <!--Optional:-->
         <Name>Dell*</Name>
         <!--Optional:-->
         <!--Optional:-->
         <AccountGroup>ABC</AccountGroup>
</man:MT_CustomerRead_request>

提前致谢

【问题讨论】:

    标签: c# asp.net web-services soap sap


    【解决方案1】:

    我正在研究这个主题,这里有一个关于如何在 .NET (C#) 中创建请求和调用 SAP 服务的示例。

    // Create the client
    SapServiceReference.ECC_WS sapService = new SapServiceReference.ECC_WS();
    sapService.Credentials = new NetworkCredential("Account", "Password");
    
    // Prepare the parameters
    SapServiceReference._parameters param = new SapServiceReference._parameters();
    param.id = 1;
    param.action = "R";
    
    // Call SAP service
    SapServiceReference._ws_Response response = sapService._someFunction(param);
    string result = response.EvDescriptionText.Tdline;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-09
      • 2011-01-15
      相关资源
      最近更新 更多