我试图弄清楚如何使用SAP网络服务。我有一个.WSDL文件,它在SAP中查找某些信息。
我的.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>
提前致谢
答案 0 :(得分:1)
我正在研究这个主题,这里有一个关于如何创建请求并在.NET中调用SAP服务(C#)的示例。
// 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;