Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify port name in php WSDL

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..

like image 953
Giordano B. Avatar asked Sep 10 '12 16:09

Giordano B.


1 Answers

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());
like image 164
Skarpi Steinthorsson Avatar answered Oct 02 '22 00:10

Skarpi Steinthorsson