0

I am trying to call web service via SOAP. I feel that the PHP request looks about right. Below is the SOAP PHP code and, the XML. Please let me know what may be wrong. I technically keep getting response of object has no property.

This is the error message:

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'schema' property

$client = new SoapClient(
    'Link.asmx?wsdl',
    array(
        'soap_version' => SOAP_1_1,
        'trace'        => 1,
    )
);

$result = $client->OTA_VehAvailRate(
    array(
        'OTA_VehAvailRateRQ' => array(
            'VehAvailRQCore' => array(
                'VehRentalCore' => array(
                    'type'           => 'VehicleRentalCoreType',
                    'PickUpLocation' => array(
                        'LocationCode' => 'ERLAX01',
                    ),
                    'PickUpDateTime' => '2013-03-14T12:00:00',
                    'ReturnDateTime' => '2013-03-16T12:00:00',
                    'ReturnLocation' => array(
                        'LocationCode' => 'ERLAX01',
                    ),
                ),
                'VendorPrefs'   => array(
                    'VendorPref' => array(
                        'Code'        => '*****',
                        'CodeContext' => '******',
                    ),
                ),
                'VehPrefs'      => array(
                    'VehPref' => array(
                        'Code' => 'HFG',
                    ),
                ),

                'RateQualifier' => array(
                    'PromotionCode' => '',
                    'RateQualifier' => '',
                ),
            ),
        )
    )
);

print_r($result);

Here is the XML Schema.

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <tns:OTA_VehAvailRate xmlns:tns="http://www.opentravel.org/OTA/2003/05" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:tnsC="http://www.w3.org/1999/xhtml" xmlns:vs="http://schemas.microsoft.com/Visual-Studio-Intellisense" xmlns:tnsB="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <AA:OTA_VehAvailRateRQ xmlns:AA="http://www.opentravel.org/OTA/2003/05" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" Version="0">
                <AA:VehAvailRQCore>
                    <AA:VehRentalCore xs:type="AA:VehicleRentalCoreType" PickUpDateTime="2013-03-14T12:00:00" ReturnDateTime="2013-03-16T12:00:00">
                        <AA:PickUpLocation LocationCode="ERLAX01" />
                        <AA:ReturnLocation LocationCode="ERLAX01" />
                    </AA:VehRentalCore>
                    <AA:VendorPrefs>
                        <AA:VendorPref Code="****" CodeContext="******" />
                    </AA:VendorPrefs>
                    <AA:VehPrefs>
                        <AA:VehPref Code="HEG" />
                    </AA:VehPrefs>
                    <AA:RateQualifier PromotionCode="" RateQualifier="" />
                </AA:VehAvailRQCore>
            </AA:OTA_VehAvailRateRQ>
        </tns:OTA_VehAvailRate>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Please let me know what I am doing wrong. thanks a lot

POST /OTA2011A/OTASrvc.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.opentravel.org/OTA/2003/05/OTA_VehAvailRate"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <OTA_VehAvailRate xmlns="http://www.opentravel.org/OTA/2003/05">
      <OTA_VehAvailRateRQ>
        <xsd:schema>schema</xsd:schema>xml</OTA_VehAvailRateRQ>
    </OTA_VehAvailRate>
  </soap:Body>
</soap:Envelope>
hakre
  • 193,403
  • 52
  • 435
  • 836
Mike131
  • 19
  • 1
  • 7
  • You might be missing something from the specification, maybe you need to pass on a schema property or something similar. – silkfire Feb 19 '13 at 16:59
  • share the schema too. – जलजनक Feb 19 '13 at 19:15
  • This error is frequently caused by passing elements in the wrong order. – EmmyS Feb 19 '13 at 19:43
  • It appears that all the request I am sending via PHP are giving me the same error. When I send the XML via SOAP UI, I getting successful responses. This is odd. I know the PHP is valid, and I missing possibly a header? – Mike131 Feb 19 '13 at 21:47
  • You might not built the parameter object as you need to. At least the error sounds that way to me. Please double check. You see the problem in your XML you send? (It's obvious not a valid SOAP request for that WSDL). – hakre Feb 20 '13 at 10:34
  • Thanks, I think I see the issue. I am going to attempt. – Mike131 Feb 20 '13 at 15:13

1 Answers1

0

If you are working on OTA, I really suggest you to try https://github.com/goetas-webservices/soap-client

Is fully PHP SOAP client that does not rely on the ext-soap from PHP. It already supports is PSR7, multiclient and allows to have generated classes for type-hinting via your IDE.

https://github.com/goetas-webservices/soap-client-demo is demo project that allows you to see how to use the client to consume a generic SOAP webservice.

The project is based on https://github.com/goetas-webservices/xsd2php that internally uses OTA as test suite (and the test suite is passing).

Asmir Mustafic
  • 533
  • 4
  • 14