Previous Next vertical dots separating previous/next from contents/index/pdf

Web Service Development Starting Points

This topic describes three different starting points for developing web services:

Starting from a WSDL

In this approach to developing a web service, you begin by defining the WSDL file (or getting a pre-existing one). This is the web service contract that defines how the web service communicates with clients, including the data types conveyed, the available methods, and the protocols and message formats used. Hence, this approach to web service development is sometimes called "contract first" or "top down" development. Note that you can only use JAX-RPC types when using this development approach, XMLBean types are not available.

To generate a web service from a WSDL:

  1. Import the WSDL into a web service project.
  2. In the Package Explorer or Navigator view, right-click the WSDL and select Web Services > Generate Web Service.

Two artifacts will be created: a web service implementation class and a JAR file. The web service class will contain the web methods described by the WSDL (the publicly accessible methods and callbacks) without any method bodies. The developer must fill in the web service's implementation details. The JAR file contains a web service interface class and types referenced in the original WSDL and is located in the project's WEB-INF/lib directory.

For example the generated web service implementation class will resemble the following:

public class MailingListServiceImpl implements MailingListService {
  public MailingListServiceImpl() {

  public java.lang.String getCustomers() {
    //replace with your impl here
     return null;     

Notice that this class implements MailingListService, the interface file found in the generated JAR file.

The developer must fill in the method body for the method getCustomers().

Starting from an XML Schema

In this approach to developing a web service, you begin with an XML schema (XSD file) that defines XML data structures to be used as parameters and return types in the web service operations. XMLBean Java types are then automatically generated from the schema for use in your web service. This approach gives you the following benefit of a common set of data structures for all of the web services in a project or set of projects.

Once the XMLBean types are available, web service development proceeds according to the "Start with a Java Class" method described below.

To develop starting from an XML schema:

  1. Enable the XML beans builder facet on your web service project.
  2. Import the schema into the project's schema directory. (The schema directory is automatically created when the builder facet is added to the project.)

Schemas will be automatically compiled into XMLBeans, which you can use in your web service. The XMLBean types will be automatically re-compiled whenever the schemas in the schema directory are updated.

Note: You do not have to use the XML beans builder facet to create XMLBean types. Alternatively, you can generate a JAR by right-clicking any XSD or WSDL in the project and selecting Web Services > Generate Types JAR File. This will open the Types JAR File Generation Wizard, from which you can generate a JAR containing XMLBeans. Or, if you already have a JAR containing the XMLBean types, you can import it into the project and use those types in a web service. Neither of these options provide automatic updating of the XMLBean JAR when the original schema changes.

Available XMLBean types can be seen in the Navigator view (Window > Show View > Navigator) in the directory .xbean_src. The .xbean_src and .xbean_bin directories contain generated files that should never be directly edited.

The following example shows one way to incorporate XMLBean types into a web service. Suppose you import the following schema:

<xs:schema xmlns:xs="" xmlns:ws="" targetNamespace="" elementFormDefault="qualified">
    <xs:element name="applicant">
        <xs:complexType mixed="true">
            <xs:choice minOccurs="0" maxOccurs="1">
                <xs:element name="bankrupt" type="xs:boolean"/>
                <xs:element name="name_first" type="xs:string"/>
                <xs:element name="name_last" type="xs:string"/>
                <xs:element name="risk_estimate" type="xs:string"/>
                <xs:element name="score_info" type="ws:score_infoType"/>
</xs:choice> </xs:complexType> </xs:element> <xs:complexType name="score_infoType" mixed="true"> <xs:choice minOccurs="0" maxOccurs="1"> <xs:element name="credit_score" type="xs:short"/> </xs:choice> </xs:complexType> </xs:schema>

The corresponding generated XMLBean types are ApplicantDocument, ScoreInfoType, etc.

The following web service method uses the ApplicantDocument as an input parameter and performs a simple risk assessment calculation.

    public String getRiskEstimate(ApplicantDocument appDoc) {
        boolean bankrupt = appDoc.getApplicant().getBankrupt();
        short balanceRemain = appDoc.getApplicant().getBalanceRemaining();
        if (bankrupt == true && balanceRemain < 200)
        return appDoc.getApplicant().getRiskEstimate();

For detailed information about using XMLBeans see Using XMLBeans in the IDE.

Starting from a Java Class

In this approach, you develop a web service as a Java class. Methods become web service operations and method parameters and return types can be simple Java Beans. The Java class is annotated to indicate what methods should be exposed and to set other properties for the service. The following guidelines will help you utilize all of Workshop for WebLogic's web service features.

  1. Create a new web service class (File > New > Web Service) in an appropriate package within your web service project. To learn about Workshop for WebLogic projects, see Applications and Projects.
  2. All of the following steps can be accomplished using the web service Design View, a graphical editing environment for creating web services. For more information see Using Design View to Create Web Services.
  3. Add the methods your web service will expose and configure each method's parameters.
  4. Add any callbacks your web service will expose and configure each callback's parameters. To learn more about callbacks see Web Service Callbacks.
  5. Implement event handlers for relevant events from controls that the web service utilizes. To learn more about event handlers see Handling Control Events and Handling Web Service Callback Messages.
  6. Determine and configure the conversation phase of each method and callback. To learn more about conversations, see Designing Conversational Web Services.
  7. Determine and configure any buffered methods. To learn more about message buffers see Creating Buffered Web Services in the WebLogic Server documentation.
  8. Once your web service is complete, you can generate a WSDL file by right-clicking on the web service in the Package Explorer and selecting Web Services > Generate WSDL.

Related Topics

WSDL Files: Web Service Descriptions



Skip navigation bar   Back to Top