Search code examples
phpweb-servicessoapwsdl

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=

Solution

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