Using Fixed WSDL file with PHP SOAP - php

I' developing a Soap Server using php nusoap library, however , I don't need to use dynamic generated WSDL file feature that's generated by nusoap, I just want to tell nuSoap to use the Fixed WSDL file that's written manully by an another team.
What do you suggest ?

My suggestion - give up. I'm not entirely sure that you can do what you want.
As you know, NuSOAP creates the WSDL on the fly only from the functions that you specify and then returns the resultant WSDL when requested.
If you could use an external fixed WSDL, what would happen if it is changed later on without your knowledge? A call to a SOAP method which is not handled by one of your functions could provide unknown results and would need to be handled by the calling machine in a nice, non-customer impacting way. Conversely, if you provide a new functionality but the other team won't adjust the WSDL for you, what do you do? Try and shoe-horn it into some other function?
Trying to match your functions to a pre-defined WSDL without errors would far out-strip any benefit you could get.
Stick with the "on-the-fly" generation for consistency and lack of headaches. Use the pre-generated WSDL as a reference but don't bother investigating whether you can use it
Also, I agree with #chrfin. If they are available on your server, consider using the native PHP SOAP functions - they are noticeably faster than NuSOAP as they are compiled rather than interpreted. The only reason I used NuSOAP in the first place was that (about 5 years ago) the native SOAP had problems communicating with a provider I needed (incorrect variable types etc). Now though, I will be re-factoring all of my code to native PHP SOAP

Related

Features of PHP SOAP

I am wondering the features that are fully supported within PHP Soap, I have tried researching this, but there is very little documentation to support PHP Soap.
Also how is Soap used during the exchange of data through client machine to web service then server.
I know this is fairly vague, but as I am constantly being asked this myself I thought it was better to find more about it.
PHP has some build in SOAP classes for both client and server. Docs is on here.
But you have to be sure that your PHP build is compilled with SOAP support.
"The features that are fully supported within PHP" are pretty much non-existent.
Built in SOAP client is ok only for basic services. It doesn't support any WS extensions, so you have to add support manually, e.g. including headers for WS-Security.
Also, there are some problems with namespace handling and creating requests.
If you'll be using it and are having trouble with missing parameters or badly formatted requests, you'll probably want to modify requests - this can be done by extending SoapClient class and overriding doRequest function.

wsdl 2.0 support in PHP

If I want to create a web service or consume a web service that is defined as WSDL 2.0, what options do I have in PHP?
As I understand it the in-built SOAP libs in 5.x don't currently support WSDL 2.0 spec, and I can't see future support for this.
One of my former colleagues used to devour SOAP services manually, simply because he disliked the current .net implementation.
The SOAP implementation is based around you posting XML across the web to the service, and you "just" need to build a such XML and parse the results coming back. It is not as simple as it sounds, but it definitely is possible.
The WSDL2PHP project seems very interesting, and im very sure this can lead you in the right direction.

Advantages of nuSOAP WebService?

I've been writing a demo web service in PHP using nuSOAP.
I wanted to know what is the advantage of nuSOAP to SOAP PHP5 class.
Also, this is a test web service to use as a model.
I was wondering which were the typical scenarios (general to Webservices, not just PHP) I should test out e.g. providing a web method that returns an object from the server returning a list of items.
The only advantage IMO is that it is a set of PHP classes and No PHP extensions are required.
So, if your webhost uses an older version of PHP or does NOT have SoapClient extension installed, you can use this.
To test the webservice, there is an awesome tool: soapUI.
I could tell one .
Nusoap could provide wsdl uri.
e.g.
https://www.domain.com/nusoap?wsdl

PHP remote procedure calling

I have two servers on PHP that need to communicate, calling remote methods of each other. XML-RPC for PHP is not very good solution because it's very slow, and I can't call multiple methods in one request.
Try MultiRpc - multiple methods calling in 1 request, by encrypted and compressed protocol.
XML-RPC in PHP is pretty fast actually, if you use the built-in xmlrpc methods. It supports multiple method calls in a single request as well, using system.multiCall. The native multiCall is broken up to PHP 5.3.2 though. I've written an easy to use library for xmlrpc, called Ripcord, which allows you to very easily create servers and clients and works around most of the bugs in PHP's native xmlrpc methods. See http://ripcord.googlecode.com/
Thanks for RipCord. I think it's a very good library. I just used it and could exec some rpc in just a hour or less.

Is it necessary to have a wsdl file for the creation of a webservice in php?

My question is needed for some basic understanding of webservices and more specificly
in conjunction with php
I would like to know, if it is necessary to have a wsdl file for the creation of a webservice or is that just something that is usefull to third party's that want to access the webservice?
Also, it's generated automaticly in .net environments, but for php it's a bit more difficult.
What are my options?
The thing I am after is to create a jm2ee application on my mobile that sends data to the webservice from time to time.
I read somewhere that you have to supply the arguments when there is no wsdl file.
What is meant by that? and/or what are the implications of that?
Thanks in advance, Richard
I would like to know, if it is
neccasary to have a wsdl file for the
creation off a webservice
No, it is not necessary (at least, not in PHP) : it helps others know how to access your webservice (which methods, objects, ... should be used), but a WS can be called even if it doesn't export a WSDL
For PHP, yes, it is a bit difficult to get a WSDL (many classes don't generated them :-( ) ; still, you can generatd it with another tool (there are tools in Eclipse to write WSDL files, for example).
There was PEAR::Soap that was able to generate WSDL from PHP code (but you had to write down many lines of code to get it right) -- considering there is a class included in PHP 5 to work with SOAP, I wouldn't recommend using this one, anyway.
For more informations, you can have a look at :
SoapServer ; especially, if you look at the documentation of SoapServer::__construct, you will notice it can work both in WSDL and non-WSDL mode
Zend_Soap
If you are creating both the client and the web service, then there is no particular need to futz with SOAP, WSDL, or any of that jazz.
Just use the basics of the web: the client can use GET to fetch information, and POST to send it. You can format the data any way you like, but JSON and XML are common, well-defined approaches.
If you'd like inspiration for your API design, check out some popular examples:
Twitter API
Flickr API
all the Google APIs
all the Yahoo APIs
That's enough to get you started, but if you're curious about the design philosophy, you can read up on Representational State Transfer or REST.
WSDL file documents in a machine readable (XML) format what the methods (and args for methods) offered by a web service. You do not need a WSDL file if you know what the methods and args are - though WSDL is very good to have as a means of making the web service public interface more 'contractified', if you will.
To the best of my knowledge the PHP library does not have functions to automagically generate a WSDL file for you.
Web service support is built into php5, your best starting place is the documentation.
Some sources will use the term "webservice" as synonymous with SOAP. That is a misnomer. SOAP is a particular protocol - It is one way to create a web service. There are other technologies available. In general SOAP is the preferred standard with in Java and .net, but it is a bad fit outside of this sphere. If you have the option, I would strongly suggest that you consider either xml-rpc (Which is simpler and has better direct support on php) or a http-based service (Also called REST based).

Categories