如何创建PHP SOAP请求看起来像这样?

时间:2013-09-10 08:03:22

标签: php web-services soap

用php我想创建请求,xml应该是这样的, 我正在使用Web服务测试工具,它的工作正常,而我在xml以下发布到它, 我只是想知道我可以创建这样的肥皂请求吗? enter image description here

 <?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="000032" primaryLangID="E" timeStamp="2008-12-09T09:55:16.3618750-05:00" xmlns="http://webservices.test.com/og/4.3/Core/">
      <Origin entityID="OWS" systemType="WEB" />
      <Destination entityID="TI" systemType="ORS" />
    </OGHeader>
  </soap:Header>
  <soap:Body>
    <AvailabilityRequest xmlns:a="http://webservices.test.com/og/4.3/Availability/" xmlns:hc="http://webservices.test.com/og/4.3/HotelCommon/" summaryOnly="true" xmlns="http://webservices.test.com/ows/5.1/Availability.wsdl">
      <a:AvailRequestSegment availReqType="Room" numberOfRooms="1" totalNumberOfGuests="1" totalNumberOfChildren="0">
        <a:StayDateRange>
          <hc:StartDate>2013-10-05T00:00:00.0000000-05:00</hc:StartDate>
          <hc:EndDate>2013-10-06T00:00:00.0000000-05:00</hc:EndDate>
        </a:StayDateRange>
        <a:HotelSearchCriteria>
          <a:Criterion>
            <a:HotelRef chainCode="AXA" hotelCode="AXAMUM" />
          </a:Criterion>
        </a:HotelSearchCriteria>
      </a:AvailRequestSegment>
    </AvailabilityRequest>
  </soap:Body>
</soap:Envelope>

编辑: PHP代码已添加。

error_reporting(E_ALL);


require_once('../lib/nusoap.php');
$client = new nusoap_client("http://###.###.###.##:8080/ws_ws_51/Availability.asmx?wsdl");
$err = $client->getError();
echo "<pre>";

if ($err) {
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
    exit();
}
// Call the SOAP method
$result = $client->call('Availability', array('name' => 'Scott'));
// Check for a fault
if ($client->fault) {
    echo '<h2>Fault</h2><pre>';
    print_r($result);
    echo '</pre>';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
        // Display the result
        echo '<h2>Result</h2><pre>';
        print_r($result);
    echo '</pre>';
    }
}

此代码o / p:

错误

来自HTTP Content-Type'UTF-8'的字符集与XML声明'iso-8859-1'中的编码不匹配

0 个答案:

没有答案