How can I pass in an array as a value into a PHP soapclient request?
I have a soapclient instantiated and connected already. I then try to make a call to a webservice method that expects 3 parameters (string, string, hashmap).
Here is what I expected to work below. But when viewing the xml output, the params node is empty.
soapclient->doSomething(array('id' => 'blah', 'page' => 'blah', 'params' => array('email' => 'test@test.com', 'password' => 'password', 'blah' => 'blah')));
The soap body xml ends up like this (note the empty params element):
<SOAP-ENV:Body><ns1:doSomething>
<id>blah</id>
<page>blah</page>
<params/>
</ns1:register></SOAP-ENV:Body>
For JAX-WS webservices it may be a problem with the hashmap input parameter. The xsd schema generated seems to be incorrect for hashmaps. Placing the map in a wrapper object causes JAX-WS to output the correct xsd.
Then the php code will succeed. I found I didn't need SoapVar or SoapParam and could not get either of those methods to work without the MapWrapper.
Here is the correct xsd generated with the wrapper
Here is the incorrect schema generated by JAX-WS with just the hashmap
One last note. Wrapping HashMap<String, String> worked with this solution, but HashMap<String, Object> did not. The Object gets mapped to xsd:anyType which comes into the java webservice as a xsd schema object rather than just Object.
Depending on the webservice definition, the hashmap parameter might need to have a specific structure/encoding that can not be directly created from an array. You might want to check the WSDL on that, and take a look into the SoapVar and the SoapParam classes for more options on Soap parameter construction.