Tiago Silva Tec. Informação e Hobbies pessoais

4Jul/110

Making arrays in WSDL (RPC/encoded)

This article covers how to create an array of any type within an WSDL document.

Why is the array type so hard to find? Because in WSDL this is not a type, but rather, an encoding restriction and this means that not all bindings are allowed to carry arrays.

Many may use the light HTTP POST and/or GET bindings, but these are a little limited, they do not provide any array encoding type from out of the box. Of course there is JSON, which does the job very well, but this article will cover an well known and used encoding type, the SOAP encoding.
 
Have in mind that this example is having in mind that you are already using SOAP within your WSDL.
 
Here goes an example of WSDL code snippets showing an ordinary string being encoded in an array.
 
First of all, to use this encoding restriction you must import the namespace "http://schemas.xmlsoap.org/soap/encoding/" in your WSDL types schema.
Example:


 
Then, you define your array restrictions, like any other custom type.
Example:
 

     
          
               
                    
               
          
     

 
If you noticed, this complex type uses the SOAP-ENC namespace to get this restriction and thus, encoding the string object in an array restriction on the SOAP envelope.
 
There is also one last thing. You must tell the importing client that you are using this encoding in your binding operation input or output.
Example:


     

 
This means that you can have different bindings together, but remember that array restrictions are just for SOAP, they will not work with HTTP POST or GET bindings. To use HTTP POST or GET bindings and work with arrays you must learn about how to serialize and deserialize objects into JSON (for example).
 
Until then, have fun understanding WSDL and SOAP!

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.