Call SOAP client using NuSoap PHP with Document/literal wrapped - php

Im trying to make a SOAP call, but have to many problems.
Im using this:
$client = new nusoap_client('http://odigo.xxx.com/xxx/servlet/services/WebCallBack?wsdl');
$client -> setEndpoint('https://odigo2.xxx.com/xxx/servlet/services/WebCallBack.WebCallBackHttpSoap11Endpoint/');
$client->soap_defencoding = 'UTF-8';
error message:
$error = $client->getError();
if ($error) {
die("client construction error: {$error}\n");
}
$param = array('skillKeyWord' => 'yyy',
'phoneNumber' => '999999999',
'user' => 'XXX',
'password' => 'XXX',
);
$result = $client->call('saveCallBack', array('parameters' => $param), '', '', false, true);
The IT department of the Client tell me, the request are wrong, because: "need to use Document/literal wrapped, not encoded" and "parameters are wrong encapsulated"
The correct call they send to us, is this example:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<saveCallBack xmlns ="http://odigo.xxx.com/2009/09/21/webcallback.xsd" xmlns:ns2="http://webcallback.ws.bean.model.odigo.xxx.com/xsd" xmlns:ns3="http://administration.bean.model.odigo.xxx.com/xsd">
<webCallBack>
<ns2:date>0</ns2:date>
<ns2:phoneNumber>9999999</ns2:phoneNumber>
<ns2:skillKeyWord>yyy</ns2:skillKeyWord>
</webCallBack>
<user>
<ns3:login>XXX</ns3:login>
<ns3:password>XXX</ns3:password>
</user>
</saveCallBack>
</soap:Body>
</soap:Envelope>
I dont know how i can send this format call using nusoap, or using this XML to make a call using nusoap.
Any help its appreciated.

Try using CURL. Code is shown below:
$soap_body = '<?xml version="1.0" encoding="utf-8"?>'.
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'.
'<soap:Body>'.
'<saveCallBack xmlns ="http://odigo.xxx.com/2009/09/21/webcallback.xsd" xmlns:ns2="http://webcallback.ws.bean.model.odigo.xxx.com/xsd" xmlns:ns3="http://administration.bean.model.odigo.xxx.com/xsd">'.
'<webCallBack>'.
'<ns2:date>0</ns2:date>'.
'<ns2:phoneNumber>9999999</ns2:phoneNumber>'.
'<ns2:skillKeyWord>yyy</ns2:skillKeyWord>'.
'</webCallBack>'.
'<user>'.
'<ns3:login>XXX</ns3:login>'.
'<ns3:password>XXX</ns3:password>'.
'</user>'.
'</saveCallBack>'.
'</soap:Body>'.
'</soap:Envelope>';
$headers = array
(
'Content-Type: text/xml; charset="utf-8"',
'Content-Length: '. strlen($soap_body),
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://odigo.xxx.com/xxx/servlet/services/WebCallBack?wsdl');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soap_body);
$result = curl_exec($ch);
//do something useful with $result variable

Related

Correct XML request with Curl: getting blank XML response

I was trying to hit XML request from PHP SOAP Client according to the following provided SOAP API documentation.
WSDL Schema
Refer to the following URL.
http://[SERVER_IP]/PowerSuite/PSXMLSearch.asmx?wsdl
4 Input/Output
4.1 Search Supplier Code and Name (PSXMLSearchSupplier)
Input : PSXML_SEARCH_SUPP
Output : PSXML_SEARCH_SUPP_Response
6 Field definition
6.1 PSXML_SEARCH_SUPP - The main entry point and the authentication information.
MSGID
USERID
PASSWORD
OPTION
SUPPNO
But when i run with SOAP client it gives me a following error
Object reference not set to an instance of an object
So after long research on internet, i decided to send XML request via CURL, i have created following Schema for XML request and send it via CURL request
$soapUrl = "https://[MY_SERVER_DOMAIN]/PowerSuite/PSXMLSearch.asmx"; // asmx URL of WSDL
// xml post structure
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<PSXML_SEARCH_SUPP xmlns="https://[MY_SERVER_DOMAIN]/PowerSuite/PSXMLSearch.asmx">
<MSGID>TRAVEK_E1</MSGID>
<USERID>GCOT</USERID>
<PASSWORD>CKHOSKIS6</PASSWORD>
<OPTION>LIKE</OPTION>
<SUPPNO>RK0048</SUPPNO>
</PSXML_SEARCH_SUPP>
</soap:Body>
</soap:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"https://[MY_SERVER_DOMAIN]/PowerSuite\"",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "GCONNECT:Connect#786");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
curl_close($ch);
// converting
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
// convertingc to XML
$parser = simplexml_load_string($response2);
// user $parser to get your data out of XML response and to display it.
echo "<pre>";
print_r($parser);
echo "</pre>";
die();
But even after that i only get empty XML response as can see below
SimpleXMLElement Object
(
)
Please guide am i sending a correct XML schema, or their needs to be some thing amend into it?
I checked with RapidAPI, it shows the correct response, i have shown the request in the image below:
In FORM
https://gcdnb.pbrd.co/images/a9NdABt6rXQl.png
In XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xh="http://www.xmlhk.com/">
<soapenv:Header/>
<soapenv:Body>
<xh:PSXMLSearchSupplier>
<!--Optional:-->
<xh:PSXML_SEARCH_SUPP>
<!--Optional:-->
<xh:MSGID>TRAVEK_EBOOK001</xh:MSGID>
<!--Optional:-->
<xh:USERID>ABCUSER</xh:USERID>
<!--Optional:-->
<xh:PASSWORD>Connect#786</xh:PASSWORD>
<!--Optional:-->
<xh:OPTION>LIKE</xh:OPTION>
<!--Optional:-->
<xh:SUPPNO>ABDECS</xh:SUPPNO>
<!--Optional:-->
<xh:SUPPNAME>?</xh:SUPPNAME>
</xh:PSXML_SEARCH_SUPP>
</xh:PSXMLSearchSupplier>
</soapenv:Body>
</soapenv:Envelope>
I tried the same above with CURL request and got that working, i found that,following to be changed in my previous CURL request
, which on the raw tab in ReadyAPI
"SOAPAction: \"http://www.xmlhk.com/PSXMLSearchSupplier\"",
To work this with SOAP Client i just need to used multi dimensional array with $params['PSXML_SEARCH_SUPP'] shows below
$wsdl = "https://ps.gerrys.com.pk/PowerSuite/PSXMLSearch.asmx?WSDL";
$params['PSXML_SEARCH_SUPP'] = array(
'MSGID' => "TRAVEK_EBOOK001",
'USERID' => "GCONNECT",
'PASSWORD' => "Connect#786",
'OPTION' => 'LIKE',
'SUPPNO' => 'RK0048'
);
try {
$soap = new SoapClient($wsdl);
$data = $soap->PSXMLSearchSupplier($params);
echo "<pre>";
print_r($data);
echo "</pre>";
die();
}
catch(Exception $e) {
$e->getMessage();
var_dump($e->getMessage());
die();
}

Invoking API with SOAP using SoapClient - can't find method

I'm trying to connect to an API that uses SOAP. It is working for me with php/curl, but what I'd really like to do is use SoapClient, which looks like it would produce much cleaner code.
This is the php that works:
$xml_post_string = '<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:v300="http://V300">
<soapenv:Header/>
<soapenv:Body>
<v300:GetNote soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Request xsi:type="get:Request" xmlns:get="http://getNote.note.V300">
<Security xsi:type="req:Security" xmlns:req="http://request.base.V300">
<Password xsi:type="xsd:string">'.$soapPassword.'</Password>
<Username xsi:type="xsd:string">'.$soapUser.'</Username>
</Security>
<NoteID xsi:type="xsd:string">'.$soapNoteID.'</NoteID>
</Request>
</v300:GetNote>
</soapenv:Body>
</soapenv:Envelope>';
$headers = array(
"Content-type: application/soap+xml;charset=utf-8",
"Accept: text/xml",
"SOAPAction: https://webservices.aus.vin65.com/V300/NoteService.cfc?wsdl",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
$ch = curl_init();
echo("set curl\n");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE,false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
echo("about to execute\n");
// converting
$response = curl_exec($ch);
echo('Got '.strlen($response)." characters in response\n");
curl_close($ch);
echo("Response:\n".$response."\n");
And this is my attempt at a SoapClient version, informed by this helpful StackExchange user over here: How to make a PHP SOAP call using the SoapClient class
class Security{
function Security($Username,$Password){
$this->Username = $Username;
$this->Password=$Password;
}
}
class Request{
function Request($Security,$NoteID){
$this->Security = $Security;
$this->NoteID = $NoteID;
}
}
$client = new SoapClient($soapUrl);
$security = new Security($soapUser,$soapPassword);
$securityArray = array("Username"=>$soapUser,"Password"=>$soapPassword);
//$request = new Request($security,$soapNoteID);//gave error message "expects parameter 2 to be array"
//$request = array("Security"=>$security,"NoteID"=>$soapNoteID);//gave error message "No such operation 'GetNote'"
$request = array("Security"=>$securityArray,"NoteID"=>$soapNoteID);//gave error message "No such operation 'GetNote'"
echo("Showing Request:\n");
var_dump($request);
$response=null;
try{
$response = $client->__soapCall("GetNote",$request);
}catch(Exception $ex){
echo("Caught Exception: ".$ex->getMessage()."\n");
echo("Last Request was: ".$client->__getLastRequest()."\n");
echo("Last Request Headers: ".$client->__getLastRequestHeaders()."\n");
echo("Last Response was: ".$client->__getLastResponse()."\n");
echo("Last Response Headers: ".$client->__getLastResponseHeaders()."\n");
}
if($response){
var_dump($response);
}
As you can see, I've tried a couple of different ways to feed it the user/password/NoteID information, noting down which error message it gives me each time. Currently it's claiming that there's 'no such operation GetNote' - definintely not right, but I don't know what the underlying problem is.
Thanks in advance for any pointers.
When i do $client->__getFunctions(), the method GetNote method shows up and works
<?php
$client = new SoapClient('https://webservices.aus.vin65.com/V300/NoteService.cfc?wsdl');
/**
print_r($client->__getFunctions());
Array
(
[0] => Response SearchNotes(Request $Request)
[1] => Response AddUpdateNote(Request $Request)
[2] => Response GetNote(Request $Request)
)
*/
$result = $client->GetNote([
'Security' => [
'Password' => 'XXX',
'Username' => 'XXX'
],
'NoteID' => 'XXX'
]);
print_r($result);

Configuring soap api xml

I want to configure an api of soap with php, following the xml is used for the api, but its not responding, please help me to recover this problem
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fram="http://framework.zend.com">
<soapenv:Header/>
<soapenv:Body>
<fram:getCountries>
<securityInfo>
<userName>username</userName>
<password>password</password>
<agentCode>code</agentCode>
<lang>en</lang>
</securityInfo>
</fram:getCountries>
</soapenv:Body>
</soapenv:Envelope>
The below showing the php code I used to call xml. But I didnt get any response to my php code, but the xml is correct, I have asked to the provider they told me the xml is correct but my php code is not correct. I dont what I do to solve this problem :(
<?php
$soapUrl = "http://testapi.roombookpro.com/en/soap/index?wsdl"; // asmx URL of WSDL
$soapUser = "username"; // username
$soapPassword = "password"; // password
// xml post structure
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fram="http://framework.zend.com">
<soapenv:Header/>
<soapenv:Body>
<fram:getCountries>
<securityInfo>
<!-- You may enter the following 4 items in any order -->
<userName>username</userName>
<password>password</password>
<agentCode>agentcode</agentCode>
<lang>en</lang>
</securityInfo>
</fram:getCountries>
</soapenv:Body>
</soapenv:Envelope>'; // data from the form, e.g. some ID number
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache"
"SOAPAction: http://testapi.roombookpro.com/en/soap/index#getCountries",
"Content-length: ".strlen($xml_post_string),
); //SOAPAction: your op URL
$url = $soapUrl;
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
curl_close($ch);
// converting
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
// convertingc to XML
$parser = simplexml_load_string($response2);
var_dump($parser);
echo $parser;
// user $parser to get your data out of XML response and to display it.
?>
In your code,your request is pointing to wsdl link below,
http://testapi.roombookpro.com/en/soap/index?wsdl
and thats why you are not getting soap response rather you getting the definitions.
you should use the following soap url to get the soap response,
http://testapi.roombookpro.com/en/soap/index
EDIT:
and to get the XML response (as string):
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
to get as SimpleXMLElement Object :
$xml = simplexml_load_string($response);
foreach ($xml->xpath('//ns2:Soap_Model_SOAP_Location_Country') as $item)
{
print_r($item);
//to access individual elements
// echo $item->id ;
// echo $item ->code;
// echo $item->name;
// echo "\n";
}
which gives array of XML objects:
SimpleXMLElement Object
(
[id] => 252
[code] => ZW
[name] => Zimbabwe
)

Unable to call .NET ASMX from PHP

I have the following - currently hosted - SOAP service that was created in .NET that I'm trying to call from PHP:
POST /ExampleService/ExampleService.asmx HTTP/1.1
Host: dev.examplesite.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://localhost:51713/ExampleService.asmx/RegisterPerson"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<UserCredentials xmlns="http://localhost:51713/ExampleService.asmx">
<UserID>string</UserID>
<AuthKey>string</AuthKey>
</UserCredentials>
</soap:Header>
<soap:Body>
<RegisterPerson xmlns="http://localhost:51713/ExampleService.asmx">
<requestItem>
<RequestResult>string</RequestResult>
<Firstname>string</Firstname>
<Lastname>string</Lastname>
</requestItem>
</RegisterPerson>
</soap:Body>
</soap:Envelope>
and I'm trying to call it using the following PHP code:
<?php
$ns = "http://dev.examplesite.com/ExampleService/ExampleService.asmx";
$wsdl_url = "http://dev.examplesite.com/ExampleService/ExampleService.asmx?wsdl";
$client = new SOAPClient($wsdl_url);
$header = new SoapHeader(
$ns,
'UserCredentials',
array(
'UserID' => "1",
'AuthKey' => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
)
);
$client->__setSoapHeaders($header);
$params = array(
'Firstname' => 'John',
'Lastname' => 'Doe'
);
$client->__soapCall('RegisterPerson',$params);
?>
This however results in the following error:
Fatal error: Uncaught SoapFault exception: [soap:MustUnderstand] Missing required header 'UserCredentials'. in /home/devops1/public_html/asmxtest/register.php:43 Stack trace: #0 /home/devops1/public_html/asmxtest/register.php(43): SoapClient->__soapCall('RegisterPerso...', Array) #1 {main} thrown in /home/devops1/public_html/asmxtest/register.php on line 43
I've tried a few other methods but all met with no success. One thing that concerns me is the fact that we are reaching across over the wire to this web service which is already hosted on a testing server, and the localhost:51713 is ringing alarm bells. Should this be changed to a fully qualified domain name such as dev.examplesite.com?
For as easy as the SoapClient is supposed to be, I've never had success w/ it. In just about every case we have rolled our own process, which always seemed to work better.
Example:
// set our headers to pass in cURL
$headers = array(
'Content-type: text/xml;charset="utf-8"',
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache',
'SOAPAction: ' . $action,
'Content-length: '.strlen($soap)
);
// initiate cURL
try {
$_ch = curl_init();
curl_setopt($_ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($_ch, CURLOPT_URL, WEB_SERVICE_URL);
curl_setopt($_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($_ch, USERPWD, USER_ID . ":" . PASSWORD);
curl_setopt($_ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($_ch, CURLOPT_TIMEOUT, 10);
curl_setopt($_ch, CURLOPT_POST, true);
curl_setopt($_ch, CURLOPT_POSTFIELDS, $soap);
curl_setopt($_ch, CURLOPT_HTTPHEADER, $headers);
// process the request and get the result back
$response = curl_exec($_ch);
curl_close($_ch);
return $response;
} catch (Exception $e) {
capDebug(__FILE__, __LINE__, "Error calling the web service: " . $e->getMessage(), "/tmp/errors.log");
return false;
}
We've had to massage the data afterwards, but it always works!

PHP & XML - How to generate a soap request in PHP from this XML?

I am completly new to SOAP operations.
I have been provided with an XML document (SOAP) to get some collection points for a shipping method.
From the manual located here:
http://privpakservices.schenker.nu/package/package_1.3/packageservices.asmx?op=SearchCollectionPoint
I can see that I need to use the following SOAP request:
POST /package/package_1.3/packageservices.asmx HTTP/1.1
Host: privpakservices.schenker.nu
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://privpakservices.schenker.nu/SearchCollectionPoint"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SearchCollectionPoint xmlns="http://privpakservices.schenker.nu/">
<customerID>long</customerID>
<key>string</key>
<serviceID>string</serviceID>
<paramID>int</paramID>
<address>string</address>
<postcode>string</postcode>
<city>string</city>
<maxhits>int</maxhits>
</SearchCollectionPoint>
</soap:Body>
</soap:Envelope>
The thing is that i don't know how to send this as a request using PHP, and how to get the response.
Any help to pinpoint me in the right direction, is much appreciated.
UPDATE
I can read the response data with var_dump. However, I am not able to read individual element data.
I need to read data as below
foreach($parser as $row) {
echo $row->customerID;
echo $row->key;
echo $row->serviceID;
}
If anyone should be interested, i have provided the correct answer:
$soapUrl = "http://privpakservices.schenker.nu/package/package_1.3/packageservices.asmx?op=SearchCollectionPoint";
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><SearchCollectionPoint xmlns="http://privpakservices.schenker.nu/"><customerID>XXX</customerID><key>XXXXXX-XXXXXX</key><serviceID></serviceID><paramID>0</paramID><address>RiksvÅ gen 5</address><postcode>59018</postcode><city>Mantorp</city><maxhits>10</maxhits></SearchCollectionPoint></soap12:Body></soap12:Envelope>';
$headers = array(
"POST /package/package_1.3/packageservices.asmx HTTP/1.1",
"Host: privpakservices.schenker.nu",
"Content-Type: application/soap+xml; charset=utf-8",
"Content-Length: ".strlen($xml_post_string)
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
$parser = simplexml_load_string($response2);
following example might help you.
SOAP XML schema
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.dataaccess.com/webservicesserver/">
<x:Header/>
<x:Body>
<web:NumberToDollars>
<web:dNum>10</web:dNum>
</web:NumberToDollars>
</x:Body>
</x:Envelope>
PHP code
$wsdl = 'http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL';
try{
$clinet=new SoapClient($wsdl);
$ver =array("dNum"=>"2002");
$quates=$clinet->NumberToDollars($ver);
var_dump($quates);
}
catch(SoapFault $e)
{
echo $e->getMessage();
}

Categories