JAX-RPC Client Programming mode has the following three kinds
Ø Static stub (statically client stub invocation)
Ø Dynamic Proxy (partially active proxy invocation)
Ø Dynamic invocation Interface (DII) (dynamically calling Interface)
Here are a few of the three modes:
1. Static stub
the WSDL Document of The service description is first generated by the mapping transformation to generate the Java stub of the client
then instantiate the locator instance of the service
Obtaining an instance of a service client through loacator
to invoke a service with a client instance
The following is an example of a weather service client call
Package itso.test;
Import java.io.*;
Import java.util.*;
Import itso.test.*;
public class Weatherforecastclient {
public static void Main (String [] args) {
try{
Weatherforecastservicelocator WSL = new Weatherforecastservicelocator ();
Weatherforecastservice ws = (weatherforecastservice) wsl.getweather ();
String temperature = Ws.gettemperature ();
SYSTEM.OUT.PRINTLN (temperature);
System.out.println ("Weatherforecastclient completed");
catch (Exception e) {
E.printstacktrace ();
}
}
}
2. Dynamic Proxy
with Static stub The difference is that you can specify the generated client instance, such as the weather forecast client above can be changed to:
Import Javax.xml.namespace.QName;
import java.io. * ;
import java.util. * ;
public class weatherforecastdynamicproxyclient ... {
public static void Main (String [] args) ... {
try... {
weatherforecastservicelocator wsl = New weatherforecastservicelocator ();
qname qn = new qname ( ) http://www.somewhere.com " , " Weatherforecast " );
weatherforecast ws = (weatherforecast)
Wsl.getport (qn,weatherforecast. class );
string temperature = ws.gettemperature ();
SYSTEM.OUT.PRINTLN (temperature);
System.out.println ( " dynamicproxyjavaclient completed " } catch ( Exception e)... {
E.printstacktrace ();
}
}
}
In this way, when the service changes, the client can also follow the change
3.
1. Dynamic Invocation Interface
The dynamic invocation interface pattern can be based on the service's WSDL changes and the client changes.
The comparison of the three can be summarized into the following table: