gpt4 book ai didi

php - Eurotours XML 接口(interface) SOAP HTTP 未经授权

转载 作者:可可西里 更新时间:2023-11-01 13:24:17 25 4
gpt4 key购买 nike

我试着从 Eurotours XML interface 做一个例子但是所有 SOAP 函数调用都给我

PHP Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized

这是我的代码:

$soapClient = new SoapClient("https://ws.eurotours.at/accommodation/development/AccommodationService?wsdl",array('trace' => true));
$functions = $soapClient -> __getFunctions();
$soapClient -> getLanguages(array("Client"=>"TESTXMLB2B"));

这只是测试文档的客户端,我不知道我是否有错误。

这是我的完整异常,我想知道是否真的是一个授权问题,或者只是因为我在打电话时犯了一个错误:

object(SoapFault)#2 (9) {
["message":protected]=>
string(12) "Unauthorized"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(34) "/home/laurentiu/teste/testswap.php"
["line":protected]=>
int(5)
["trace":"Exception":private]=>
array(3) {
[0]=>
array(4) {
["function"]=>
string(11) "__doRequest"
["class"]=>
string(10) "SoapClient"
["type"]=>
string(2) "->"
["args"]=>
array(5) {
[0]=>
string(224) "<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.eurotours.at/"><SOAP-ENV:Body><ns1:getLanguages/></SOAP-ENV:Body></SOAP-ENV:Envelope>
"
[1]=>
string(74) "https://ws.eurotours.at:443/accommodation/development/AccommodationService"
[2]=>
string(0) ""
[3]=>
int(1)
[4]=>
int(0)
}
}
[1]=>
array(6) {
["file"]=>
string(34) "/home/laurentiu/teste/testswap.php"
["line"]=>
int(5)
["function"]=>
string(6) "__call"
["class"]=>
string(10) "SoapClient"
["type"]=>
string(2) "->"
["args"]=>
array(2) {
[0]=>
string(12) "getLanguages"
[1]=>
array(1) {
[0]=>
array(1) {
["Client"]=>
string(10) "TESTXMLB2C"
}
}
}
}
[2]=>
array(6) {
["file"]=>
string(34) "/home/laurentiu/teste/testswap.php"
["line"]=>
int(5)
["function"]=>
string(12) "getLanguages"
["class"]=>
string(10) "SoapClient"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
array(1) {
["Client"]=>
string(10) "TESTXMLB2C"
}
}
}
}
["previous":"Exception":private]=>
NULL
["faultstring"]=>
string(12) "Unauthorized"
["faultcode"]=>
string(4) "HTTP"
};

最佳答案

我现在不知道他们的服务,但正如评论“HTTP Unauthorized” 表示 HTTP 状态代码 401,这意味着您需要在 HTTP 级别提供用户名和密码。

联系该服务供应商并获取您的登录名(请参阅 http://xml.eurotours.at/overview 上的“获取您的登录名”),然后将用户名和密码用于 SoapClient .

对于 SoapClient,您可以通过选项参数传递用户名和密码:

$soapClient = new SoapClient(
"https://ws.eurotours.at/accommodation/development/AccommodationService?wsdl",
array(
'trace' => true,
'login' => 'your username',
'password' => 'your password',
)
);

这将使用默认的身份验证方法 SOAP_AUTHENTICATION_BASIC(参见 basic authentication)。 **SoapClient* 还允许第二种身份验证方法,方法是将“authentication”选项设置为 SOAP_AUTHENTICATION_DIGEST for digest authentication .如果服务器需要身份验证类型,此信息可能会有用。但是,在您的情况下,根据响应 header ($soapClient->__getLastResponseHeaders()),它是“Basic”:

HTTP/1.1 401 Unauthorized
Date: Thu, 31 Jul 2014 09:35:27 GMT
Server: Apache
X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
WWW-Authenticate: Basic realm="webservice-realm"
Content-Length: 1073
Content-Language:
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

(由我突出显示)

这也是 SoapClient 无法提供但可以通过 HTTP 检查(代理)或您自己的 HTTP 请求获得的响应主体:

GlassFish Response to the SOAP Request

Image transcription: HTTP Status 401 -

type Status report

message

descriptionThis request requires HTTP authentication ().

GlassFish Server Open Source Edition 3.1.2.2

关于php - Eurotours XML 接口(interface) SOAP HTTP 未经授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25052086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com