Tutorials > Web services > Define an inbound Web service

< Previous | Next >


Create the XML schema for a Web service

In this section you create the XML schema for a Web service.


Define a Web service

In this section, you use WebSphere Commerce Developer to define a Web service to retrieve product information. Using the XML tools, you develop an XML schema to contain the service definition. Then, using the Web service tools, you develop a WSDL document to expose the service.


Create the XML Schema

These are the recommended steps for creating an XML schema to define the customized service. For more information about how to use the XML schema tools, see the WebSphere Commerce Developer documentation.

To create the XML schema:


Procedure

  1. Under the WebContent/xsd folder in the WebServicesRouter project, create a folder to contain the XML schema. Right-click the xsd folder and select New > Folder. In the Folder name field, type MyCompany. Click Finish.

  2. Right-click the MyCompany folder and select New > Other.

  3. In the Select a Wizard dialog box, select XML > XML Schema and click Next.

  4. In the Create XML Schema dialog box, ensure that the MyCompany folder is highlighted. In the File name field, type ProductInformationServices.xsd.

  5. Click Finish to create the XML schema file.

  6. In the XML Schema Editor, click the Properties tab.

    1. In the Prefix field, type myco.

    2. In the Target namespace field, type http://www.mycompany.com/schema.

  7. Click the Graph tab.

  8. In the Types section, right-click and select Add Complex Type.

  9. Select the new complex type and click the Properties tab.

    1. In the Name field, type GetProductInformationType.

  10. Double-click GetProductInformationType.

  11. Right-click inside the GetProductInformationType section and select Add Sequence.

  12. Right-click the sequence and select Add Element.

  13. Select the new element and click the Properties tab.

    1. In the Name field, type StoreIdentifier.

    2. In the Type field, click the ... button and select string.

    3. In the minOccurs field, select 1.

    4. In the maxOccurs field, select 1.

  14. Right-click the sequence and select Add Element.

  15. Select the new element and click the Properties tab.

    1. In the Name field, type ProductSKU.

    2. In the Type field, click the ... button and select string.

    3. In the minOccurs field, select 1.

    4. In the maxOccurs field, select unbounded.

  16. Click the arrow in the top left of the XML Schema Editor to return to the schema.

  17. In the Types section, right-click and select Add Complex Type.

  18. Select the new complex type and click the Properties tab.

    1. In the Name field, type ProductInformationType.

  19. Double-click ProductInformationType.

  20. Right-click inside the ProductInformationType section and select Add Sequence.

  21. Right-click the sequence and select Add Element.

  22. Select the new element and click the Properties tab.

    1. In the Name field, type ProductSKU.

    2. In the Type field, click the ... button and select string.

    3. In the minOccurs field, select 1.

    4. In the maxOccurs field, select 1.

  23. Right-click the sequence and select Add Element.

  24. Select the new element and click the Properties tab.

    1. In the Name field, type ProductName.

    2. In the Type field, click the ... button and select string.

  25. Right-click the sequence and select Add Element.

  26. Select the new element and click the Properties tab.

    1. In the Name field, type ShortDescription.

    2. In the Type field, click the ... button and select string.

  27. Right-click the sequence and select Add Element.

  28. Select the new element and click the Properties tab.

    1. In the Name field, type LongDescription.

    2. In the Type field, click the ... button and select string.

  29. Right-click the sequence and select Add Element.

  30. Select the new element and click the Properties tab.

    1. In the Name field, type Availability.

    2. In the Type field, click the ... button and select string.

  31. Right-click the sequence and select Add Element.

  32. Select the new element and click the Properties tab.

    1. In the Name field, type SuggestedRetailPrice.

    2. In the Type field, click the ... button and select string.

  33. Click the arrow in the top left of the XML Schema Editor to return to the schema.

  34. In the Types section, right-click and select Add Complex Type.

  35. Select the new complex type and click the Properties tab.

    1. In the Name field, type ShowProductInformationType.

  36. Double-click ShowProductInformationType.

  37. Right-click inside the ShowProductInformationType section and select Add Sequence.

  38. Right-click the sequence and select Add Element.

  39. Select the new element and click the Properties tab.

    1. In the Name field, type Product.

    2. In the Type field, click the ... button and select User-defined complex type.Select myco:ProductInformationType and click OK.

    3. In the minOccurs field, select 0.

    4. In the maxOccurs field, select unbounded.

  40. Click the arrow in the top left of the XML Schema Editor to return to the schema.

  41. In the Elements section, right-click and select Add Element.

  42. Select the new element and click the Properties tab.

    1. In the Name field, type GetProductInformation.

    2. In the Type field, click the ... button and select User-defined complex type. Select myco:GetProductInformationType and click OK.

  43. In the Elements section, right-click and select Add Element.

  44. Select the new element and click the Properties tab.

    1. In the Name field, type ShowProductInformation.

    2. In the Type field, click the ... button and select User-defined complex type. Select myco:ShowProductInformationType and click OK.

  45. Save the work and close the XML Schema Editor.

After completing this section of the tutorial, you can verify that the XML schema is correct by comparing the source code of the schema with the source code of ProductInformationServices.xsd in the sample zip file.

< Previous | Next >


+

Search Tips   |   Advanced Search