Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Developing a Service using JAX-WS

...

#Example2 shows a simple SEI for a stock updating service.

Anchor
Example2
Example2

Code Block
titleExample2:Simple SEI
package org.apache.cxf;

public interface quoteReporter
{
  public Quote getQuote(String ticker);
}

...

Code Block
titleExample4:Interface with the @WebService Annotation
package com.iona.demo;

import javax.jws.*;

@WebService(name="quoteUpdater",
            targetNamespace="http:\\cxf.apache.org",
	    serviceName="updateQuoteService",
            wsdlLocation="http:\\cxf.apache.org\quoteExampleService?wsdl",
            portName="updateQuotePort")
public interface quoteReporter
{
  public Quote getQuote(@WebParam(name="ticker") String ticker);
}

The @WebService annotation in #Example4 does the following:

  1. Specifies that the value of the name attribute of the wsdl:portType element defining the service interface is quoteUpdater.
  2. Specifies that the target namespace of the service is {{http:
    cxf.apache.org}}.
  3. Specifies that the value of the name of the wsdl:service element defining the published service is updateQuoteService.
  4. Specifies that the service will publish its WSDL contract at http:\\cxf.apache.org\quoteExampleService?wsdl.
  5. Specifies that the value of the name attribute of the wsdl:port element defining the endpoint exposing the service is updateQuotePort.

The @WebParam annotation is necessary as java interfaces do not store the Parameter name in the .class file. So if you leave out the annotation your parameter will be named arg0.

Annotating the service implementation

...

#Example6 shows an SEI that uses rpc/literal SOAP messages.

Anchor
Example6
Example6

Code Block
titleExample6:Specifying an RPC/LITERAL SOAP Binding
package org.eric.demo;

import javax.jws.*;
import javax.jws.soap.*;
import javax.jws.soap.SOAPBinding.*;

@WebService(name="quoteReporter")
@SOAPBinding(style=Style.RPC, use=Use.LITERAL)
public interface quoteReporter
{
  ...
}

...