Defining the XML schema

This section describes the steps involved in creating an XML schema definition. In this lesson you are defining the XML schema, Customer.xsd. The Customer XML schema defines a Web service to create customers. Since this tutorial follows the OAGIS structure, the directories in which the XML schema is placed follow the OAGIS overlay recommendation. After completing this section, you will have an XML schema that is used to define the Web services.

Procedure

  1. Create the directories to contain the service XML schema and customer data objects:
    1. In the Enterprise Explorer view, navigate to WebServiceRouter/WebContent/xsd/OAGIS/9.0/Overlays
    2. Right-click the Overlays directory; select New > Folder. Name the folder MyCompany.
    3. Right-click the MyCompany directory; select New > Folder. Name the folder BODs. This folder contains the service XML schema.
    4. Right-click the MyCompany directory; select New > Folder. Name the folder Resources.
    5. Right-click the Resources directory; select New > Folder. Name the folder Nouns. This folder contains the customer data objects.
  2. Create the Customer.xsd schema file:
    1. In the Enterprise Explorer view, navigate to WebServiceRouter/WebContent/xsd/OAGIS/9.0/Overlays/MyCompany/Resources/Nouns
    2. Right-click the Nouns folder; select New > Other.
    3. In the Select a Wizard dialog box, select XML/XML Schema; click Next.
    4. In the File name field, type Customer.xsd.
    5. Click Finish to create the XML schema file.
  3. In the XML Schema Editor, set the schema properties:
    1. Select Window > Show View > Properties
    2. Click the Customer.xsd in the schema editor and click Properties tab.
    3. In the Prefix field, type myco.
    4. In the Target namespace field, type http://www.mycompany.com/schema.
  4. In the XML Schema Editor, create the CustomerDemographicsType type for the schema:
    1. Click the Design tab.
    2. In the drop-down menu for the View: options select Detailed.
    3. In the Types section, right-click the section and select Add Complex Type.
    4. Select your new complex type and click the Properties tab.
    5. In the Name field, type CustomerDemographicsType.
    6. Double-click CustomerDemographicsType to open the complex type for editing.
    7. Right-click inside the CustomerDemographicsType section and select Add Sequence.
    8. Create the element, Gender of type string for the CustomerDemographicsType sequence:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type Gender.
      4. In the Type field, select string.
      5. In the minOccurs field, select 0.
      6. In the maxOccurs field, select 1.
    9. Repeat substep h for the elements IncomeCurrency, MaritalStatus, Hobbies, and AdditionalInformation
    10. Create the element Age of type integer for the CustomerDemographicsType:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type Age.
      4. In the Type field, select int.
      5. In the minOccurs field, select 0.
      6. In the maxOccurs field, select 1.
    11. Repeat substep j for the element Income.
    12. Ensure that your design for the complex type CustomerDemographicsType resembles the following screen capture:

      This screen capture shows the CustomerDemographicsType complex type

  5. Click the show schema index view Show schema index view button in the upper left of the XML Schema Editor to return to the schema.
  6. In the XML Schema Editor, create the AuthenticationType type for the schema:
    1. Click the Design tab.
    2. In the drop-down menu for the View: options select Detailed.
    3. In the Types section, right-click the section and select Add Complex Type.
    4. Select your new complex type and click the Properties tab.
    5. In the Name field, type AuthenticationType.
    6. Double-click AuthenticationType to open the complex type for editing.
    7. Right-click inside the AuthenticationType section and select Add Sequence (Element)
    8. Create the element Logon of type string for the AuthenticationType sequence:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type Logon.
      4. In the Type field, select string.
    9. Repeat substep h for the elements Password, PasswordVerify, ChallengeQuestion, and ChallengeAnswer.
    10. Ensure that your design for the complex type AuthenticationType resembles the following screen capture:

      This screen capture shows the AuthenticationType complex type

  7. Click the show schema index view Show schema index view button in the upper left of the XML Schema Editor to return to the schema.
  8. In the XML Schema Editor, create the AddressType type for the schema:
    1. Click the Design tab.
    2. In the drop-down menu for the View: options select Detailed.
    3. In the Types section, right-click the section and select Add Complex Type.
    4. Select your new complex type and click the Properties tab.
    5. In the Name field, type AddressType.
    6. Double-click AddressType to open the complex type for editing.
    7. Right-click inside the AddressType section and select Add Sequence.
    8. Create the element StreetAddress of type string for the AddressType sequence:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type StreetAddress.
      4. In the Type field, select string.
    9. Repeat substep h for the elements City, State, Country, and ZipCode.
    10. Ensure that your design for the complex type AddressType resembles the following screen capture:

      This screen capture shows the AddressType complex type

  9. Click the show schema index view Show schema index view button in the upper left of the XML Schema Editor to return to the schema.
  10. In the XML Schema Editor, create the ContactType type for the schema:
    1. Click the Design tab.
    2. In the drop-down menu for the View: options select Detailed.
    3. In the Types section, right-click the section and select Add Complex Type.
    4. Select your new complex type and click the Properties tab.
    5. In the Name field, type ContactType.
    6. Double-click ContactType to open the complex type for editing.
    7. Right-click inside the ContactType section and select Add Sequence.
    8. Create the element FirstName of type string for the ContactType sequence:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type FirstName.
      4. In the Type field, select string.
    9. Repeat substep h for the elements LastName, PhoneNumber, FaxNumber, and Email.
    10. Create the element Address with a user defined complex type for the ContactType sequence:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type Address.
      4. In the Type field, select Browse....
      5. In the Set Type dialog, select AddressType; click OK.
      6. In the maxOccurs field, select 1.
    11. Ensure that your design for the complex type ContactType resembles the following screen capture:

      This screen capture shows the ContactType complex type

  11. Click the show schema index view Show schema index view button in the upper left of the XML Schema Editor to return to the schema.
  12. In the XML Schema Editor, create the complex type CustomerType for the schema:
    1. Click the Design tab.
    2. In the drop-down menu for the View: options select Detailed.
    3. In the Types section, right-click the section and select Add Complex Type.
    4. Select your new complex type and click the Properties tab.
    5. In the Name field, type CustomerType.
    6. Double-click CustomerType to open the complex type for editing.
    7. Right-click inside the CustomerType section and select Add Sequence.
    8. Create the element DisplayName of type string for the CustomerType sequence:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type DisplayName.
      4. In the Type field, select string.
      5. In the minOccurs field, select 0.
      6. In the maxOccurs field, select 1.
    9. Repeat substep h for the elements ParentOrganization, ProfileType, and PreferredCurrency.
    10. Create the element Store of type integer for the CustomerType sequence:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type Store.
      4. In the Type field, select int.
      5. In the minOccurs field, select 0.
      6. In the maxOccurs field, select 1.
    11. Repeat substep j for the element PreferredLanguage.
    12. Create the element Authentication for the CustomerType sequence. The element Authentication has a user defined complex type:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type Authentication.
      4. In the Type field, select Browse....
      5. In the Set Type dialog, select AuthenticationType; click OK.
      6. In the minOccurs field, select 0.
      7. In the maxOccurs field, select 1.
    13. Create the element Contact for the CustomerType sequence. The element Contact has a user defined complex type:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type Contact.
      4. In the Type field, select Browse....
      5. In the Set Type dialog, select ContactType; click OK.
      6. In the minOccurs field, select 0.
      7. In the maxOccurs field, select 1.
    14. Create the element Demographics for the CustomerType sequence. The element CustomerDemographicsType has a user defined complex type:
      1. Right-click the sequence and select Add Element.
      2. Select the new element and click the Properties tab.
      3. In the Name field, type Demographics.
      4. In the Type field, select Browse....
      5. In the Set Type dialog, select CustomerDemographicsType; click OK.
      6. In the minOccurs field, select 0.
      7. In the maxOccurs field, select 1.
    15. Ensure that your design for the complex type CustomerType resembles the following screen capture:

      This screen capture shows the CustomerType complex type

  13. Click the show schema index view Show schema index view button in the upper left of the XML Schema Editor to return to the schema.
  14. In the XML Schema Editor, create the element Customer type for the schema:
    1. Click the Design tab.
    2. In the drop-down menu for the View: options select Detailed.
    3. In the Elements section, right-click the section and select Add Element.
    4. Select your new element and click the Properties tab.
    5. In the Name field, type Customer.
    6. In the Type field, select Browse....
    7. In the Set Type dialog, select CustomerType; click OK.
    8. Ensure that your design for the schema Customer.xsd resembles the following screen capture:

      This screen capture shows the ContactType complex type

  15. Save your work and close the XML Schema Editor.