3

I'm using a provider wsdl with SoapClient but when I use the command __getFunctions I get something like this:

method1Rsp service(method1Req $parameters)
method2Rsp service(method2Req $parameters)
method3Rsp service(method3Req $parameters)
method4Rsp service(method4Req $parameters)
method5Rsp service(method5Req $parameters)

So,I can only call the function "service()" or use __soapCall('service',$info) but I always get the "method1" schema. If I use __doRequest() I can send the method I want in a self writen xml and works fine, but it's a pity... If I send the method name in the $info array, it also uses the first method.

Question: Is there a way to call specific methods using __soapCall() or the service function, or I have to modify the wsdl?

Edit:

Here is a xml request used with __doRequest:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <LowFareSearchReq TargetBranch="" xmlns="http://www.travelport.com/schema/air_v20_0" xmlns:com="http://www.travelport.com/schema/common_v17_0">
            <com:BillingPointOfSaleInfo OriginApplication="UAPI"/>
            <SearchAirLeg>
                <SearchOrigin>
                    <CityOrAirport Code="LON" xmlns="http://www.travelport.com/schema/common_v17_0" />
                </SearchOrigin>
                <SearchDestination>
                    <CityOrAirport Code="MUC" xmlns="http://www.travelport.com/schema/common_v17_0" />
                </SearchDestination>
                <SearchDepTime PreferredTime="2013-02-10" />
                <AirLegModifiers>
                    <PreferredCabins>
                        <CabinClass Type="Economy" />
                    </PreferredCabins>
                </AirLegModifiers>
            </SearchAirLeg>
            <SearchPassenger Code="ADT" Age="30" xmlns="http://www.travelport.com/schema/common_v17_0"/>
            <AirPricingModifiers CurrencyType="EUR">
            </AirPricingModifiers>
        </LowFareSearchReq>
    </s:Body>
</s:Envelope>

The location of the webservice is http://webservicename/AirService despite the method you have to use. This works okay, but the response is also and xml string. Further more, the schemas are not updated if I change the wsdl file in a future update. Using __soapCall returns an stdClass object and gets the schemas automatically.

Luís Cruz
  • 14,780
  • 16
  • 68
  • 100
castledom04
  • 207
  • 2
  • 13
  • Even all those service-names are the same (across all different bindings), the service URIs do vary for this document style SOAP service per each binding and therefore per each request. I therefore would try if the *location* and/or *uri* SoapClient options are helpful here. See http://www.php.net/soapclient.soapclient – hakre Feb 08 '13 at 08:39
  • The location is always the same, `http://webservicename/AirService` Depending on the xml request it returns the correct service response. But as I said, using `$client->__soapCall('service',$info);` or `$client->service($info);` it generates always the first method xml (method1Req), no matter what values I have in `$info`. – castledom04 Feb 08 '13 at 11:26
  • 1
    Hmm, I got different locations (but not for the first two, right), later e.g.: `http://localhost:8080/kestrel/FlightService` - However check the bindings, they vary always, e.g. `AirCreateReservationBinding`, `AirPrePayBinding`, `FlightDetailsBinding`, `AirLowFareSearchBinding`, `AirLowFareSearchAsynchBinding`, `AirRetrieveLowFareSearchBinding`, `AirScheduleSearchBinding`, ... (there are more operations named service than there are those service methods. Looks like you need to specify the binding. Sorry no clue how that works so far. Not even a real idea what that means. – hakre Feb 08 '13 at 12:39
  • I confused too, I'll try to find the way. I think the key is on the wsdl and how the soapClient reads it, with `__doRequest` sending the written xml works ok. – castledom04 Feb 08 '13 at 14:41
  • Yes with __doRequest you can do "everything" :) Can you add to your question the exemplary XML of such a working request? This might help me (and others) spot something. – hakre Feb 08 '13 at 14:43

2 Answers2

1

I think you can call service with custom paramert (method1Req or method2Req, etc). And PHPSoap library determine necessary method itself

Ramil Amerzyanov
  • 1,301
  • 12
  • 26
0

Assuming you're using the internal SOAP library, I think you can call the distinct operations using the correct parameters. You can do it using internal helper class SoapParam. Lets imagine that method3req needs username and log-in parameters. If you want use it, you should have something like:

 $soap = new SoapClient( $wsdl );

 class method3req{
   public $username;
   public $password;
 }

 $m3r = new method3req();

 $m3r->username = new SoapVar( 'user', SOAP_STRING, $namespace,...);
 $m3r->password = new SoapVar( 'pwd', SOAP_STRING, $namespace,...);

 $tmp = new SoapVar( $m3r, SOAP_ENV_OBJECT, $namespace, ...);
 $soap->__soapCall( 'service', $tmp ); 

You can look for helper class SoapParam too.

NDRange
  • 16
  • 2