A PHP Soap Nightmare.

Back in September 2016 I began working on a project that used SOAP to communicate with a WebService.  No big deal. However, I kept running into issues that I couldn’t seem to resolve regarding types in the WSDL.  I eventually created this StackOverflow post to try and get help, which never really happened. This was the basic issue I was dealing with.

I have a WSDL, that I am connecting to and getting a sessionToken  that is used for future requests, all well and good. I am trying to call a VmifCreateVisitor  method now that according to SOAP UI, should look something like the following:

I can create a visitor OK if I leave out the DetailFields  section:

But this is not something I can do, I need to send some personal details in the POST request. This is where it gets weird. When I send the following SOAP DetailFields Params, I get “Cannot create abstract class“.

The Generated PHP WSDL Class created the following PdfValue()  Class:

But I notice its missing Value  parameter, same with SOAP structure from SOAP UI. (Adding it to class makes no difference).

If you’re curious, here is the VmifVisitor  class the WSDL generated:

As shown above – its missing the DetailFields  parameter, even the the SOAP API Docs clearly show its required, (Adding it manually to class still doesn’t help)

The Actual documentation shows the following structure for PdfValue :

As you can see it clearly shows Value  as an object. What is it expecting me to send it in an object?

For completion, this is the documentation for the Visitor  object:

So we can see its expecting an array of PdfValue , which I believe I am sending.

In the end this basically boiled down to a namespace issue. The Type was not being found due to my assumption that all types were in the same namespace. Simply changing:


This was the key to getting this working.  Using SoapVar  to encode the object properly.

I also stumbled onto a decent article that shows how to use PHP’s  ArrayObject() to achieve some sanity when creating an XML envelope that needs to have specific tag names.


Leave a reply:

Your email address will not be published.

Site Footer