XML Eurotours SOAP HTTP interface unauthorized

I'm trying to make an example from the Eurotours XML interface , but all SOAP function calls give me

PHP Fatal Error: SoapFault Exception: [HTTP] Unauthorized

Here is my code:

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

this is only a client from the documentation test, I donโ€™t know if I have something wrong.

Here is my complete exception, and I want to know if this is really an authorized problem, or just because I make a mistake when making a call:

 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" }; 
+6
source share
1 answer

I am not their service now, but, as HTTP Unauthorized commented, it signals an HTTP 401 status code, which means that you need to specify a username and password at the HTTP level.

Contact this service provider and get your username (see "Get your username" at http://xml.eurotours.at/overview ), then use the username and password with SoapClient .

Using SoapClient you pass the username and password using the options parameter:

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

This will use the default authentication method SOAP_AUTHENTICATION_BASIC (see basic authentication ). ** SoapClient * also allows you to use the second authentication method by setting the < authentication SOAP_AUTHENTICATION_DIGEST for authentication digest . This information may be useful if the server requires an authentication type. However, in your case, according to the response headers ( $soapClient->__getLastResponseHeaders() ), this is " Basic ":

HTTP / 1.1 401 Unauthorized use Date: Thu, Jul 31, 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 Authentication: Base Area = "webservice-realm"
Content Length: 1073
Content-Language:
Keep-Alive: timeout = 5, max = 100
Connection: Keep-Alive
Content-Type: text / html; charset = utf-8

(highlight me)

Here is also the body of the response, which SoapClient cannot provide, but which can be obtained through HTTP (proxy) checking or simply by executing an HTTP request:

GlassFish Response to the SOAP Request

Image Transcription: HTTP Status 401 -

enter status report

message

descriptionThis request requires HTTP () authentication.

GlassFish Server Open Source Edition 3.1.2.2

+4
source

Source: https://habr.com/ru/post/973144/


All Articles