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.
Related
I'm using PHP's SoapClient to access a SOAP service. The provider of the service has told me that their WSDL is only for development and I shouldn't use it in production.
The SoapClient constructor expects the first argument to be the WSDL of the service, but also allows null, when working in non-WSDL mode.
I've been searching the RFCs and W3C for guidance, but haven't been able to find anything definitive on the use of WDSLs with SOAP.
Should someone who provides a SOAP service also provide a WSDL?
If someone who provides a SOAP service with a WSDL, is it correct to query that WSDL for each SOAP call?
Is it bad practice to provide a SOAP service without WSDL?
I wouldn't call it bad practice. It is a convention to provide a WSDL file at ?wsdl but you are not required to. There might be a reason why the provider doesn't want to expose the WSDL file, e.g. if it's a private web service.
The provider of the service has told me that their WSDL is only for development and I shouldn't use it in production.
So there is a WSDL file but it shouldn't be used? Now that sounds like a bad practice to me. IMO there should either be a valid WSDL file or no file at all. A file that doesn't reflect the actual web service will just cause confusion.
is it correct to query that WSDL for each SOAP call?
Yes the WSDL file is cached anyways and hence won't be queried every time.
We need to transfer file from one server to another using PHP SOAP or REST web service. We are considering MTOM for this. Any readily available php library for this?
QuickBooks Web Connector is a Windows client that can communicate with a SOAP server to synchronize QuickBooks data. They supply a QuickBooks Web Connector WSDL file which defines the functions supported by QuickBooks Web Connector. I am using the Zend_Soap_AutoDiscover class to generate the WSDL, but QuickBooks Web Connector does not understand the response.
How do I write a Zend SOAP Server class that will implement this pre-existing WSDL?
I ended up NOT using Zend_Soap classes at all, and am using the QuickBooks PHP DevKit Server. I'd still like to know how to accomplish this with the Zend_Soap classes.
Zend_Soap_AutoDiscover is used to generate a WSDL from an existing class. Usually this is used when setting up your own SOAP Server / Web Services. It sounds like you are trying to go the other way and get / send data to Quickbooks. If so, look into Zen_Soap_Client
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.
I have a WCF web service which allows both Basic HTTP and WS-HTTP clients, both over HTTPS using user name & password authentication. This is achieved with two bindings on the same service.
So, the service is at https://foo.com/Service.svc, the Basic HTTP (SOAP 1.1) endpoint is https://foo.com/Service.svc/Unp11, and the WS-HTTP (SOAP 1.2) endpoint is https://foo.com/Service.svc/Unp .
A client is trying to access this web service via PHP 5, using its built-in SOAP support, and is having trouble connecting to the service. He keeps getting an HTTP 400 (Bad Request) response, which tends to happen if the SOAP message is badly formed, or a SOAP 1.1 message is sent to a SOAP 1.2 endpoint (or vice versa).
I only know basic PHP so I'm having trouble helping him. I know you can create a client by doing
$client = new SoapClient('https://foo.com/Service.svc?wsdl');
but how do you specify the binding/endpoint? Are there any known issues achieving all this with PHP?
UPDATE
Ok, so I can use PHP to connect to the WCF service ok (specifying the SOAP version in the SoapClient constructor), and calling $client->__getFunctions() returns a correct list of all the web service operations.
When I try to call one using $client->__soapCall, the page just sits there loading for quite a while, and eventually returns the error "Error Fetching http headers". What exactly is this supposed to mean and how do I fix it? (Consuming the service from .Net client works perfectly.)
Just ran into this today, creating a WCF with multiple bindings for a PHP caller. Setting the location appears to allow for both the WSDL version of PHP's SoapClient and specifying a binding to use.
WCF config is (1 service with 2 bindings wsHttp and basicHttp), pretty straight-forward.
PHP code:
$client = new SoapClient("http://example.com/service.svc?wsdl");
$client->__setLocation("http://example.com/service.svc/basic");
$response = $client->MethodName(array( "paramName" => "paramValue" ... ));
We have a SOAP service which has several bindings. In C# when you add a service reference to a wsdl you get a class created for each one, but in PHP it seems you can't specify which binding you want to use - this has caused me problems when the bindings have conflicting type/method names. It does seem to generally work out OK though but I don't really know how it is dealing with it internally.
The other common problem I have had is that I always have to wrap up the parameters in loads of arrays or structs - sometimes you get a Bad Request back if the server is expecting a parameter and you haven't quite set it correctly. (see Having trouble getting my head around SOAP in PHP)
Not sure this is much help, just some thoughts. There are also some third-party Soap client implementations written in PHP that could be worth looking at, but they will be quite a lot slower.