创建WSDL PHP请求返回内部错误

时间:2012-10-29 14:27:38

标签: php soap wsdl xsd

我在执行此搜索请求时遇到大问题。

首先,我需要对自己进行身份验证,而且工作正常。

然后我需要添加安全令牌来请求标头,这也很容易。

但是当我尝试创建搜索请求时,我可以从服务器获得积极响应。

$url = 'http://devapi.stellatravelgateway.stellatravelservices.co.uk/AirService.svc?wsdl';
$search = new SoapClient($url , array('trace' => true));

$header =  new SoapHeader('http://devapi.stellatravelgateway.stellatravelservices.co.uk','AuthHeader', $token, true);
$search->__setSoapHeaders(array($header)); ?>
<h1>Search</h1> <?php var_dump($search);


$ser_par = array(
    'request'=>array(
            'SelectedAirlines' => array(),
        'MaximumConnectionTimeMins' => '',
        'MaxResultsPerAirline' => '',
        'JourneyDetails' => array(
              'JourneyDetail'=> array(
                'DepartureDateTime' => '2012-12-01T17:20:58',
                'DeparturePoint' => 'LON',
                'DeparturePointIsCity' =>   false,
                'DestinationPoint' => 'MLE',
                'DestinationPointIsCity' => false,
                'ViaPointAirportCode' => ''),
              'JourneyDetail' => array(
                'DepartureDateTime' => '2012-12-15T17:20:58',
                'DeparturePoint' => 'MLE',
                'DeparturePointIsCity' =>   false,
                'DestinationPoint' => 'LON',
                'DestinationPointIsCity' => false,
                'ViaPointAirportCode' => ''
                )),
        'SearchType' => 'Availability',
            'FlexiDays' => 0,
            'FareType' => 'All',
            'SearchSource' =>'Default',
            'ReturnIncompleteResults' => false,
            'SortOrder' => 'Price',
            'ChildPaxCount' => 1,
            'AdultPaxCount' => 1,
            'DirectFlightsOnly' => false,
            'CabinClass' => 'All',
            'InfantWithSeatPaxCount' => 0,
            'InfantPaxCount' => 1,
            'MaxResultsPerAirline' => '',
            'MaxResults' => '',
            'IncludePriorDepartues' => false,
            'SessionID'=> '070ed09a-ec58-4eee-a7d9-31942e968a3c',
));

try{
    $search->Search(array($ser_par));
}catch(SoapFault $e){
    echo '<h1> Errors: </h1>';
        var_dump($e);
}

这是输出:

Search

object(SoapClient)#218 (4) { ["trace"]=> int(1) ["_soap_version"]=> int(1) ["sdl"]=> resource(108) of type (Unknown) ["__default_headers"]=> array(1) { [0]=> object(SoapHeader)#219 (4) { ["namespace"]=> string(60) "http://devapi.stellatravelgateway.stellatravelservices.co.uk" ["name"]=> string(10) "AuthHeader" ["data"]=> string(36) "149db61f-c1d6-49e2-bf37-430ec3526053" ["mustUnderstand"]=> bool(true) } } }
Errors:

object(SoapFault)#220 (9) { ["message":protected]=> string(433) "The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs." ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(96) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/wp-content/themes/responsive/page.php" ["line":protected]=> int(151) ["trace":"Exception":private]=> array(5) { [0]=> array(6) { ["file"]=> string(96) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/wp-content/themes/responsive/page.php" ["line"]=> int(151) ["function"]=> string(6) "__call" ["class"]=> string(10) "SoapClient" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(6) "Search" [1]=> array(1) { [0]=> array(1) { [0]=> array(1) { ["request"]=> array(19) { ["SelectedAirlines"]=> array(0) { } ["MaximumConnectionTimeMins"]=> string(0) "" ["MaxResultsPerAirline"]=> string(0) "" ["JourneyDetails"]=> array(1) { ["JourneyDetail"]=> array(6) { ["DepartureDateTime"]=> string(19) "2012-12-15T17:20:58" ["DeparturePoint"]=> string(3) "MLE" ["DeparturePointIsCity"]=> bool(false) ["DestinationPoint"]=> string(3) "LON" ["DestinationPointIsCity"]=> bool(false) ["ViaPointAirportCode"]=> string(0) "" } } ["SearchType"]=> string(12) "Availability" ["FlexiDays"]=> int(0) ["FareType"]=> string(3) "All" ["SearchSource"]=> string(7) "Default" ["ReturnIncompleteResults"]=> bool(false) ["SortOrder"]=> string(5) "Price" ["ChildPaxCount"]=> int(1) ["AdultPaxCount"]=> int(1) ["DirectFlightsOnly"]=> bool(false) ["CabinClass"]=> string(3) "All" ["InfantWithSeatPaxCount"]=> int(0) ["InfantPaxCount"]=> int(1) ["MaxResults"]=> string(0) "" ["IncludePriorDepartues"]=> bool(false) ["SessionID"]=> string(36) "070ed09a-ec58-4eee-a7d9-31942e968a3c" } } } } } } [1]=> array(6) { ["file"]=> string(96) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/wp-content/themes/responsive/page.php" ["line"]=> int(151) ["function"]=> string(6) "Search" ["class"]=> string(10) "SoapClient" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> array(1) { [0]=> array(1) { ["request"]=> array(19) { ["SelectedAirlines"]=> array(0) { } ["MaximumConnectionTimeMins"]=> string(0) "" ["MaxResultsPerAirline"]=> string(0) "" ["JourneyDetails"]=> array(1) { ["JourneyDetail"]=> array(6) { ["DepartureDateTime"]=> string(19) "2012-12-15T17:20:58" ["DeparturePoint"]=> string(3) "MLE" ["DeparturePointIsCity"]=> bool(false) ["DestinationPoint"]=> string(3) "LON" ["DestinationPointIsCity"]=> bool(false) ["ViaPointAirportCode"]=> string(0) "" } } ["SearchType"]=> string(12) "Availability" ["FlexiDays"]=> int(0) ["FareType"]=> string(3) "All" ["SearchSource"]=> string(7) "Default" ["ReturnIncompleteResults"]=> bool(false) ["SortOrder"]=> string(5) "Price" ["ChildPaxCount"]=> int(1) ["AdultPaxCount"]=> int(1) ["DirectFlightsOnly"]=> bool(false) ["CabinClass"]=> string(3) "All" ["InfantWithSeatPaxCount"]=> int(0) ["InfantPaxCount"]=> int(1) ["MaxResults"]=> string(0) "" ["IncludePriorDepartues"]=> bool(false) ["SessionID"]=> string(36) "070ed09a-ec58-4eee-a7d9-31942e968a3c" } } } } } [2]=> array(4) { ["file"]=> string(90) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/wp-includes/template-loader.php" ["line"]=> int(43) ["args"]=> array(1) { [0]=> string(96) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/wp-content/themes/responsive/page.php" } ["function"]=> string(7) "include" } [3]=> array(4) { ["file"]=> string(77) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/wp-blog-header.php" ["line"]=> int(16) ["args"]=> array(1) { [0]=> string(90) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/wp-includes/template-loader.php" } ["function"]=> string(12) "require_once" } [4]=> array(4) { ["file"]=> string(68) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/index.php" ["line"]=> int(17) ["args"]=> array(1) { [0]=> string(77) "/home/sites/simplymaldivesholidays.co.uk/public_html/feeds/wp-blog-header.php" } ["function"]=> string(7) "require" } } ["previous":"Exception":private]=> NULL ["faultstring"]=> string(433) "The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs." ["faultcode"]=> string(22) "a:InternalServiceFault" }

以下是我所拥有的资源文件。

文档: http://devapi.stellatravelgateway.stellatravelservices.co.uk/documentation/

XML文档: http://devapi.stellatravelgateway.stellatravelservices.co.uk/AirService.svc?wsdl

这是示例搜索请求。我试过使用这些值但不成功。

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://stellatravelgateway.stellatravelservices.co.uk/AirService/IAirService/Search</Action>
    <AuthHeader xmlns="http://stellatravelgateway.stellatravelservices.co.uk">a80681e2-e70f-4bf0-ab0f-df81a6449c6d</AuthHeader>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Search xmlns="http://stellatravelgateway.stellatravelservices.co.uk/AirService">
      <request SearchType="Availability" FlexiDays="0" FareType="All" SearchSource="Default" ReturnIncompleteResults="false" SortOrder="Price" ChildPaxCount="1" AdultPaxCount="1" DirectFlightsOnly="false" CabinClass="All" InfantWithSeatPaxCount="0" InfantPaxCount="1">
        <SelectedAirlines />
        <MaxResultsPerAirline xsi:nil="true" />
        <JourneyDetails>
          <JourneyDetail DepartureDateTime="2012-12-01T17:20:58" DeparturePoint="LON" DeparturePointIsCity="false" DestinationPoint="MLE" DestinationPointIsCity="false" ViaPointAirportCode="" />
          <JourneyDetail DepartureDateTime="2012-12-15T17:20:58" DeparturePoint="MLE" DeparturePointIsCity="false" DestinationPoint="LON" DestinationPointIsCity="false" ViaPointAirportCode="" />
        </JourneyDetails>
        <MaxResults xsi:nil="true" />
        <IncludePriorDepartues>false</IncludePriorDepartues>
        <SessionID>070ed09a-ec58-4eee-a7d9-31942e968a3c</SessionID>
      </request>
    </Search>
  </s:Body>
</s:Envelope>

我的问题是:我在这做错了什么? 任何帮助将非常感激。 最好的祝福 PawikSD

1 个答案:

答案 0 :(得分:0)

非常感谢您的帮助。 我已经成功解决了这个问题。我已经使用SoapUI来获取正确的请求格式。 接下来我复制了它并将其作为curl请求发送。 奇迹般有效。 感谢

相关问题