【问题标题】:soapenv:Server.userExceptionorg.xml.sax.SAXParseException: Content is not allowed in prolog for Hotelbed WSDL apisoapenv:Server.userExceptionorg.xml.sax.SAXParseException:Hotelbed WSDL api 的序言中不允许有内容
【发布时间】:2013-02-02 06:18:57
【问题描述】:

当我在代码下运行时收到响应 500 内部服务器错误,我认为代码是完美的,所以有人可以帮我解决这个问题吗?

<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= '<CountryListRQ echoToken="DummyEchoToken" xmlns="http://www.hotelbeds.com/schemas/2005/06/messages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.hotelbeds.com/schemas/2005/06/messages CountryListRQ.xsd">';
$xml .= '<Language>ENG</Language>';
$xml .= '<Credentials>';
$xml .= '<User>username</User>';
$xml .= '<Password>password</Password>';
$xml .= '</Credentials>';
$xml .= '</CountryListRQ>';

$url = 'http://212.170.239.71/appservices/ws/FrontendService?wsdl';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml; charset=utf-8; action="getCountryList"'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('xml' => $xml));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result = @curl_exec($ch);
echo "<pre>";
print_r($result);
exit;
if($result === false) {
    echo "Error performing request";
} else {
    $xml_doc = simplexml_load_string($result);
    echo 'status is ', $xml_doc->status, '<br/>';
    if ($xml_doc->status == 'SUCCESS') {
        print_r($result);
    } else {
        echo 'Error is ', $xml_doc->errormessage, '<br/>';
    }
}?>

我得到了这样的回应,

HTTP/1.1 100 Continue

HTTP/1.1 500 Internal Server Error
Date: Sat, 02 Feb 2013 06:02:12 GMT
Server: Resin/2.1.17
Content-Type: text/xml; charset=utf-8
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked

soapenv:Server.userExceptionorg.xml.sax.SAXParseException: Content is not allowed in prolog.we3mpf01

谁能帮帮我?我如何使用这个 hotelbed api 获取国家/地区列表?

【问题讨论】:

    标签: php soap curl wsdl soap-client


    【解决方案1】:

    使用下面的http服务网址:

    http://212.170.239.71/appservices/http/AcceptanceTest
    

    我在hotelbeds服务器关闭的时候发生了这个错误。

    【讨论】:

      【解决方案2】:

      错误消息告诉您缺少 SOAP 包装器元素,即 、 等 - 请参阅基本用法示例:

      http://www.soapuser.com/basics3.html

      但是,我建议不要使用 curl(一种低级 HTTP 工具)与服务器交互,而是查看 SOAP 包:

      http://php.net/manual/en/book.soap.php

      这将为您完成所有包装工作,并为您提供一个很好的 OO 层。

      如果您出于某种原因有意学习 SOAP 的较低级别的详细信息,那么至少您的示例中的 XML 需要位于 和 中,而不仅仅是在其上拥有。

      【讨论】:

        猜你喜欢
        • 2023-04-10
        • 2014-07-23
        • 2020-07-03
        • 2016-10-11
        • 2023-03-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多