How can I get Soap request and response xml through Soap server - php

Is there any way to get SOAP request and response through SOAP server. I know that I can get it via SOAP client?
Any help will be appreciated.

I am able to get the request xml on my SOAP server, we can get it via following line:-
file_get_contents('php://input')
This provide us the Raw POST data.
But still struggling with response xml.Hope to find a solution for that too.

At the end of the day, a SOAP call is just http.
To get the raw SOAP XML request, use the PHP function http_get_request_body() or use the $GLOBALS['HTTP_RAW_POST_DATA'] variable.
To get the XML response, you can capture it after you do $soapServer->handle(); with $xml = ob_get_contents(); much the same way as you would grab the output of a web page.

Related

soap client api call

Kindly any one explain how to give request and when hit the soap api url i want to get the response using soap client call.
You can use an assign and an unset
$your_array[$your_newkey] = $you_array[$your_oldkey];
unset($arr[$your_oldkey]);

How to send xml file for asp.net webservice using php soap

I have to send a XML file to asp.net based webservice. I am using php soap client.
Here is the code:
$request = file_get_contents('myfile.xml');
$result = $soap->__doRequest($request, 'LOCATION_URL', 'ACTION_URL', SOAP_1_2);
AND the xml file looks like:
<ns1:header xmlns:ns1="http://something.com">
<ns1:timestamp>2014-01-01T13:20:00.000-05:00</ns1:timestamp>
But, every time its return a blank response. I didn't get any clue from any side.
Any help will be welcome.

Autogenerate SOAP requests from WSDL in PHP

Im have searched a lot for a code-snippet to autogenerate a SOAP request based on a WSDL in PHP.
We have a 3'rd party vendor creating a huge WSDL ( + related webservices) for us , and I would really like to autogenerate some SOAP-requests in PHP based on that WSDL.
I know of application specific tools like SOAPUI etc - however - I prefer to do the unittesting directly in the PHP-code.
Do you know of any PHP lib to autogenerate SOAP requests based on a WSDL? Or even better, do you have a some code to autogenerate a SOAP request?
use apigenerator.com to generate soap requests
What i would recommend you is to use the soap components of the zend framework.
For example you just setup a soap client using :
$client = new Zend_Soap_Client("url to wsdl file");
//Then you can do what ever request to the server.
$client->helloWorld("Parameter');
// In this example i guess helloWolrd is a server function.
and finally you can have the xml soap request calling:
$request = $client->getLastRequest();
just do: echo $request; and you will see the data.
Remember to change the mime code to xml so you can see the xml in the browser.

PHP HTTP request to get JSON response

I am a novice in PHP. I have a URL and I need generate a GET request to this URL and get a JSON response. How might I achieve this?
You can perform GET requests using the following. . . provided PHP is not in safe mode.
file_get_contents();
curl();
You can use http://php.net/curl library to send GET requests.

Need help understanding Google Maps API URL?

i am kind of new to API thing, and i need help understanding on what exactly is happening with the below Code.
$address = 'Bhatkal, Karnataka, India';
$requestUrl = 'http://maps.google.com/maps/geo?output=xml&key=aabbcc&oe=utf-8&q='.urlencode($address);
$xml = simplexml_load_file($requestUrl);
i understand that HTTP is capable of sending Request and getting response in return isn't it? what i am unable to understand is the third and last function that is $xml = simplexml_load_file($requestUrl); when i do a print_r($xml) i get an object in return which prints all the object details i got back as response,
how does the function process the
URL?
does it use CURL (i have very less idea about what is CURL).
and where do i look up for Google Maps API URL?
That function does not process the request (nor the URL), only the response, Google processes the URL that, the function just "visit's" it. You can do as well: here. The XML file you see here is ending up in the variable $xml, parsed.
EDIT: the URL in this post is not working too well, because of the key parameter
simplexml_load_file internally uses the fopen wrapper and opens the remote xml that would be produced by the url and then converts into an array for php to easily use.
The response object will help you to extract the data from the response.
Check out the details of Google Maps API

Categories