如何在php中创建soap xml请求 [英] how to create soap xml request in php

查看:27
本文介绍了如何在php中创建soap xml请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SubmitRequest xmlns="http://tripauthority.com/hotel">
      <siteID>string</siteID>
      <username>string</username>
      <password>string</password>
      <xmlFormattedString>string</xmlFormattedString>
    </SubmitRequest>
  </soap:Body>
</soap:Envelope>

我们必须调用上面的soap xml.我有siteID,用户名,密码.字符串在下面

we have to call above soap xml. i have siteID, username, password. where string is below

<ArnRequest><Availability DisplayCurrency="USD" SearchTimeout="15"><HotelAvailability InDate="2007-04-26" OutDate="2007-04-29" Rooms="1" Adults="2" Children="0"><Hotel HotelID="8800"/></HotelAvailability></Availability></ArnRequest>

我不知道肥皂要求.请对此提供帮助,以在 PHP 中获得上述soap xml 的响应.上面的xml是ARN(Alliance reserved)提前致谢.

i have no idea on soap request. Please help with this to get response on above soap xml in PHP. The above xml is of ARN(Alliance reservations) thanks in advance.

推荐答案

我已经解决了我的问题,如果将来任何机构有任何问题,他们这段代码对他有用,请检查-

I have solve my question if any body in future have any problem they this code works for him, please check-

<?php
error_reporting(E_ALL);

define('API_SITEID',    $your_siteid);
define('API_USERNAME',  $your_uname);
define('API_PASSWORD',  $your_pass);
define('API_WSDL',      'http://tripauthority.com/hotel.asmx?WSDL');
ini_set("soap.wsdl_cache_enabled", "0");

$xmlReq = '<ArnRequest>
<Availability DisplayCurrency="USD" SearchTimeout="15">
    <HotelAvailability InDate="2014-09-26" OutDate="2014-09-27" Rooms="1" Adults="1" Children="0">
    <Hotel HotelID="8800"/>
    </HotelAvailability>
</Availability>
</ArnRequest>';
echo '<form action="" method="post">
    <strong>XML Request:</strong>
    <p>
    <textarea style="width:100%;height:400px;" id="xmlReq" name="xmlReq">'.$xmlReq.'</textarea>
    </p>
    <input type="submit" name="submit" id="submit" value="Test Request">
    <input type="hidden" name="avail" id="avail" value="y">
</form>';

if($_POST['avail'] == "y") {
    $xmlRes = doSoapRequest((($_POST['xmlReq']) ? $_POST['xmlReq'] : $xmlReq));
    echo '<strong>XML Response:</strong>
    <p>
    <textarea style="width:100%;height:400px;" id="xmlRes" name="xmlRes">'.$xmlRes.'</textarea>
    </p>';
}

function doSoapRequest($xmlReq) {
        try {
    $client = new SoapClient(API_WSDL);
    return $client->SubmitRequestRpc(API_SITEID, API_USERNAME, API_PASSWORD, $xmlReq);
    } catch(SoapFault $exception) {
    return "Fault Code: {$exception->getMessage()}";
    }
}

?>

谢谢

这篇关于如何在php中创建soap xml请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆