Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

As per JAX-RPC a Service Endpoint Interface must extend Remote. JAX-WS removes this condition and you can pretty much make a POJO class Web Service by just adding the @WebService annotation at the top of the class.

Code Block
borderStylesolid
titleJAX-RPC Converter SEIborderStylesolid
package org.apache.geronimo.samples.jaxrpc;

import java.math.BigDecimal;
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Converter extends Remote {
	
	public BigDecimal dollarToRupees(BigDecimal dollars) throws RemoteException;
	public BigDecimal rupeesToEuro(BigDecimal rupees) throws RemoteException;

}
Code Block
borderStylesolid
titleJAX-WS Converter SEIborderStylesolid
package org.apache.geronimo.samples.jaxrpc;

import java.math.BigDecimal;
import javax.jws.WebService

@WebService(name = "Converter", targetNamespace = "http://org.apache.geronimo.samples.jaxws")
public interface Converter {
	
	public BigDecimal dollarToRupees(BigDecimal dollars);
	public BigDecimal rupeesToEuro(BigDecimal rupees);

}

...

The following code samples demonstrate the difference between JAX-RPC and JAX-WS in client port lookup.

Code Block
borderStylesolid
titleJAX-RPC Converter ClientborderStylesolid

package org.apache.geronimo.samples.jaxrpc;

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ServiceException;

//a part of client
URL url = new URL("http://localhost:8080/jaxrpc-converter/converter?wsdl");
QName qname = new QName("http://org.apache.geronimo.samples.jaxrpc/","ConverterService");
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(url, qname);
Converter conv = (Converter) service.getPort(Converter.class);

Code Block
borderStylesolid
titleJAX-WS Converter ClientborderStylesolid

package org.apache.geronimo.samples.jaxrpc;

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;

//a part of client
URL url = new URL("http://localhost:8080/jaxrpc-converter/converter?wsdl");
QName qname = new QName("http://org.apache.geronimo.samples.jaxrpc/","ConverterService");
Service service = Service.create(url, qname);
Converter conv = (Converter) service.getPort(Converter.class);

...