...
- Start with a WSDL contract and generate Java objects to implement the service.
- Start with a Java object and service enable it using annotations.
For new development the preferred path is to design your services in WSDL and then generate the code to implement them. This approach enforces the concept that a service is an abstract entity that is implementation neutral. It also means you can spend more time working out the exact interface your service requires before you start coding.
However, there are many cases where you may need to service enable an existing application. While JAX-WS eases the process, it does require that you make some changes to source code of your application. You will need to add annotations to the source. It also requires that you migrate your code to Java 5.0.
...
Code Block | ||
---|---|---|
| ||
package org.apache.cxf;
import java.util.*;
public class StockQuoteReporter implements QuoteReporter
{
...
public Quote getQuote(String ticker)
{
Quote retVal = new Quote();
retVal.setID(ticker);
retVal.setVal(Board.check(ticker));[1]
Date retDate = new Date();
retVal.setTime(retDate.toString());
return(retVal);
}
}
|
...
Code Block | ||
---|---|---|
| ||
package org.apache.cxf;
import javax.jws.*;
@WebService(endpointInterface="org.apache.cxf.quoteReporter",
targetNamespace="http://cxf.apache.org",
portName="StockQuotePort",
serviceName="StockQuoteReporter",
)
public class StockQuoteReporter implements QuoteReporter
{
public Quote getQuote(String ticker)
{
...
}
}
|
...
Tip | ||
---|---|---|
| ||
The more details you provide in the SEI, the SEIthe easier it will be for developers to implement applications that can use the functionality it defines. It will also provide for better generated WSDL contracts. |
...