Uncaught SoapFault exception: [HTTP] Bad Request

家住魔仙堡 提交于 2019-12-11 04:36:21

问题


i am trying to make a Soap request i says this error :

Uncaught SoapFault exception: [HTTP] Bad Request in C:\

<?php
$client = new SoapClient(null, array('location' => "http://webservices.micros.com/ows/5.1/Availability.wsdl#FetchCalendar",
                                     'uri'      => "http://###.###.###.##:8080/ows_ws_51/Availability.asmx?wsdl"));

//print_r($client);

$para = array('StayDateRange' => array('StartDate' => '2013-10-01','EndDate' => '2013-10-10'),'GuestCount'=>array('GuestCountageQualifyingCode'=>'ADULT','GuestCountageQualifyingCode'=>'CHILD'));


$ns = 'http://webservices.micros.com/og/4.3/Availability/'; //Namespace of the WS.
//Body of the Soap Header.
$headerbody = array('OriginentityID' => 'OWS',
                    'DestinationentityID' => 'WEST',
                    'systemType'=>'WEB',
                      'systemType'=>'ORS');
//Create Soap Header.       
$header = new SOAPHeader($ns, 'OGHeader', $headerbody);       
//set the Headers of Soap Client.
$client->__setSoapHeaders($header);

$client->__soapCall("FetchCalendar", $para);


?>

whats wrong in my code ?

after adding Exception handling : http://postimg.org/image/6w9lmac1d/

EDIT: XML Added

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <OGHeader transactionID="005435" timeStamp="2008-12-09T13:26:56.4056250-05:00" xmlns="http://webservices.micros.com/og/4.3/Core/">
      <Origin entityID="OWS" systemType="WEB" />
      <Destination entityID="WEST" systemType="ORS" />
    </OGHeader>
  </soap:Header>
  <soap:Body>
    <FetchCalendarRequest xmlns:a="http://webservices.micros.com/og/4.3/Availability/" xmlns:hc="http://webservices.micros.com/og/4.3/HotelCommon/" xmlns="http://webservices.micros.com/ows/5.1/Availability.wsdl">
      <HotelReference chainCode="AXA" hotelCode="AXAMUM" />
      <StayDateRange>
        <hc:StartDate>2013-10-01</hc:StartDate>
        <hc:EndDate>2013-10-10</hc:EndDate>
      </StayDateRange>
      <GuestCount>
        <hc:GuestCount ageQualifyingCode="ADULT" count="1" />
        <hc:GuestCount ageQualifyingCode="CHILD" count="0" />
      </GuestCount>
    </FetchCalendarRequest>
  </soap:Body>
</soap:Envelope>

回答1:


I believe there are 2 layer of problem, first you didn't catch the exception when it is thrown. second you request might be incorrect/invalid that's why it returns 400 bad request

try{
      $client->__soapCall("FetchCalendar", $para);
}catch (SoapFault $exception){
      //or any other handling you like
      var_dump(get_class($exception));
      var_dump($exception);
}


来源:https://stackoverflow.com/questions/18735748/uncaught-soapfault-exception-http-bad-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!