非WSDL php调用

时间:2014-10-03 05:43:04

标签: php wsdl

我是php的新手,希望将网站与某些租借软件集成在一起。他们使用非WSDL模式服务并提供了这段代码,但我对这个"这就是动作 - uri"有点困惑。我的猜测是我需要调用的方法。

    $client = new SoapClient(NULL, array(
    'location' => '21.ip2.ip3.ip4/r2ws_v5/servlet/messagerouter',
    'uri' => 'urn:this-is-the-action-uri',
    'exceptions' => 1,
    );

我可以打电话给这个并得到答复。

http://21.ip2.ip3.ip4:8080/r2ws_v5/jsp/UBS_GetAvailability.jsp

重新开始就像这样。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getAvailabilityByItemResponse xmlns:ns1="UBS/R2" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<response>
<product>
<productID xsi:type="xsd:string">TESTUB</productID>
<level xsi:type="xsd:int">1</level>
<description xsi:type="xsd:string">
<![CDATA[ testub ]]>
</description>
</level>

你能告诉我这个&#39; uri&#39;参数应该是这种情况还是应该如何格式化?

1 个答案:

答案 0 :(得分:3)

您只需创建一个PHP文件并将下面的代码放入您的PHP文件中。

$xmlRequest = "<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" .
    "<SOAP:Body>" .
    "<getAvailabilityByItem xmlns=\"UBS/R2WebServices/AvailabilityService\">" .
        "<request>" .
            "<detail xsi:type=\"xsd:string\">0</detail>" .
            "<products>".
                "<product>" .
                    "<type xsi:type=\"xsd:int\">0</type>" .
                    "<productID xsi:type=\"xsd:string\"><![CDATA[DE014SML]]></productID>" .
                    "<startDate xsi:type=\"xsd:date\">12/07/2014</startDate>" .
                    "<startTime xsi:type=\"xsd:timeInstant\">8:00 AM</startTime>" .
                    "<endDate xsi:type=\"xsd:date\">12/08/2014</endDate>" .
                    "<endTime xsi:type=\"xsd:timeInstant\">12:00 PM</endTime>" .
                "</product>".
            "</products>" .
        "</request>" .
    "</getAvailabilityByItem>" .
    "</SOAP:Body>" .
    "</SOAP:Envelope>" ;

$location_URL = 'http://21.ip2.ip3.ip4/r2ws_v5/servlet/messagerouter';

$client = new SoapClient(null, array(
'location' => $location_URL,
'uri' => "",
'trace' => 1,
    ));
$order_return = $client->__doRequest($xmlRequest, $location_URL, '' , 1);

希望你找到解决方案;)