how to do SOAP request in PHP code - php

My website is written in PHP. How should I write the PHP code to send a SOAP request to another server and parse the response.
The link below is the server who can accept the request.
http://gisdata.usgs.gov/XMLWebServices2/Elevation_Service.asmx?op=getElevation
Thanks.

You have options.
If it's available on your server, there's a native SoapClient extension for php. You could use that.
Or, you might prefer the Zend_Soap library, which is part of the Zend Framework, but can easily be used independently.
There venerable nuSoap library is an old standby.

Related

SOAP client with node.js and socket.io

I am trying to create a web app using Node.js. I want to use socket.io to stream data that I pull from a soap service. I am having trouble finding any information about this. what would be the best option for this situation.
right now:
I am using PHP to call a soap service and retrieve data.
my client side java script makes interval calls using AJAX to the PHP function containing the SOAP call.(this is inefficient which is why I would like to switch to socket.io setup).
What I would like to do:
Node.js app with express possibly
SOAP call using PHP or Node.js if possible.
stream data from SOAP to client side to be viewed using socket.io
I am not sure if this setup is possible and I have not found and good documentation on this. would this be possible ? if so, what would be the best method or is there a tutorial for this?
There is excellent node.js module called 'soap', you may get it via npm install soap. Also see the docs at https://github.com/milewise/node-soap.

Passing a Soap message from PHP

I know almost nothing about PHP. So I have a coworker doing the PHP stuff. It's not going well so I need some help.
Here is the task.
Receive a SOAP message (in this case from SalesForce) in a PHP site on Linux.
Take that soap message and simply pass it along to a web service (as a parameter) running on a windows server. Which I am writing. The reason we need to do it this way is far beyond the scope of this question. We have no choice.
The communication between the PHP page and the webservice works. The problem is taking the soap message and sending it to the method in the webservice as a parameter.
Here is the big question:
How can we accept a soap message and send it as a prameter. Even converting it to a simple string and sending that would work.
Thanks in advance.
It looks to me like you need to use a SOAP handler, and then reformat the request accordingly.
I'd suggest you start by taking a look at NuSOAP, which provides PHP SOAP support. Go here - for a nifty tutorial on NuSOAP

PHP SOAP Server - how to check parameters against WSDL file

I'm setting up a SOAP service using the PHP SOAP server and client library.
I've coded some structured data types into my wsdl file with some heavy restrictions.
Do you know of functionality in the PHP SOAP library or of a 3rd party library which will check the actual parameters in the the server against the definitions of the WSDL file? Or do I have to code all my parameter checking explicitly into my SOAP server class, even though it is already coded in the WSDL?
In PHP 5.2 the SOAP server does not validate against the WSDL as described here http://bugs.php.net/bug.php?id=45966
I'm not sure about 5.3 though.

PHP Soap (Server)

I am trying to create a webservice using the PHP Soap extension and I am having problems with the .wsdl. Is there an easy way to generate 2.0 wsdl's? Where is a good site (or book) that I can look to in order to determine how to build the WSDL? I have no problem getting my soap client to retrieve soap messages from other web services so I know soap is installed and working. I have found a few links out there that generate WSDL's for you, but most of the sites are down. Any help pointing me in the right direction would be helpful
PHP does not have a built-in WSDL generation utility. I would recommend using Zend_Soap_Server which supports WSDL generation via its Autodiscover feature.

Accessing Sabre Web Services using PHP

I have been approached to create a website using Sabre Web Services to power the reservations system. All documentation I have seen refers to .NET or Java solutions, and I was in doubt as to whether PHP can be used, as access is performed using SOAP.
I have found no further information about this, and I assume the answer is yes, but I wonder why there is not a single reference to this being possible. All solutions seem to be .NET!
SOAP is language independent, which means that any language can communicate with the web service if it can generate SOAP requests and handle responses.
PHP's SOAP documentation can be found in the php manual
PHP can be used to call SOAP pretty effectively.
There's a very good tutorial on devzone on how you can use SOAP well.
I've just done a little digging around and it looks like you can use stream_context_create() to create a custom HTTP stream context. This would include the HTTP content type header you need. The resource returned from this function call can then be passed to the SoapClient constructor to be used in SOAP calls. Have a look at http://ca.php.net/stream_context_create and the PHP manual page for the SoapClient constructor (sorry, I can only post one link as a new user) for more information.
Yes, PHP can be be used to connect to SOAP web services - take a look at NuSOAP. It allows a nice & easy object oriented way to consume web services.

Categories