I'm using nusoap to communicate with a web service in PHP, and for a few particular parameters I need to pass the attribute:
when the element is NULL.
I've been searching around for hours and can't seem to find any example on how to add this, or any attribute at all to node elements.
Creating a parameter array is very straight forward, but does anyone have a simple example of how to tack on an attribute to a given parameter element? Thanks!
This is a part of XML Schema that NuSOAP does not fully implement. Currently, if you provide a PHP NULL value for a parameter (or array element of a parameter), NuSOAP will serialize the xsi:nil="true" attribute when calling an rpc/encoded service. When calling rpc/literal or document/literal, it simply creates an empty element. To properly support XML Schema, NuSOAP should look for minOccurs and nillable attributes for the element to determine how to serialize NULL values.
If I get a chance, I will look into coding this better.
Could you provide a syntaxual example of how to call an encoded service? When looking at the nusoap class, I see call() defined as:
but when I tried to invoke 'encoded' as the value of the last parameter, I don't see xsi:nil being appended. my use:
$result = $client->call('myCall',$myTest, NULL, NULL, NULL, NULL, NULL, 'encoded');
What am I missing?
If you are using WSDL, which hopefully you are, only the first two parameters to call are used. The rest are taken from the WSDL. If the service is implemented as document/literal, you can never use 'encoded' to generate a valid request.
I am going to look at the XML Schema spec and NuSOAP code right now to see how difficult it is to make NuSOAP behave correctly (or at least more correctly) in this regard.
I'm also trying to get this working, but got the latest version (I think). I'm not seeing xsi:nil="true" in my request.
Could you get me an example?
OK, I made some changes to the wsdl class and checked them into CVS (both class.wsdl.php and nusoap.php). The changes do not break anything I tested. They *may* allow you to get your nillable value serialized correctly. Let me know how it works for you.
Brilliant! As soon as I copied over the new classes, my result worked, and I can clearly see the xsi:nil attribute appended properly when debugging.
Hi Snichol, I have the same problem and I see that you've solved, where I can find the changes you have done to solve the problem?
sorry, I ask the question differently. as I have to make the call to encode the nillables values?.
Log in to post a comment.