How to specify port name in php WSDL

隐身守侯 提交于 2020-01-12 08:09:29

问题


How do I select the port in SOAP PHP? I'm developing a travel booking website with TravelPort as the GDS. I've just began looking at their WSDLs and I'm trying to use them to call their server with PHP. I'm not able to do it. I know that the server works, because if I craft a request and send it through cURL, I get the response I'm expecting, but by using and adapting their own sample code (accept confidentiality agreement, and then click “Sample Code” to see), I'm not going anywhere.

By looking at the request the SOAP PHP Module generates, I think the problem is that it uses the wrong function. I don't think I can disclose the whole WSDL, but here is an excerpt:

<!-- Service -->

<service name="AirService">
    <port name="AirRepriceSearchPort"
          binding="tns:AirRepriceSearchBinding">
        <soap:address
                location="http://localhost:8080/kestrel/AirService" />
    </port>

    <port name="AirScheduleSearchPort"
          binding="tns:AirScheduleSearchBinding">
        <soap:address
                location="http://localhost:8080/kestrel/AirService" />
    </port>

    <port name="AirLowFareSearchPort"
          binding="tns:AirLowFareSearchBinding">
        <soap:address
                location="http://localhost:8080/kestrel/AirService" />
    </port>

Apparently the script always generates the request based on the AirReprice module instead of the LowFareSearch module. In fact, if I edit the WSDL and put “AirLowFareSearchPort” as the first element, the request works.

I've tried the following:

  • Specify what action to take by using $client->AirLowFareSearchPort($data), but it is not a valid function;

  • I got all the functions by using $client->__getfunctions():

:

 [0]=>
 string(48) "AirRepriceRsp service(AirRepriceReq $parameters)"
 [1]=>
 string(56) "ScheduleSearchRsp service(ScheduleSearchReq $parameters)"
 [2]=>
 string(54) "LowFareSearchRsp service(LowFareSearchReq $parameters)"
 [3]=>
 string(66) "LowFareSearchAsynchRsp service(LowFareSearchAsynchReq $parameters)"

It looks like the only “function” is “service.” But I don't get where I would put the stuff in the brackets.

I have no other ideas. Hopefully you'll be able to help!

UPDATE:

I've found this article where it exposes the problem. However, it refers to their own module called PHP Web Services. I need to do the same thing with SOAP. I really need your help..


回答1:


You should be able to set the endpoint manually with __setLocation once you have loaded the WSDL.

Example:

$client = new SoapClient('http://localhost/supplied_path?wsdl');
$client->__setLocation('http://localhost:8080/kestrel/AirService');

print_r($client->__getfunctions());


来源:https://stackoverflow.com/questions/12355366/how-to-specify-port-name-in-php-wsdl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!