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
)
Related
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();
}
I'm at a slight loss, havent touched a soap script in forever and looking around stackoverflow and google just confuses the matter more. PHP.net examples seem outdated as well.
The SOAP Request is supposed to POST to a non-WSDL url.
https://some.soapurl.com/provided
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cam="http://kamp.gw.com/kamp">
<soapenv:Header/>
<soapenv:Body>
<cam:setRolesUpdatedRequest>
<cam:orgCode>username</cam:orgCode>
<cam:password>password</cam:password>
<cam:emails>
<cam:email>abc#dom.com</cam:email>
<cam:email>def#dom.com</cam:email>
<cam:email>ghi#dom.com</cam:email>
</cam:emails>
<cam:updateAllUsers>false</cam:updateAllUsers>
</cam:setRolesUpdatedRequest>
</soapenv:Body>
</soapenv:Envelope>
Just running this snippet returns a 200 OK header, which is good.
try {
$client = new SoapClient("https://abc.kamp.group.com/axis/services/KampService/setRolesUpdated");
}
catch(Exception $e)
{
$e->getMessage();
}
The Response i'm looking to get is supposed to look like
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:returnStatus xmlns:ns1="http://kamp.gw.com/kamp">
<ns1:type>S</ns1:type>
<ns1:desc>Successful</ns1:desc>
</ns1:returnStatus>
</soapenv:Body>
</soapenv:Envelope>
EDIT:
I attempted a curl version to post the xml string directly.
$post_string = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cam="http://kamp.gw.com/kamp">
<soapenv:Header/>
<soapenv:Body>
<cam:setRolesUpdatedRequest>
<cam:orgCode>username</cam:orgCode>
<cam:password>password</cam:password>
<cam:emails>
<cam:email>abc#dom.com</cam:email>
<cam:email>def#dom.com</cam:email>
<cam:email>ghi#dom.com</cam:email>
</cam:emails>
<cam:updateAllUsers>false</cam:updateAllUsers>
</cam:setRolesUpdatedRequest>
</soapenv:Body>
</soapenv:Envelope>';
$user = "username";
$password = "password";
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"run\"",
"Content-length: ".strlen($xml),
);
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "https://abc.kamp.group.com/axis/services/KampService/setRolesUpdated" );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 100000);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 100000);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $headers); //array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($post_string) )
curl_setopt($soap_do, CURLOPT_USERPWD, $user . ":" . $password);
$result = curl_exec($soap_do);
$err = curl_error($soap_do);
var_dump($result);
echo "<br /><br />";
var_dump($err);
But unfortunately the result is
bool(false)
string(74) "Failed connect to abc.kamp.group.com:443; Connection timed out"
And i'm not certain if that's my fault or the web service's fault. Even though i get connection timed out, the header returned is still 200 Ok.
First check that the SOAP service url and access credentials are working. Use SoapUI or a similar tool to make a request independent of your PHP SoapClient code.
Also check if there are any IP address restrictions in place when making calls and, if so, create / ask for an exception for the IP address you are making requests from.
If everything checks, use php.net SoapClient examples to make simple calls and build your script logic.
<?php
$client = new SoapClient('http://soap.amazon.com/schemas3/AmazonWebServices.wsdl');
var_dump($client->__getFunctions());
?>
Forgot i was behind a proxy, once i pointed curl to the proxy server everything worked out just fine.
I am calling this soap API with curl and not able read response value properly so can you please guide me what I am doing wrong.
Here is my code:
$wsdl = "http://xxxx/xxxx/xxxx";
$body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:par="http://xxxx.com">
<soapenv:Header/>
<soapenv:Body>
<par:cancelReservationReq>
<par:garageID>47</par:garageID>
<par:orderNumber>orderNumber168</par:orderNumber>
<!--Optional:-->
<par:barCode>barCode168</par:barCode>
<!--Optional:-->
<par:orderTime>2015-11-19T00:30:57.905</par:orderTime>
</par:cancelReservationReq>
</soapenv:Body>
</soapenv:Envelope>';
// initializing cURL with the IPG API URL:
$ch = curl_init($wsdl);
// setting the request type to POST:
curl_setopt($ch, CURLOPT_POST, 1);
// setting the content type:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
// setting the authorization method to BASIC:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// filling the request body with your SOAP message:
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
// telling cURL to verify the server certificate:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// telling cURL to return the HTTP response body as operation result
// value when calling curl_exec:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// calling cURL and saving the SOAP response message in a variable which
// contains a string like "<SOAP-ENV:Envelope ...>...</SOAP-ENV:Envelope>":
$result = curl_exec($ch);
// loads the XML
$xml = simplexml_load_string($result);
$soapenv = $xml->children("http://schemas.xmlsoap.org/soap/envelope/");
$tns = $soapenv->Body->children("http://xxxx.com");
echo "success ".$success = $tns->cancelReservationResp->success;
echo "message ".$message = $tns->cancelReservationResp->message;
echo "garageID ".$garageID = $tns->cancelReservationResp->reservations->garageID;
API response data:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<tns:cancelReservationResp xmlns:tns="http://xxxx.com">
<tns:success>true</tns:success>
<tns:message/>
<tns:reservations>
<tns:garageID>47</tns:garageID>
<tns:barCode>barCode168</tns:barCode>
<tns:licensePlate>licensePlate168</tns:licensePlate>
<tns:orderNumber/>
<tns:used>false</tns:used>
<tns:cancelled>true</tns:cancelled>
<tns:startTime>2015-11-20 22:53:45.547</tns:startTime>
<tns:endTime>2015-11-21 22:53:45.547</tns:endTime>
<tns:cancelledTime>2015-11-19 00:51:58.717</tns:cancelledTime>
<tns:checkInTime/>
<tns:checkOutTime/>
<tns:grossPrice>152.6000</tns:grossPrice>
<tns:commFee>162.6000</tns:commFee>
<tns:customerName>customerName168</tns:customerName>
<tns:customerEmail>customerEmail168</tns:customerEmail>
<tns:customerPhone>customerPhone168</tns:customerPhone>
<tns:vehicleMake>vehicleMake168</tns:vehicleMake>
<tns:vehicleModel>vehicleModel68</tns:vehicleModel>
<tns:vehicleColor>vehicleColor168</tns:vehicleColor>
<tns:reentryAllowed>true</tns:reentryAllowed>
</tns:reservations>
</tns:cancelReservationResp>
</soapenv:Body>
</soapenv:Envelope>
I am getting this <tns:success>true</tns:success> value from $success variable but not getting anything from $garageID variable.
Any idea why $garageID is getting blank?
Thanks.
I am passing an xml string to https://insurance-api.pingtree.co.uk/api through curl but is getting parameter error in response (code 12 0) which can be also seen if you browse the above mentioned url.The parameter is defined in the xml i.e. the campaign code then why isn't the system recognizing it. here is my code below which i also got from the http://www.quinternet.com site.
<?php
/**
* Initialize the request xml string here.
* The string in the tag like '[int]' should be replaced with actual value.
* The string in the square brackets is the data type.
*/
$request_string =
'<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:pt_service">
<soapenv:Header />
<soapenv:Body>
<urn:submit
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<campaign_code>dllfYg0JBwQ</campaign_code>
<site_url>www.surelifecover.co.uk</site_url>
<client_ip>127.0.0.1</client_ip>
<policy_type>J</policy_type>
<cover_purpose>1</cover_purpose>
<cover_amount>50000</cover_amount>
<cover_term>1</cover_term>
<title>1</title>
<first_name>INTRODUCERTEST</first_name>
<last_name>wwww</last_name>
<dob >1995-04-05</dob >
<email>will#bitscube.com</email>
<home_phone>07111111111</home_phone>
<best_call_time>1</best_call_time>
<gender>F</gender>
<is_smoker>Y</is_smoker>
<title2>1</title2>
<first_name2>ww</first_name2>
<last_name2>wwww</last_name2>
<dob2>1991-02-03</dob2>
<email2>913661383#qq.com</email2>
<home_phone2>07111111112</home_phone2>
<best_call_time2>2</best_call_time2>
<gender2>M</gender2>
<is_smoker2>N</is_smoker2>
<terms_consent>Y</terms_consent>
<privacy_content>Y</privacy_consent>
<mode>LIVE</mode>
<keyword>life ins</keyword>
<match_type>1</match_type>
<network>ABC</network>
<device>mobile</device>
<ref>00</ref>
<v1>var1</v1>
<v2>var2</v2>
<v3>var3</v3>
<v4>var4</v4>
<v5>var5</v5>
<i1>1</i1>
<i2>2</i2>
<i3>3</i3>
<i4>4</i4>
<i5>5</i5>
</urn:submit>
</soapenv:Body>
</soapenv:Envelope>
</env:Envelope>';
echo htmlspecialchars($request_string);
echo '<br>';
/**
* The values of the following fields please refer
*to the reference field list spec*
//setup the request headers here, notice at the action string and SOAPAction string */
$request_headers = array('Content-Type: application/soap+xml;charset=utf-8;action="urn:pt_service#Webservice#submit"',
'SOAPAction: "urn:pt_service#Webservice#submit"',
'Content-length: '.strlen($request_string) );
//setup the service url here
$service_url = 'https://insurance-api.pingtree.co.uk/api';
//setup the user agent for the request
$user_agent = $_SERVER['HTTP_USER_AGENT'];
//initialize the curl here
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $service_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLINFO_HEADER_OUT, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POST,TRUE );
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_POSTFIELDS,$request_string);
curl_setopt($ch, CURLOPT_HTTPHEADER,$request_headers);
//do the submit process here
$result= curl_exec ($ch);
$response_string = curl_exec($ch);
// Convert API feed to xml object
var_dump($response_string);
$xml = simplexml_load_string($response_string);
$name = $xml->response->status;
echo $name;
//-----------------------------------------------
//parsing the response string here
/*example response below. Please get detail
refer for the reponse in specs.
<?xml version="1.0" encoding="UTF8"?>
<response>
<result>20</result>
<status>1</status>
<commission>10.00</commission>
<reference>347</reference>
<message><![CDATA[Accepted]]></message>
<redirect_url>
http://insurance-api.pingtree.co.uk/redirect?p=bUzbir4VhB-BB-Z_gMxVSy8YT15gxUB9iJMBGxi_aOq5PQuDBf_JPqgvc2egv6orCj6TJkeR5g6tX1y0D7hZgbV6DdBAlzbccKmkFNG4-PgWmaNR9LQ57cUQg6jTOXuB
</redirect_url>
</response>
//-----------------------------------------------*/
curl_close($ch);
?>
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();
}