Before you begin
If you have used Web services based on Apache SOAP and now want to develop and implement Web services based on the Web Services for Java 2 platform, Enterprise Edition (J2EE) specification, you need to migrate your Version 4.0.x and 5.0.x client applications.
Why and when to perform this task
To migrate these client applications according to the Web Services for J2EE standards:Steps for this task
javax.xml.rpc.Service service = ServiceFactory.newInstance().createService(new QName(""));in JAX-RPC.
org.apache.soap.rpc.Call call = new org.apache.soap.rpc.Call ()in Apache SOAP.
An instance of the call object is created by
java.xml.rpc.Call call = service.createCall();in JAX-RPC.
call.invoke: call.invoke("http://...", "");in Apache SOAP.
The setTargetEndpointAddress method is used as a parameter to
call.setTargetEndpointAddress("http://...");in JAX-RPC.
Apache SOAP has a setTargetObjectURI method on the call object that contains routing information for the request. JAX-RPC has no equivalent method. The information in the targetObjectURI is included in the targetEndpoint URI for JAX-RPC.
call.setMethodName("opName");in Apache SOAP.
The setOperationName method, which accepts a QName instead of a String parameter, is used in JAX-RPC as follows:
call.setOperationName(new javax.xml.namespace.Qname("namespace", "opName"));
call.setEncodingStyleURI(org.apache.soap.Constants.NS_URI_SOAP_ENC);in Apache SOAP.
The encoding style is set by a property of the call object
call.setProperty(javax.xml.rpc.Call.ENCODINGSTYLE_URI_PROPERTY, "http://schemas. xmlsoap.org/soap/encoding/");in JAX-RPC.
Vector params = new Vector (); params.addElement (new org.apache.soap.rpc.Parameter(name, type, value, encodingURI)); // repeat for additional parameters... call.setParams (params);
For JAX-RPC, the call object is configured with parameter names and types without providing their values, for example:
call.addParameter(name, xmlType, mode); // repeat for additional parameters call.setReturnType(type);Where
org.apache.soap.Response resp = call.invoke(endpointURI, "");in Apache SOAP.
The parameter values are collected into an array and passed to call.invoke as follows:
Object resp = call.invoke(new Object[] {parm1, parm2,...});in JAX-RPC.
if resp.generatedFault then { org.apache.soap.Fault f = resp.getFault; f.getFaultCode(); f.getFaultString(); }in Apache SOAP.
A java.rmi.RemoteException is thrown in JAX-RPC if a SOAP fault occurs on the invocation.
try { ... call.invoke(...) } catch (java.rmi.RemoteException) ...
Parameter result = resp.getReturnValue(); return result.getValue();
In JAX-RPC, the result of invoke is the returned object when no exception is thrown:
Object result = call.invoke(...); ... return result;
What to do next
Developing a Web services client based on Web Services for J2EE.