Blessan Kurien
Blessan Kurien

Reputation: 1665

Getting response from SOAP in php

I am trying to response from web service using SOAP in php.Actually its paid API fore booking flights.I have two cases for my problem,in both cases i didnt get the response properly.

Here is the code

        try{
        $client = new SoapClient($url);
        print_r($client->__getFunctions());
        $values = $client->getAvailability($input_xml);
        print_r($values);
        }catch(exception $e){
            echo 'error<br>';
            echo $e->getMessage();
        }

CASE 1

$url=http://59.162.33.102/ArzooWS/services/DOMFlightAvailability

in this case i will get an exception

SOAP-ERROR: Parsing WSDL: Couldn't find in 'http://59.162.33.102/ArzooWS/services/DOMFlightAvailability'

CASE 2

$url=http://59.162.33.102/ArzooWS/services/DOMFlightAvailability?wsdl

in this case no exception i will get the output of __getFunctions() but the response is

invalid XML format

I had contacted the API service providers they will say everything up and running. Here is the xml

<?xml version="1.0" encoding="UTF-8"?>
            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
            <soapenv:Body>
              <getAvailability xmlns="http://avail.flight.arzoo.com">
              <in0>
                <Request>   
                <Origin>BOM</Origin>
                <Destination>BLR</Destination>
                <DepartDate>2015-05-15</DepartDate>
                <ReturnDate>2015-05-20</ReturnDate>
                <AdultPax>1</AdultPax>
                <ChildPax>1</ChildPax>
                <InfantPax>1</InfantPax>
                <Currency>INR</Currency>
                <Preferredclass>B</Preferredclass>
                 <mode>ROUND</mode> 
                <Clientid>7XXX</Clientid>
                <Clientpassword>XX</Clientpassword>
                <Clienttype>XXX</Clienttype>
                <PreferredAirline>AI,G8,IC,6E</PreferredAirline>
                </Request> 
        </in0>
    </getAvailability>
    </soapenv:Body></soapenv:Envelope>

UPDATE Here is a sample response of only one flight

20875
            7303
            130
            0
            0
            0


            0
            0
            0




            319
            BLR
            2015-05-15T07:45:00
            BOM
            2015-05-15T06:15:00
            603
            AI
            603

            0
            Air India
            3860
            http://live.arzoo.com/FlightWS/image/AirIndia.gif


              3
              Z


              13250
              Z
              6625
              Business
              mek+yu2iz7Q=
              1000
              This fare is Non Refundable Booking Class : Z|Cancellation Penalty: All bookings done are subject to cancellation penalty levied by the airlines.<br>In addition to the airlines cancellation penalty, we charge a service fee of Rs. 50 per passenger for all cancellations.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 50 per passenger.|
              0
              0
              0

            0
            3369
            74
            2150,147,1563
            2150,147,1072
            0,0,74
            0


        arzoo11
        h/jf17QHSJphWFSOTFWg8tk50VHVm+kKk3MJJ4NqTDo3mXlTqg2QNScTJzH+TWN+pNURIyTJYKOW
O8yH8+0tznjZpdCApJT4KQTfIRJRrTZDwLtSiN0xXggcK2BneoFH2Pr/Vo/CRI/xTgfh9d8ZSmFY
VI5MVaDyYfwphO4fcQEnEycx/k1jftlsnmWWqYGnJxMnMf5NY36YIq2FtLkfcHtsd+IDEhxpxJuT
v4YyS+QnEycx/k1jfv+QxLuqYmdiJxMnMf5NY37/kMS7qmJnYicTJzH+TWN+OT2lxrlMEOeSMz+b
qzlxwlz7VeZtrnP7Hv3jj2fYS5nICxQuxGH6/79fDhZYRaCPuGMF+eC/zteWO8yH8+0tzpu80ORl
KER+BD/GuWW7DZ2bbbGbXj1Z0HOJPC4p49y3JxMnMf5NY377cKnYYdkF4kP854vEBONogwbVnQw0
AohFgCa1qKcQs0PAu1KI3TFezaEuVisWRglDwLtSiN0xXs2hLlYrFkYJQ8C7UojdMV7NoS5WKxZG
CUPAu1KI3TFezaEuVisWRglDwLtSiN0xXtz6IhL3LsgmAeGKrEtqevYnEycx/k1jfuI7TUNwKUQ0
x8cEZXwg6V6nH6TvjNSCRUPAu1KI3TFej7Y1Yu+fHhBzqWDbQb1E1IoDSY1wep73c6lg20G9RNSn
Ux8jbjT6hrp5c9fnhtxFljvMh/PtLc5KhxZKtuH3cJY7zIfz7S3O/SUTzGstO8VofEuXJIOZ0ptt
sZtePVnQqDUuNolYhru/Xw4WWEWgj4D+4B+dOi9iv18OFlhFoI+A/uAfnTovYr9fDhZYRaCPCq4g
JlaBMkdzqWDbQb1E1KdTHyNuNPqGz7rBmgDnrsY=

Upvotes: 0

Views: 2508

Answers (3)

Dinesh Gurjar
Dinesh Gurjar

Reputation: 1

this is working code of flight availibility by arzoo.. i also getting error while using SOAP CLIENT but when i use nusoap then they give me result..using this code if u get error like ip/password mismatch then You will call arzoo to verify your clientid and clientpassword

    <?php
  ini_set('max_execution_time','180');
    include 'lib/nusoap.php';
   $location_URL ='http://avail.flight.arzoo.com';
   $action_URL ='http://demo.arzoo.com/ArzooWS/services/DOMFlightAvailability?wsdl';
$Request = '<Request>
<Origin>BOM</Origin>
<Destination>DEL</Destination>
<DepartDate>2017-02-02</DepartDate>
<ReturnDate>2017-02-02</ReturnDate>
<AdultPax>1</AdultPax>
<ChildPax>0</ChildPax>
<InfantPax>0</InfantPax>
<Currency>INR</Currency>
<Clientid>Given by Arzoo.com</Clientid>
<Clientpassword>Given by Arzoo.com</Clientpassword>
<Clienttype>ArzooFWS1.1</Clienttype>
<Preferredclass>E</Preferredclass>
<mode>ONE</mode>
<PreferredAirline>AI</PreferredAirline>
</Request>';

$clientinfo = array('soap_version'=>SOAP_1_1,
'location' =>$location_URL,
'uri' =>$action_URL,
 'style' => SOAP_RPC,
 'use' => SOAP_ENCODED,
 'trace' => 1,
 );

 $client = new nusoap_client('http://demo.arzoo.com/ArzooWS/services/DOMFlightAvailability?wsdl', $clientinfo);
//print_r($client);
$result = $client->call('getAvailability', array($Request));
echo"<pre>";
print_r($result);
$clientInfo =simplexml_load_string(utf8_encode($result));
$flight = $clientInfo->Response__Depart->OriginDestinationOptions->OriginDestinationOption;
$error =$clientInfo->error__tag;
//echo $error;
var_dump($flight);
//exit;
//echo"<pre>";
//print_r($result);
//ECHO $error;
?>

Upvotes: -1

Maxime Mettey
Maxime Mettey

Reputation: 337

I think there is too much informations in your XML.

Do you have any documentation about how to format the XML to call the getAvailability() function ?

The XML would be more like this in my opinion :

<Request>   
    <Origin>BOM</Origin>
    <Destination>BLR</Destination>
    <DepartDate>2015-05-15</DepartDate>
    <ReturnDate>2015-05-20</ReturnDate>
    <AdultPax>1</AdultPax>
    <ChildPax>1</ChildPax>
    <InfantPax>1</InfantPax>
    <Currency>INR</Currency>
    <Preferredclass>B</Preferredclass>
    <mode>ROUND</mode> 
    <Clientid>7XXX</Clientid>
    <Clientpassword>XX</Clientpassword>
    <Clienttype>XXX</Clienttype>
    <PreferredAirline>AI,G8,IC,6E</PreferredAirline>
</Request>

To read the XML response, do this :

$values_array = json_decode(json_encode((array)simplexml_load_string($values)),1);

There is no simple way to print your data in an HTML table because the reponse is a multidimensionnal array. Check How to create a HTML Table from a PHP array? to see how to parse an array to print an HTML table.

Upvotes: 3

Furgas
Furgas

Reputation: 2844

According to WSDL, in0 should be string:

<wsdl:message name="getAvailabilityRequest">
    <wsdl:part name="in0" type="xsd:string"></wsdl:part>
</wsdl:message>

How did you came up with such XML, since WSDL doesn't describe it? Do you have any other documentation for this service?

Upvotes: 0

Related Questions