I have quite complex (authentication, logs, ...) SOAP server (standard PHP extension). Everything is working fine but I want to know if there is any tool for creating / generating WSDL file? All changes I do manually and there are two problems:
localhost
I have for testing reasons the same SOAP server on localhost - I need the same WSDL file and only difference is in url addresses which point to localhost. I copy & paste lines from one (localhost) file to other (production) file and this is good way to do mistake.
new function
When I want to add function to WSDL it takes me "long" time to understand again wsdl because it has more that 1000 lines.
I'm quite new to SOAP and also WSDL - I'm looking for good (and free) WSDL editor or tool to gererate WSDL file.
Try WSO2 WSF/PHP Library. It can generate WSDL right from your code.
If you're using Eclipse, you can take a look into the WSDL Editor.
You can also create a build script, that parses an existing WSDL (it's XML) and replace specific values (like the hostname) with another one to a target file.
Creating WSDL file from scratch can be very complicated and error prone. To ease this process, you can use an IDE to generate the WSDL file for your PHP functions and pass it as a parameter to your PHP SoapServer class. Check out this simple tutorial on How to generate wsdl for php native soap class
Related
I am trying to consume a SOAP web service with PHP.
The web service WSDL can be found here.
Simply creating the client like that:
try {
$wsdlUrl = 'https://eu1.praxedo.com/eTech/services/cxf/v6/BusinessEventManager?WSDL';
$client = new SoapClient($wsdlUrl);
}
catch(Exception $e) {
echo $e->getMessage();
}
This fails with the following error:
SOAP-ERROR: Parsing WSDL: Unknown required WSDL extension 'http://schemas.xmlsoap.org/ws/2004/09/policy'
I tried using 2 separate generators:
https://github.com/WsdlToPhp/PackageGenerator
https://github.com/wsdl2phpgenerator/wsdl2phpgenerator
They both fail with the exact same error.
PHP version is 7.0
I found this old bug report from 2008 which apparently never got fixed because not enough info was submitted at the time.
Does anyone know how I can fix that issue?
If you look at your WSDL you will see it imports a WS-Policy section:
<wsdl:import location="https://eu1.praxedo.com/eTech/services/cxf/v6/BusinessEventManager?wsdl=Pxo-policies-v1.0.wsdl" namespace="http://ws.praxedo.com/policies/v1.0">
</wsdl:import>
See http://specs.xmlsoap.org/ws/2004/09/policy/ws-policy.pdf for details:
The Web Services Policy Framework (WS-Policy) provides a general purpose model and corresponding syntax to describe the policies of a Web Service. WS-Policy defines a base set of constructs that can be used and extended by other Web services specifications to describe a broad range of service requirements and capabilities.
It's probably on this that your code generator chokes, although I don't know why; these policies apply at execution time. If you have difficulties generating the code because of them, you could remove that import from the WSDL and try to generate the client code without the policies. You basically download the WSDL to a local file, delete that import line above, and feed this modified local WSDL file to your code generators and your SoapClient.
You will still need to respect the policies when calling the SOAP web service (for example, the service requires basic authentication), but the generated client code should be the same with both versions of the WSDL.
As mentioned in the other answer, you also need to use SOAP 1.2 since the binding in the WSDL is defined as SOAP 1.2 (the SOAP Envelope will have this namespace xmlns:soap="http://www.w3.org/2003/05/soap-envelope").
Not sure this is available on 7.0 but try setting the option soap_version to SOAP_1_2 (see the docs).
I have a bit of a problem understanding how the WSDL local file is working. Normally when I need to consume a WSDL file I simply use SoapClient and pass the URL (Something like https://somesite.com/something?wsdl) to it and I am able to consume it. However, now with a new webservice provider they gave me 6 files. Two of which has .wsdl extensions and the rest has .xsd extensions. I have never consumed a web service like this before and I cannot find any tutorials online or any topics regarding this with PHP. I found one where they explained it in Visual Studio, but we need to get this working on PHP. Can anyone point me in the right direction? I did not even know this method existed as normally we consume them by URL.
Any help would be greatly appreciated.
generally speaking, every wsdl is one web service, so there's 2 different services. Xsd files are just xml schema definition and you don't need it while you're calling web services. Use them to validate your soap xml.
If wsdl-s are v 1.1 you can try NuSoap on php site, if not, in Visual Studio you have wsdl.exe command line tool. Use that tool to simulate those web services localy, so you'll get excellent testing environment.
I also highly recommend you to try SoapUI.
Cheers,
SiniĊĦa
A third party provided a WSDL specification, through which I'm going to transfer data to a remote application using SOAP.
I'd like to convert all declared types, constants and method signatures to corresponding classy PHP source code.
Today, I gave WsdlToPhp a try. As far as I figured out, this converter doesn't convert any detail. Furthermore, the documentation has a few rough edges... Maybe a better converter exists.
Q: Could someone propose a stable WSDL to PHP converter?
Please note, that I need a converter to be run offline on a development machine. The WSDL specification isn't publicly available. Therefore, I'm not able to upload the WSDL to a remote converter service.
I used Wsdl2phpgenerator recently. It was pretty easy to use and the generated code has not let me down yet.
I think i done it once, use the pear wsdl lib
http://pear.php.net/reference/SOAP-0.9.4/SOAP/SOAP_WSDL.html#methodgenerateProxyCode
can any one help me in developing soap client whereas parameters type of soap server's functions is object etc.
$client->__call("functionName",array(/*now how to find parameter type if they are object*/));
thanks ...
Just read the official documentation (http://php.net/manual/en/class.soapclient.php). There are plenty of examples, you only have to copy, paste and adapt them.
If you really don't know how to use SOAP in PHP then try to use a WSDL to PHP generator such as PackageGenerator. With this is you'll have a PHP SDK corresponding to SOAP Web Service using the native PHP SoapClient class. A tutorial file is also generated that can be used as a starting guide.
Is it possible to consume a php webservice in visual studio? I have a webservice with a wsdl file created by nusoap, when I try to add the web reference in visual studio the name of the service and the methods show up but it complains that the 'wsdl is not a known document type' and the discovery document could not be found.
Any suggestions would be appreciated.
thanks,
Richard
Responses to suggestions:
Well there is no asmx file at the moment, since the .net app is using the functions of the php webservice and not the other way around. Maybe nusoap can create a asmx? I think that is just for the .net side though.
I 'm trying with nusoap because it automatically creates the wsdl for you, however I did try the inbuilt soap handing of php first with my own wsdl file but got the same error as with nusoap.
Seems the problem in the end was really my webserver, my files where encoded in utf8 and it didn't like that. Thanks for the answers though.
I use the pattern of the code found here. It works for me. Also did you check to the wsdl by browsing to the url of the service? It may be that your service is generating an invalid .wsdl file.
Here is what I found to use nuSoap with WCF. http://offroadcoder.com/2008/03/23/CallingYourNusoapPHPWebServiceFromWCF.aspx