I'm trying to call a SOAP API request using PHP? - php

I am trying to call a soap api
I have the following request xml and wsdl addresses.
test WSDL URL
http://demo-activityws.touricoholidays.com/ActivityBookFlow.svc?wsdl
sample request xml
how can i get response from API ???
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aut="http://schemas.tourico.com/webservices/authentication" xmlns:act="http://tourico.com/webservices/activity" xmlns:act1="http://schemas.tourico.com/webservices/activity">
<soapenv:Header>
<aut:AuthenticationHeader>
<aut:LoginName>John</aut:LoginName>
<aut:Password>Johnpass</aut:Password>
<aut:Culture>en_US</aut:Culture>
<aut:Version>8</aut:Version>
</aut:AuthenticationHeader>
</soapenv:Header>
<soapenv:Body>
<act:SearchActivityByAirPortCode>
<act:SearchRequest destination="MCO" cityName="Orlando">
<act1:FromDate>2017-03-23</act1:FromDate>
<act1:ToDate>2017-03-25</act1:ToDate>
<act1:Filters>
<act1:MinAdults>
<act1:Value>0</act1:Value>
</act1:MinAdults>
<act1:MinChildren>
<act1:Value>0</act1:Value>
</act1:MinChildren>
<act1:MinUnits>
<act1:Value>0</act1:Value>
</act1:MinUnits>
<act1:CategoryName>
<act1:Value>Theme Parks</act1:Value>
</act1:CategoryName>
<act1:CategoryId>
<act1:Value>592</act1:Value>
</act1:CategoryId>
<act1:ActivityName>
<act1:Value>SeaWorld Orlando</act1:Value>
</act1:ActivityName>
</act1:Filters>
</act:SearchRequest>
</act:SearchActivityByAirPortCode>
</soapenv:Body>
</soapenv:Envelope>

Related

How to figure out Arguments for __soapCall()

Im trying to access a specific method from a webservice. i can access the webservice, i know because __getFunctions() is working. What i need to know is which arguments i have to pass, to call getItem(). In SoapUI a request looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://webservice.mks.com/2009/Integrity" xmlns:sch="http://webservice.mks.com/2009/Integrity/schema">
<soapenv:Header/>
<soapenv:Body>
<int:getItem>
<!--Optional:-->
<arg0 transactionId="?" sch:ItemId="8720303">
<sch:Username>--</sch:Username>
<sch:Password>--</sch:Password>
<sch:InputField>State</sch:InputField>
</arg0>
</int:getItem>
</soapenv:Body>
</soapenv:Envelope>
I think i have to pass a ItemId, Username, Password and InputField. But i have no Idea in which way i have to. I am using php and i called the method like this:
$result = $client->__soapCall('getItem',array('arg0'=>array('transactionId'=>'?','ItemId'=>'8720303','InputField'=>'State', 'Username'=>'--','Password'=>'--')));

How to receive soap request from codeigniter controller?

How I can receive a soap request in my controller? For your convenient I am sharing the sample soap format. From this I need to get "message" field. Can you please suggest me any solution.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:NotifySOAPHeader xmlns:ns1="http://www.huawei.com.cn/schema/common/v2_1">
<ns1:timeStamp>111029084631570</ns1:timeStamp> <ns1:traceUniqueID>100001200101110623021721000011</ns1:traceUniqueID>
</ns1:NotifySOAPHeader>
</soapenv:Header>
<soapenv:Body>
<ns2:notifySmsReception xmlns:ns2="http://www.csapi.org/schema/parlayx/sms/notification/v2_2/local">
<ns2:correlator>00001</ns2:correlator>
<ns2:message>
<message>Hello world</message>
<dateTime>2010-08-09T00:00:00.000+08:00</dateTime>
</ns2:message>
</ns2:notifySmsReception>
</soapenv:Body>
</soapenv:Envelope>

How to call Soap Client PHP with urn?

Hi i have this WSDL that, when i test in soapUI, it works well.
but i am having problems to call it from php soap client.
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:uXXX">
<soapenv:Header/>
<soapenv:Body>
<urn:Pesquisar soapenv:encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/">
<active xsi:type="xsd:boolean">true</active>
</urn:Pesquisar>
</soapenv:Body>
</soapenv:Envelope>
i am trying in PHP something like this:
$client = new \SoapClient($mywsdl);
$headers[] = new \SoapHeader('urn:uXXX', 'urn');
$client->__setSoapHeaders($headers);
var_dump($client->Pesquisar(['parameters'=>['active' => true]]));
PS: This soap, doens have authentication, because i am inside a server that have access to the soap server.

Calling Soap with Header and body in php

I need to send a soap request with soap header and body.
I have the request soap xml.
I had use different curl and soap client but nothing is working.
Some one please help.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://www.v.com/schema/" xmlns:loc="http://www.c.org/local">
<soapenv:Header>
<RequestSOAPHeader xmlns="http://www.h.com/schema/1">
<s1>000201</s1>
<s2>e6434ef249df55c7a21a0b45758a39bb</s2>
<s3>35000001000001</s3>
<s4>20100731064245</s4>
</RequestSOAPHeader>
</soapenv:Header>
<soapenv:Body>
<loc:start>
<loc:reference>
<c1>http://desertcreator.com/nct</c1>
<c2>notify</c2>
<c3>1</c3>
</loc:reference>
<loc:w1>1234</loc:w1>
<loc:w2>demand</loc:w2>
</loc:start>
</soapenv:Body>
</soapenv:Envelope>
Thanks

Soap header without header name php

I'm having a problem in order to create a soap call. As one can see the header that is being supplied from a 3rd party client doesn't have a header name. I need to create a soap call by passing the username and password to the soap request which doesn't have a name in the header. I have tried several examples but no success. The call below works in soap UI but I'm having serious problems when it comes to php. Any help would be much appreciated
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://namespace.example.com/">
<soapenv:Header>
<int:password>123</int:password>
<int:login>abc</int:login>
</soapenv:Header>
<soapenv:Body>
<int:getEventTree>
<!--Optional:-->
<lang>en</lang>
</int:getEventTree>
</soapenv:Body>
</soapenv:Envelope>
Please take a look at http://php.net/manual/en/soapclient.dorequest.php
You can use code like:
$response = $soapClient->__doRequest(
$request,
$endpoint,
$soapAction,
$soapVersion,
$one_way
);
$request could be defined as a string containing xml, such as:
$request =
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/""xmlns:int="http://namespace.example.com/">
<soapenv:Header>
<int:password>123</int:password>
<int:login>abc</int:login>
</soapenv:Header>
<soapenv:Body>
<int:getEventTree>
<!--Optional:-->
<lang>en</lang>
</int:getEventTree>
</soapenv:Body>
</soapenv:Envelope>';
You can define the rest of the arguments in the __doRequest() call depending on your configuration.

Categories