Is there available any tool for PHP which can be used to generate code for consuming a web service based on its WSDL? Something comparable to clicking "Add Web Reference" in Visual Studio or the Eclipse plugin which does the same thing for Java.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- How to know full paths to DLL's from .csproj f
- Can php detect if javascript is on or not?
I've had great success with wsdl2php. It will automatically create wrapper classes for all objects and methods used in your web service.
In PHP 5 you can use SoapClient on the WSDL to call the web service functions. For example:
and $client is now an object which has class methods as defined in some.wsdl. So if there was a method called getTime in the WSDL then you would just call:
And the result of that would (obviously) be in the $result variable. You can use the __getFunctions method to return a list of all the available methods.
I have used NuSOAP in the past. I liked it because it is just a set of PHP files that you can include. There is nothing to install on the web server and no config options to change. It has WSDL support as well which is a bonus.
This article explains how you can use PHP SoapClient to call a api web service.
Say you were provided the following:
and
Let's say that accessing http://thesite.com/ said that the WSDL address is: http://thesite.com/PortalIntegratorService.svc?wsdl
As you can see, the items specified in the XML are used in the PHP code though the LoginId value can be changed.
Well, those features are specific to a tool that you are using for development in those languages.
You wouldn't have those tools if (for example) you were using notepad to write code. So, maybe you should ask the question for the tool you are using.
For PHP: http://webservices.xml.com/pub/a/ws/2004/03/24/phpws.html