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.
Related
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>
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>
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
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.
I need a php client base on nusoap lib. to get a asmx service response with haeder auth enabled:
This is the Request (using soapUI):
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:res="namespaceurl">
<soap:Header>
<res:AuthHeader>
<!--Optional:-->
<res:UserName>myuser</res:UserName>
<!--Optional:-->
<res:Password>mypass</res:Password>
</res:AuthHeader>
</soap:Header>
<soap:Body>
<res:LoanStatus>
<res:iAccountNbr>?</res:iAccountNbr>
<res:iResortNbr>?</res:iResortNbr>
<!--Optional:-->
<res:strXRef></res:strXRef>
</res:LoanStatus>
</soap:Body>
</soap:Envelope>
Here es the Response (soapUI):<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:res="namespaceurl">
<soap:Header>
<res:AuthHeader>
<!--Optional:-->
<res:UserName>myuser</res:UserName>
<!--Optional:-->
<res:Password>mypass</res:Password>
</res:AuthHeader>
</soap:Header>
<soap:Body>
<res:LoanStatus>
<res:iAccountNbr>?</res:iAccountNbr>
<res:iResortNbr>?</res:iResortNbr>
<!--Optional:-->
<res:strXRef></res:strXRef>
</res:LoanStatus>
</soap:Body>
</soap:Envelope>
If you really need to use NuSoap (I recommend using the PHP-native Soap extension!), have a look at the client samples in the Introduction to NuSoap:
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/phphack/helloworld.php');
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));
// Display the result
print_r($result);
?>
From there it should be straightforward.
You can use nusoap to send raw XML if you are having trouble making a SOAP call to a predefined .NET Web Service.
Check this post for more info.
However it is better to try parsing the WSDL file. Try using wsdl2php. It is really nice for parsing WSDL files. It will replicate the data type structure from the WSDL file to a php class library.
You can find a description on how to use it here.