Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP SOAP XML请求问题_Php_Xml_Web Services_Soap_Soap Client - Fatal编程技术网

PHP SOAP XML请求问题

PHP SOAP XML请求问题,php,xml,web-services,soap,soap-client,Php,Xml,Web Services,Soap,Soap Client,我已经在PHP中创建了SOAP XML请求,用于从另一个应用程序获取一些数据 我的PHP脚本是: try { class AuthHeader { var $LoginName; var $Password; var $Culture; var $Version; function __construct($loginInfo) { $this->LoginName = $loginInfo['

我已经在PHP中创建了SOAP XML请求,用于从另一个应用程序获取一些数据

我的PHP脚本是:

try {
    class AuthHeader {
        var $LoginName;
        var $Password;
        var $Culture;
        var $Version;

    function __construct($loginInfo) {
      $this->LoginName  = $loginInfo['LoginName'];
      $this->Password   = $loginInfo['Password'];
      $this->Culture    = $loginInfo['Culture'];
      $this->Version    = $loginInfo['Version'];
    }
}

// set current soap header with login info
$client = new SoapClient("http://demo-example.abc.com/hoteldata.svc?wsdl", array('trace' => TRUE));

// create header params array
$headerParams = array('LoginName'   => 'username',
                      'Password'    => 'password',
                      'Culture'     => 'en_US',
                      'Version'     => '7.123');

// create AuthHeader object
$auth = new AuthHeader($headerParams);

// Turn auth header into a SOAP Header
$header = new SoapHeader('http://schemas.abc.com/webservices/authentication', 'AuthenticationHeader', $auth, false);

// set the header
$client->__setSoapHeaders($header);

$b = new stdClass;
$b->HotelID = '3813';
$b->HotelID = '1322208';

$p = new stdClass;
$p->request->HotelIds            = array($b);

$quote = $client->GetHotelDetailsV3($p);

echo("<br />REQUEST :<br />" . htmlspecialchars($client->__getLastRequest()) . "<br/>");  
echo("<br />RESPONSE:<br />" .htmlspecialchars($client->__getLastResponse()) . "</pre>"); 
}
catch (SoapFault $ex)
{
    echo "Error:<br />" . nl2br($ex->faultcode) . '<br /><br />Error Details:<br />'. nl2br($ex->faultstring) . '<br />';  
    echo("<br />REQUEST :<br />" . htmlspecialchars($client->__getLastRequest()) . "<br/>");  
echo("<br /><span style=color:green;>RESPONSE:</span><br />" .htmlspecialchars($client->__getLastResponse()) . "<br />");
}

?>

这是正确的吗?使用节点属性创建xml请求的最佳方法是什么?请帮忙。谢谢。

能否尝试以多数组格式传递这些ID?能否尝试以多数组格式传递这些ID?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aut="http://schemas.example.com/webservices/authentication" xmlns:hot="http://example.com/webservices/hotelv3">
   <soapenv:Header>
      <aut:AuthenticationHeader>
         <aut:LoginName>John</aut:LoginName>
         <aut:Password>Johnpass</aut:Password>
         <aut:Culture>en_US</aut:Culture>
         <aut:Version>8</aut:Version>
      </aut:AuthenticationHeader>
   </soapenv:Header>
   <soapenv:Body>
      <hot:GetHotelDetailsV3>
         <hot:HotelIds>
            <hot:HotelID id="3813"/>
            <hot:HotelID id="1322208"/>
         </hot:HotelIds>
      </hot:GetHotelDetailsV3>
   </soapenv:Body>
</soapenv:Envelope>
<hot:HotelIds>
        <hot:HotelID id="3813"/>
        <hot:HotelID id="1322208"/>
     </hot:HotelIds>
$b = new stdClass;
$b->HotelID = '3813';
$b->HotelID = '1322208';