soap client api call - php

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]);

Related

How make redirection with web service?

I have a web-service which send JSON object as response to log my user.
But if I take the URL of the service and I put it on my navigator I see the json object, how I can send the json througth a redirection ?
Example :
Facebook login -> if we take the action in the form that call facebook/login?...
If facebook use JSON to send a response of the log i must see the JSON object if i call facebook/login?... but I was redirected to the main page, how that works ?
Thank for your reply.
The answer is to check the $_SERVER['HTTP_X_REQUESTED_WITH'] after sending an specific header in the AJAX request.
I have a last question in like :
Can i use a same like this the volley library, to allow the access to a php script only for an android app ?
You can see an example on header in this link :
https://gist.github.com/FabrizioCaldarelli/ad1118e5d8ab0661ba36

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

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.

Passing tns:ArrayOfString to SOAP client

I'm trying to use the api from this service:
http://messagingws.payamservice.ir/SendSMS.asmx?WSDL
I'm using the php's SOAP client like this:
$client = new SoapClient("http://messagingws.payamservice.ir/SendSMS.asmx?WSDL");
$params=array();
$params['PortalCode']='code';
$params['UserName']='user';
$params['PassWord']='pass';
$params['Mobiles']=array('09123456789');
$params['Messages']=array('test');
$params['FlashSMS']=false;
$params['ServerType']=1;
$response = $client->__soapCall('MultiSMSEngine', array($params));
but I get "empty message" error, when I try with single mode it works correctly so it seems the problem is with Mobiles & Messages parameters that are tns:ArrayOfString
How can I correctly pass an array as tns:ArrayOfString for SOAP ?
thanks
First, you can call the method such as $client->MultiSMSEngine($params) instead of $client->__soapCall('MultiSMSEngine', array($params));.
If you keep your form of call, try $client->__soapCall('MultiSMSEngine', $params);
Finally, to ease you the call to any SOAP Web Service, I strongly advise you to use a WSDL to php generator such as PackageGenerator

Retrieving response from PHP OData SDK when using SaveResult method

I am using the PHP Odata SDK (http://odataphp.codeplex.com/). The documentation and community seems to be very limited.
I am attempting to save an object to the OData service and retrieve the response. When I execute the method, it successfully saves the object to the OData service, but just returns a successful or true result. It should return the ID of the object I just added (which it does).
$user = Users:CreatUser(array_of_data);
$proxy->AddUser($user);
$proxy->SaveResult();
How do I retrieve the actual response from the OData Service?
I have tried:
$result = $proxy->SaveResult();
But this does not work.
The location of the newly created entry should be returned in the Location header of the response, per the AtomPub specification.
If you were to surf to the location returned by the server in response to a successfully created entry, you should see an entry that looks exactly like the one in the HTTP POST response.

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