Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .NET使用SAP web服务_C#_Asp.net_Web Services_Soap_Sap - Fatal编程技术网

C# .NET使用SAP web服务

C# .NET使用SAP web服务,c#,asp.net,web-services,soap,sap,C#,Asp.net,Web Services,Soap,Sap,我正试图弄清楚如何使用SAP Web服务。我有一个.WSDL文件,它在SAP中查找某些信息 My.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="h

我正试图弄清楚如何使用SAP Web服务。我有一个.WSDL文件,它在SAP中查找某些信息

My.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个)

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

请求如下所示:

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

100
戴尔*
基础知识

提前感谢

我正在研究这个主题,下面是一个关于如何在.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;