Portlet Factory, Version 6.1.2


 

Creating schemas for complex argument and return types

If the method you want to expose as a Web service takes one or more XML arguments or returns an XML structure, you need to create a schema that describes the structure for the argument and return types and then add a Schema builder call to your model to add the schema to the model. The WSDL document generated by the "getWSDL" action includes any schemas needed for describing the inputs and outputs of a service.

The Schema builder will accept only XML Schema 2001 XSD which you can create with third-party tools such as "XML Spy." Alternately, the Simple Schema Generator builder will build a schema into the model from simple XML such as that shown below.

For example, if the method takes an IXml argument with the following structure:

<customers>
<customer>
<name></name>
<id></id>
</customer>
...
</customers>

The corresponding schema would be:

<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.acme.com" xmlns="http://www.acme.com">
<xsd:element name="customers">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="customer" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
<xsd:element name="id" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

This schema requires the developer calling this service to pass a <customers /> structure that contains at least one <customer /> element.

Parent topic: About creating web services


Library | Support |