Hearaman
Hearaman

Reputation: 8726

Invalid XML error in soap response?

This is my xml file

 <OTA_HotelDestinationsRQ Version="1.0">
       <POS>
        <Source>
            <UniqueId Id="login:pass" />
        </Source>
       </POS>
      <DestinationInformation LanguageCode="EN" />
</OTA_HotelDestinationsRQ>

I have converted this xml into an array and i wrote client request in php. It is giving Invalid XML as a response. Could you please help me.

$ary=array(
     "OTA_HotelDestinationsRQ"=>array("Version"=>"1.0"),
     "POS"=>array(
          "Source"=>array(
               "UniqueId"=>array("Id"=>"login:pass")
          )
     ),
     "DestinationInformation"=>array("Version"=>"EN")
);

$wsdl="http://acceptance.travelstreet.com/hotelsv3/components/Hotels_DestinationsWS.cfc?wsdl";
$client=new SoapClient($wsdl,array('trace' => 1));
try
{
     $res=$client->OTA_HotelDestinationsRQ($ary);
     //$res=$client->__call("OTA_HotelDestinationsRQ",array($ary));
}
catch (SoapFault $Exception)
{
     echo 'SoapFault Exception';
}
echo $res;
?>

Upvotes: 0

Views: 2735

Answers (1)

CamelBlues
CamelBlues

Reputation: 3764

Do you have an XML doctype defined at the top of your request?

I also would suggest generating your SOAP request in a more object-oriented way. You can plug your soap URL into apigenerator.com and using the SOAPClient class it generates.

Then you could make a request class with all the paramaters from the web service like:

class mySOAPRequest
{
public function makeRequestObject($param1, $param2)
{
$this->param1 = $param1;
$this->param2 = $param2;
}
}

And to make the actual soap request, you would generate a new mySOAPRequest object and pass it into a new object of the class from API Generator, like:

$mySoapConnection = new SoapClientFromAPIGenerator();
$mySoapRequest = new mySoapRequest();

$mySoapConnection->whateverSOAPMethod($mySoapReqest->makeRequestObject($param1, $param2));

That's how I normally build SOAP requests

Upvotes: 2

Related Questions