0

使用 php 我想创建请求,xml 应该看起来像这样,我正在使用 web 服务测试工具,它工作正常,而我在 xml 下面发布到它,我只想知道我可以像这样创建肥皂请求吗? 在此处输入图像描述

 <?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' 的编码不匹配

4

0 回答 0