tags:

views:

929

answers:

1

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.)

+1  A: 

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 http://stackoverflow.com/questions/1027745/having-trouble-getting-my-head-around-soap-in-php/1027852#1027852)

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.

Tom Haigh
Thanks, this has been useful. Now when I call one of the service's operations, the script doesn't seem to return! I've added some details to the original question.
Graham Clark
Oops, didn't wait long enough. "Error Fetching http headers" apparently...?
Graham Clark