Monthly Archives

April 2014


From some of my posts you’d figure I had a big project, where many problems occurred between SOAP PHP and other services..yeah it happened.

I had to implement connections with various security protocols, the other day at StackOverflow I noticed someone having problem with this, and most of the posts have no responses at all.

This specific post will show you to establish a connection to a SOAP WebService that is secured with WSSE, the specific doc is Web Services Security Username Token Profile:

In order to structure it clearly, and make sure PHP doens’t f*ck while generating the XML, we create various classes.

First we need a Class to store our username and password.

Then we need a class to store our Username Token related to this service.

Now instead of extending the SoapClient, which made errors happened in other places of communication with various other SOAP APIs.

I just make client inside another class, with the security options prepared and then return it to be used elsewhere in the code.

I have trace, exceptions and connection_timeout activated which are all optional.

After all those 3 classes are created, I can just access my prepared client like this:

Obvious as it seems, you need to indicate your user, pw, wsdl and gate (optional) to connect.

Afterwards you use it just as normal, example:

Hope this comes in handy for some of you..
Happy coding!