Now here is the part where I give the example files. After we have planned the application functions, we need to figure out what we are going to return to the client. This is going to be a standard array with at least two levels: The Response array and the Data array. It will look similar to this:
Array
(
[responseMsg] => Array
(
[status] => ok
[message] => Service call was successful
)
[allColors] => Array
(
[0] => blue
[1] => green
[2] => black
[3] => white
[4] => yellow
[5] => red
[6] => beige
)
)
Now that we have the basic idea, we need to create the WSDL file. Remember, it is very important to think of WSDL files as of reading from bottom to top. The final WSDl file is located here. Here is the basic idea of the WSDL file I created (going from the bottom to the top):
- Service: This houses the binding, the location, the port, and the name.
- Binding: This houses the functions that will be exposed, the operation and the input and output encoding. Most of the time these will be similar with only the names being different.
- Port Type: Here is where I define the operations and the input/output definitions
- Message: These are individual nodes for the Request and Response messages for all functions. These will usually have two message nodes per function, and they will define the structure for each action
- Types: This defines each structure that has been mentioned in the Message and any subsequent structures that have to be defined. This is usually the area where most struggles occur.
- This structure will be encompassed by schema target namespace
- Import the XML namespaces to help build the structures in the reasponse
- For each complex type, it should either mention a specific data type (xsd:), or a new defined structure (tns:)
- Each structure that is an array should be defined as a SOAP-ENC:Array with a wsdl:arrayType parameter
So that is the WSDL. The one I have created defines the 2 functions, the input, the output, and the structure of each. Now we can move on to the Server code.
(more…)