Home arrow SOAP & Web Services arrow Page 3 - Use collection types with SOAP and JAX-RPC

Listing 3. The CustomerService class using a simple array. - Web Services

This article introduces a couple of techniques that you can use to build interoperable Web services that take and return object collections. This is the first of a series of articles covering this subject. Future articles will cover more detailed scenarios. (This intermediate-level article was first published by IBM developerWorks, May 28, 2004, at http://www.ibm.com/developerWorks).

TABLE OF CONTENTS:
  1. Use collection types with SOAP and JAX-RPC
  2. Listing 2. The generated XML Schema for the CustomerService class.
  3. Listing 3. The CustomerService class using a simple array.
  4. Create a wrapper interface
  5. Resources
By: developerWorks
Rating: starstarstarstarstar / 5
December 22, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

public class TheCustomerService {
  public Customer[] getCustomers(String queryString) {
    Customer customer1, customer2;
    /* ... retrieve customers for query ... */
    /* create an array large enough to hold the result set */
    Customer[] customers = new Customer[2];
    /* iterate over the result set assigning to the array */
    customers[0] = customer1;
    customers[1] = customer2;
    return customers;
  }
}

As you can see, we have replaced the LinkedList with an array of type Customer. Listing 4 shows the resulting XML Schema in the WSDL definition:

Listing 4. The updated XML Schema for the CustomerService class.

<schema elementFormDefault="qualified"
  targetNamespace=http://pack
  xmlns=http://www.w3.org/2001/XMLSchema
  xmlns:apachesoap="http://xml.apache.org/xml-soap"
  xmlns:impl="http://pack" xmlns:intf="http://pack"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <element name="getCustomers">
    <complexType>
      <sequence>
        <element name="queryString"
            nillable="true"
            type="xsd:string"/>
      </sequence>
    </complexType>
  </element>
  <complexType name="Customer">
    <sequence>
      <element name="customerID"
          nillable="true"
          type="xsd:string"/>
    </sequence>
  </complexType>
  <element name="getCustomersResponse">
    <complexType>
      <sequence>
        <element maxOccurs="unbounded"
          name="getCustomersReturn"
          type="impl:Customer"/>
      </sequence>
    </complexType>
  </element>
</schema>


This resulting schema definition and the SOAP message that is generated for this service are language-neutral and follow the WS-I Basic Profile.



 
 
>>> More SOAP & Web Services Articles          >>> More By developerWorks
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

SOAP & WEB SERVICES ARTICLES

- Google Play Launched to Revive Brand
- Google Releases Preview of its Cloud SQL Ser...
- Microsoft and Amazon Team Up for the Cloud
- GoDaddy Joining the Cloud
- Amazon EBS Outage Challenges Cloud Supporters
- Dynamic Data Analysis on the Web-a Design Ap...
- Use collection types with SOAP and JAX-RPC
- Blogging Away To Glory (A bBlog Primer)
- Introduction to Service Oriented Architectur...
- Connecting Smart Devices on the Internet
- An Embeddable Standards Compliant Web Servic...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: