W
W
WebDev2015-10-05 17:41:19
PHP
WebDev, 2015-10-05 17:41:19

Authorization via soap?

There is a soar service, in it a wsdl document, I access this document through soapUI and see a list of its methods, when I select the method I need, I get xml:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:out="http://realobs.com/service/outgoing2">
   <soapenv:Header/>
   <soapenv:Body>
      <out:hotelSearchStep1Request outOperatorIncID="?" dateFrom="?" nightsDuration="?" availableOnly="?">
         <out:persons adults="?">
            <out:childAges/>
         </out:persons>
         <out:locationIds>
            <!--Zero or more repetitions:-->
            <out:long>?</out:long>
         </out:locationIds>
         <!--Optional:-->
         <out:hotelIds>
            <!--Zero or more repetitions:-->
            <out:long>?</out:long>
         </out:hotelIds>
         <!--Optional:-->
         <out:hotelServices>
            <!--Zero or more repetitions:-->
            <out:long>?</out:long>
         </out:hotelServices>
      </out:hotelSearchStep1Request>
   </soapenv:Body>
</soapenv:Envelope>

In addition, in the panel on the left I enter data for authorization.
How do I emulate this in a php script?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Smirnov, 2015-10-06
@MaxiStyle

What exactly to emulate? PHP working with SOAP? So there are special functions and classes: fi2.php.net/manual/en/class.soapclient.php

C
CerberIsety, 2016-11-22
@CerberIsety

In general, SoapUI has an "http log" button at the bottom, which shows all outgoing and incoming requests. And in the service you specified, WS-authorization is used. It is implemented in the xml head like this:

$login="login";
$password="pass";
$xml='<soapenv:Envelope xmlns:out="http://realobs.com/service/outgoing2" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken><wsse:Username>'.$login.'</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'.$password.'</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header>
   <soapenv:Body>
      <out:hotelSearchStep1Request outOperatorIncID="?" dateFrom="?" nightsDuration="?" availableOnly="?">
         <out:persons adults="?">
            <out:childAges/>
         </out:persons>
         <out:locationIds>
            <!--Zero or more repetitions:-->
            <out:long>111756</out:long>
         </out:locationIds>
         <!--Optional:-->
         <out:hotelIds>
            <!--Zero or more repetitions:-->
            <out:long>?</out:long>
         </out:hotelIds>
         <!--Optional:-->
         <out:hotelServices>
            <!--Zero or more repetitions:-->
            <out:long>?</out:long>
         </out:hotelServices>
      </out:hotelSearchStep1Request>
   </soapenv:Body>
</soapenv:Envelope>';
$c=new SoapClient("http://test.bestoftravel.cz:8080/booking/public/ws/searchHotel.wsdl");
$resp=$c->__doRequest($xml,"http://test.bestoftravel.cz:8080/booking/public/ws/searchHotel","hotelSearchStep1","1.1");
echo $resp;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question