如何从不同的wsdl:binding类型调用“SOAP WSDL”函数,而它具有相同的函数名

时间:2017-01-19 14:43:22

标签: php xml soap wsdl

请在下面的代码中找到主要的WDSL响应。

<wsdl:binding name="BasicHttpBinding_IProductService" type="i0:IProductService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RetrieveByKey">
<soap:operation soapAction="WSTRX/Product/IProductService/RetrieveByKey" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="RetrieveCollection">
<soap:operation soapAction="WSTRX/Product/IProductService/RetrieveCollection" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Validate">
<soap:operation soapAction="WSTRX/Product/IProductService/Validate" 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="BasicHttpBinding_ICustomerService" type="i1:ICustomerService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RetrieveByKey">
<soap:operation soapAction="WSTRX/Customer/ICustomerService/RetrieveByKey" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="RetrieveCollection">
<soap:operation soapAction="WSTRX/Customer/ICustomerService/RetrieveCollection" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Validate">
<soap:operation soapAction="WSTRX/Customer/ICustomerService/Validate" 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="BasicHttpBinding_ISalesOrderService" type="i2:ISalesOrderService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RetrieveCollection">
<soap:operation soapAction="WSTRX/SalesOrder/ISalesOrderService/RetrieveCollection" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Store">
<soap:operation soapAction="WSTRX/SalesOrder/ISalesOrderService/Store" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Validate">
<soap:operation soapAction="WSTRX/SalesOrder/ISalesOrderService/Validate" 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="BasicHttpBinding_ISalesOrder_lineService" type="i3:ISalesOrder_lineService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RetrieveCollection">
<soap:operation soapAction="WSTRX/SalesOrder_line/ISalesOrder_lineService/RetrieveCollection" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Validate">
<soap:operation soapAction="WSTRX/SalesOrder_line/ISalesOrder_lineService/Validate" 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="BasicHttpBinding_ICustomer_deliveryContactService" type="i4:ICustomer_deliveryContactService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RetrieveCollection">
<soap:operation soapAction="WSTRX/Customer_deliveryContact/ICustomer_deliveryContactService/RetrieveCollection" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Validate">
<soap:operation soapAction="WSTRX/Customer_deliveryContact/ICustomer_deliveryContactService/Validate" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

下面是我用来调用“RetrieveCollection”函数的PHP代码。

    $options = array(
            'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
            'style'=>SOAP_RPC,
            'use'=>SOAP_ENCODED,
            'soap_version'=>SOAP_1_1,
            'cache_wsdl'=>WSDL_CACHE_NONE,
            'connection_timeout'=>500000,
            'trace'=>true,
            'encoding'=>'UTF-8',
            'exceptions'=>true,
            'keep_alive' => false,
        );
    try {
        $soap = new SoapClient($wsdl, $options);    
        $data = $soap->RetrieveCollection('BasicHttpBinding_ICustomerService');
    }
    catch(Exception $e) {
        die($e->getMessage());
    }  
    echo "<pre>";
    var_dump($client->__getFunctions());  
    print_r($data);
    die;

以上编码响应将类似于数组

stdClass Object
(
    [RetrieveCollectionResult] => stdClass Object
        (
            [AnyMorePages] => 
            [ExceptionInformation] => 
            [Items] => stdClass Object
                (
                    [Product] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [Id] => 21479131965317
                                    [Category] => stdClass Object
                                        (
                                            [Id] => 21487721936886
                                            [Code] => 046
                                            [Description] => DISCONTINUED
                                        )

                                    [Code] => 96RT
                                    [D_CreativeBarcode] => 761236103018
                                    [ECommerceSettings_ECommerceStatus] => Disabled
                                    [Measurements_NetWeight] => 0.110000
                                    [SellingPrice6] => 5.200200
                                    [Statistics_AvailableStockLevel] => 0.000000
                                )

                            [1] => stdClass Object
                                (
                                    [Id] => 21479131965338
                                    [Category] => stdClass Object
                                        (
                                            [Id] => 21487721936836
                                            [Code] => 021
                                            [Description] => CC Novelties
                                        )

                                    [Code] => CCBJK
                                    [D_CreativeBarcode] => 847878001384
                                    [ECommerceSettings_ECommerceStatus] => Enabled
                                    [Measurements_NetWeight] => 0.000000
                                    [SellingPrice6] => 9.166700
                                    [Statistics_AvailableStockLevel] => 61.000000
                                )

另外,$ client-&gt; __ getFunctions()函数调用响应如下所示:

array(13) {
  [0]=>
  string(62) "RetrieveByKeyResponse RetrieveByKey(RetrieveByKey $parameters)"
  [1]=>
  string(77) "RetrieveCollectionResponse RetrieveCollection(RetrieveCollection $parameters)"
  [2]=>
  string(47) "ValidateResponse Validate(Validate $parameters)"
  [3]=>
  string(62) "RetrieveByKeyResponse RetrieveByKey(RetrieveByKey $parameters)"
  [4]=>
  string(77) "RetrieveCollectionResponse RetrieveCollection(RetrieveCollection $parameters)"
  [5]=>
  string(47) "ValidateResponse Validate(Validate $parameters)"
  [6]=>
  string(77) "RetrieveCollectionResponse RetrieveCollection(RetrieveCollection $parameters)"
  [7]=>
  string(38) "StoreResponse Store(Store $parameters)"
  [8]=>
  string(47) "ValidateResponse Validate(Validate $parameters)"
  [9]=>
  string(77) "RetrieveCollectionResponse RetrieveCollection(RetrieveCollection $parameters)"
  [10]=>
  string(47) "ValidateResponse Validate(Validate $parameters)"
  [11]=>
  string(77) "RetrieveCollectionResponse RetrieveCollection(RetrieveCollection $parameters)"
  [12]=>
  string(47) "ValidateResponse Validate(Validate $parameters)"
}

我的问题是:,当我调用“RetrieveCollection”函数时,它返回所有产品详细信息。相同的功能仅用于获取客户,订单,Customer_delivery,ProductService ......

我们如何使用相同的功能获取客户,订单详情?

谢谢!

1 个答案:

答案 0 :(得分:0)

尝试使用SoapClient :: __setLocation()函数将结束点更改为http://..../WSTRX/Producthttp://..../WSTRX/Customer,然后调用特定的函数名称。