2

我正在尝试提出 Soap 请求我说这个错误:

未捕获的 SoapFault 异常:[HTTP] 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);


?>

我的代码有什么问题?

添加异常处理后:http: //postimg.org/image/6w9lmac1d/

编辑:添加了 XML

<?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>
4

1 回答 1

1

我相信有两层问题,首先你在抛出异常时没有捕获异常。您请求的第二个可能不正确/无效,这就是它返回 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);
}
于 2013-09-11T08:35:55.420 回答