簡體   English   中英

如何使用“添加服務參考”從Visual Studio中調用php服務

[英]How to call php Service from visual studio with “Add Service Reference”

我想從c#桌面應用程序中使用php服務。我通過“添加服務參考”將php服務添加到了我的項目中,但是我看不到來自方法的正確響應。

    <?xml version="1.0" encoding="UTF-8"?>
<definitions
    xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
    xmlns:SOAP-ENC = "http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:tns = "urn:Invest"
    xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsdl = "http://schemas.xmlsoap.org/wsdl/"
    xmlns = "http://schemas.xmlsoap.org/wsdl/"
    targetNamespace = "urn:Invest">
    <types>
        <xsd:schema elementFormDefault = "qualified" targetNamespace = "urn:Invest">
            <xsd:import namespace = "http://schemas.xmlsoap.org/soap/encoding/"/>
            <xsd:import namespace = "http://schemas.xmlsoap.org/wsdl/"/>
            <xsd:complexType name = "ReturnItems">
                <xsd:sequence>
                    <xsd:element
                        name = "itemName"
                        type = "xsd:string"
                        minOccurs = "0"
                        maxOccurs = "unbounded"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </types>
    <message name = "ShowDataRequest">
        <part name = "no" type = "xsd:string"/>
        <part name = "user_name" type = "xsd:string"/>
    </message>
    <message name = "ShowDataResponse">
        <part name = "return" type = "tns:ReturnItems"/>
    </message>
    <portType name = "InvestPortType">
        <operation name = "ShowData">
            <input message = "tns:ShowDataRequest"/>
            <output message = "tns:ShowDataResponse"/>
        </operation>
    </portType>
    <binding name = "InvestBinding" type = "tns:InvestPortType">
        <soap:binding style = "document" transport = "http://schemas.xmlsoap.org/soap/http"/>
        <operation name = "ShowData">
            <soap:operation soapAction = "urn:Invest#ShowData" style = "rpc"/>
            <input>
                <soap:body use = "literal" namespace = "urn:Invest"/>
            </input>
            <output>
                <soap:body use = "literal" namespace = "urn:Invest"/>
            </output>
        </operation>
    </binding>
    <service name = "Invest">
        <port name = "InvestPort" binding = "tns:InvestBinding">
            <soap:address location = "http://test.com.tr/service.php"/>
        </port>
    </service>
</definitions>

當我通過“添加服務引用”從vs2010調用ShowData方法時,響應類型為String []並始終返回string [0]。此外,我在SoapUi中使用相同的參數調用此方法。由於以下原因,請返回給我;

要求SoapUi:

<soapenv:Envelope xmlns:soapenv = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn = "urn:Invest">
<soapenv:Header/>
<soapenv:Body>
    <urn:ShowData>
        <no>475</no>
        <user_name>7302AEKI</user_name>
    </urn:ShowData>
</soapenv:Body>

響應SoapUi:

<SOAP-ENV:Envelope
xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC = "http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
    <ns1:ShowDataResponse xmlns:ns1 = "urn:Invest">
        <return>
            <item>
                <TAP>
                    <kod>
                        <item>768</item>
                    </kod>
                </TAP>
            </item>
            <item>
                <BASV>
                    <SUB>10</SUB>
                </BASV>
            </item>
            <item>
                <BASV>
                    <SIRK/>
                </BASV>
            </item>
            <item>
                <BASV>
                    <BASV_NO/>
                </BASV>
            </item>
            <item>
                <aaa>bbb</aaa>
            </item>
        </return>
    </ns1:ShowDataResponse>
</SOAP-ENV:Body>

因此,可以通過“添加服務參考”從VS2010調用此服務,或者應該是什么?

謝謝..

據我所知,WSDL與實際響應不匹配。 要獲得響應,您希望修復WSDL或響應。

暫無
暫無

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

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