Generic mode for JAX-RPC service clients

Source: Internet
Author: User
Tags stub wsdl

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:



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.