Php 皂体总是空白的

Php 皂体总是空白的,php,soap,Php,Soap,我正在尝试使用soap集成web服务 这是xml文件: 这是我正在尝试的代码: <?php $wsdl = 'http://uatapiout.islandhopper.in/Service1.svc?wsdl'; $xml_array["RequestType"] = "AvailabilityRQ"; $xml_array["Login"] = array("UserName"=>"test","Password"=>"test","Version"=>"3.0

我正在尝试使用soap集成web服务

这是xml文件:

这是我正在尝试的代码:

<?php

$wsdl = 'http://uatapiout.islandhopper.in/Service1.svc?wsdl';

$xml_array["RequestType"] = "AvailabilityRQ";
$xml_array["Login"] = array("UserName"=>"test","Password"=>"test","Version"=>"3.0");

$xml_array["CheckAvailabilityCriteria"] = array("CheckIn" => "07/05/2017","CheckOut"=> "07/11/2017","CountryID"=> "MAU","CityID" => "MAU","Currency" => "USD","Adult" => "2","Rooms"=>array("Room"=>array("Adult"=>"2","Child"=>"0")));

$trace = true;
$exceptions = true;

try
{

    $client = new SoapClient($wsdl, array('trace' => 1)); 

    $response = $client->HotelSearch($xml_array );

    print_r($client->__getLastRequest());
    print_r($client->__getLastResponse());

}

catch (Exception $e)
{
    echo "Error!";
    echo $e ->getMessage ();
    echo 'Last response: '. $client->__getLastResponse();
}
“测试”、“密码”=>“测试”、“版本”=>“3.0”);
$xml_数组[“CheckAvailabilityCriteria”]=数组(“CheckIn”=>“07/05/2017”,“CheckOut”=>“07/11/2017”,“CountryID”=>“MAU”,“CityID”=>“MAU”,“Currency”=>“USD”,“成人”=>“2”,“房间”=>数组(“房间”=>数组(“成人”=>“2”,“儿童”=>“0”));
$trace=true;
$exceptions=true;
尝试
{
$client=newsoapclient($wsdl,array('trace'=>1));
$response=$client->HotelSearch($xml\u数组);
打印($client->u getLastRequest());
打印($client->uu getLastResponse());
}
捕获(例外$e)
{
回声“错误!”;
echo$e->getMessage();
回显“最后一个响应:”。$client->uu getLastResponse();
}
$client->\uuu getLastRequest()总是给我一个空白的正文:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Body><ns1:HotelSearch/></SOAP-ENV:Body></SOAP-ENV:Envelope>

所以,问题是为什么这个请求有一个空白的主体

请告诉我,我做错了什么

提前谢谢

编辑:

以下是xml请求示例:

<XMLRequest>
<RequestType>AvailabilityRQ</RequestType>
<Login>
    <UserName>UserName</UserName>
    <Password>Password</Password>
    <Version>3.0</Version>
</Login>
<CheckAvailabilityCriteria>
    <CheckIn>07/05/2016</CheckIn>
    <CheckOut>07/11/2016</CheckOut>
    <CountryID>MAU</CountryID>
    <CityID>MAU</CityID>
    <Currency>USD</Currency>
    <HotelCode></HotelCode>
    <HotelName></HotelName>
    <ClientNationality></ClientNationality>
    <Rooms>
        <Room>
           <Adult>2</Adult>
           <Child>2</Child>
           <ChildAges>
                <ChildAge>7</ChildAge>
                <ChildAge>14</ChildAge>
           </ChildAges>
        </Room>
        <Room>
           <Adult>2</Adult>
           <Child>0</Child>
       </Room>
    </Rooms>
</CheckAvailabilityCriteria>
</XMLRequest>

可用性
用户名
密码
3
07/05/2016
07/11/2016
茂
茂
美元
2.
2.
7.
14
2.
0

谢谢大家的支持

现在,我使用nusaop lib来做这件事

代码如下:

require_once('nusoap/lib/nusoap.php');
$wsdl = 'wdls url';

$xml_array["RequestType"] = "AvailabilityRQ";
$xml_array["Login"] = array("UserName"=>"username","Password"=>"password","Version"=>"version");

$xml_array["CheckAvailabilityCriteria"] = array("CheckIn" => "07/05/2017","CheckOut"=> "07/11/2017","CountryID"=> "MAU","CityID" => "MAU","Currency" => "USD","Rooms"=>array("Room"=>array("Adult"=>"2","Child"=>"0")));

$xml_array1['XMLRequest'] =$xml_array;


$client = new nusoap_client($wsdl, false);
$client->soap_defencoding = 'UTF-8';

$err = $client->getError();

if ($err)
{
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
    exit();
}

$result = $client->call('HotelSearch', $xml_array1,'','http://tempuri.org/IService1/HotelSearch',false,false,'','');

if ($client->fault) 
{

    echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2>';
}
else 
{
    $err = $client->getError();

    if ($err) 
    {
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    }
    else
    {

        $result_count = $array_result['TotalResult'];

        if($result_count)
        {
            $hotels_list = $array_result['AvailHotels']['Hotel'];

            for($i=0; $i<count($hotels_list);$i++)
            {
                $hotel_name = $hotels_list[$i]['@attributes']['Name'];
                $hotel_code = $hotels_list[$i]['@attributes']['Code'];

                echo "Hotel name is <i>$hotel_name</i> and hotel code is <i>$hotel_code</i>";

                echo "</br></br>";
            }
        }

    }
}
require_once('nusoap/lib/nusoap.php');
$wsdl='wdlsurl';
$xml_数组[“RequestType”]=“AvailabilityRQ”;
$xml_array[“Login”]=array(“用户名”=>“用户名”,“密码”=>“密码”,“版本”=>“版本”);
$xml_数组[“CheckAvailabilityCriteria”]=数组(“CheckIn”=>“07/05/2017”,“CheckOut”=>“07/11/2017”,“CountryID”=>“MAU”,“CityID”=>“MAU”,“Currency”=>“USD”,“Rooms”=>数组(“Room”=>数组(“成人”=>“2”,“儿童”=>“0”));
$xml_数组1['XMLRequest']=$xml_数组;
$client=newnusoap_客户端($wsdl,false);
$client->soap_defencoding='UTF-8';
$err=$client->getError();
如果($err)
{
回显“构造函数错误”。$err.';
echo'Debug'.htmlspecialchars($client->getDebug(),entu引号)。“”;
退出();
}
$result=$client->call('HotelSearch',$xml\u array1',,'http://tempuri.org/IService1/HotelSearch",假,假",;
如果($client->fault)
{
echo“Fault(期望-请求包含无效的SOAP正文)”;
}
其他的
{
$err=$client->getError();
如果($err)
{
回显“错误”。$err.';
}
其他的
{
$result_count=$array_result['TotalResult'];
如果($result\u count)
{
$hotels_list=$array_结果['AvailHotels']['Hotel'];

对于($i=0;$i,
$response=$client->HotelSearch($xml\u数组)是什么;
?这将是他需要调用的方法。但问题在于$xml_数组。您没有生成正确的Soap头。@hassan,谢谢您的回复。是的,这是一个API@Elbarto,感谢您的回复。我是soap新手,无法获得好的教程和链接。请建议一个链接。确切的xml soapheader是什么您的api正在等待身份验证?