This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Dynamic Proxy Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Dynamic Proxy Client" Watch "Dynamic Proxy Client" New topic
Author

Dynamic Proxy Client

Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
Hello MZ and other folks,
I have a question regarding dynamic proxy client. I have gotten stuck at the line where it says the following: (this line is copied from MZ's note)-


How do you get an access to HelloIF? Without an access to it, the code can't even compile. I know we can generate this stub from WSDL, but wouldn't that be similar to stub-based client? It would great if someone can explain to me this concept of getting access to HelloIF dynamically?

Thanks,
B
Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
There is a difference with which you get the service implementation( i.e class implementing the service interface and not the impl of end point interface)

In Static Stub
The class which implements Stub is vendor specific and we get the Port from that class

Where as in dynamic, we use service class (default implementation )is used to get the port (implementation class instance) to call the webservice method on it..

Hope i am clear. If not reply back, we can discuss.


SCJP 1.4 SCWCD 1.4 SCDJWS 1.4
Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
All I am asking is how do you get the HelloIF for a client to use? do you get it generated by webservice tools using WSDL?
Thanks.
ruijin yang
Ranch Hand

Joined: Apr 29, 2001
Posts: 96
Originally posted by Brian Smith:
All I am asking is how do you get the HelloIF for a client to use? do you get it generated by webservice tools using WSDL?
Thanks.


hey,

Hope this help(from www.xyzws.com):

1) Generated stub: Both Interface (WSDL) and implementation (stub) are created at compile time
2) Dynamic proxies: Interface (WSDL) is created at compile time while implementation (dynamic
proxy) created at runtime
3) Dynamic invocation interface (DII): Both interface (WSDL) and implementation are created at
runtime


SUN Certified Business Component Developer Java EE Platform 5 (2008)<br />SUN Certified Developer for Java Web Services (2007)<br />IBM WebSphere Portal V5.1 Application Development (2006)<br />SUN Certified Web Component Developer (2001)<br />SUN Certified Java 2 Programmer (2001)
Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
I completely understand all the theoritical aspects that you guys are saying here. Now here's what I am asking about. The following codes are taken from Mikalai Zaikin's notes which is a great notes.

This is an example of a Dynamic Proxy Client


Now look at this code line in bold. In order for this code to compile, there must exist HelloIF . My question is, how do we get this? do we generate it from WSDS at compile time as we NEED this for this code to compile. We can't wait until run time? Am I making sense here or I am missing something?
Thanks,
BR
ruijin yang
Ranch Hand

Joined: Apr 29, 2001
Posts: 96
Hi,
The following is from www.xyzws.com. I suggest you go to this website and read JAX-RPC section, you will understand.

Steps of coding and building Dynamic Proxy Client
1. Generate Service Endpoint Interface Class
1) runs wscompile with the -import option
2) reads the wsdl file provided by the Web service and generates the service endpoint interface class
2. Create Client Code
1. Creates a Service object
Service helloService = serviceFactory.createService(helloWsdlUrl,
new QName(nameSpaceUri, serviceName));
1) Service object is a factory for proxies
2) Service object itself is created from ServiceFactory object
3) Parameters of createService()
4) URL of the WSDL file
5) QName object
2. Create a proxy with a type of the service endpoint interface
dynamicproxy.HelloIF myProxy = (dynamicproxy.HelloIF)helloService.getPort(
new QName(nameSpaceUri,portName),
dynamicproxy.HelloIF.class);
1) HelloIF.class is generated by wscompile (at compile time)
2) The port name (HelloIFPort) is specified by the WSDL file
3. Compile Client Code with Service Endpoint Interface class CLASSPATH
4. Package Client to a jar file with SEI class.
[ March 06, 2007: Message edited by: ruijin yang ]
Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
You're awesome, Ruijin ! This is what I was looking for. Thanks for taking your time to explain these steps. I wanted to reinforce my understanding that HelloIF is generated by wscompile at compile time!

Originally posted by ruijin yang:

dynamicproxy.HelloIF myProxy = (dynamicproxy.HelloIF)helloService.getPort(
new QName(nameSpaceUri,portName),
dynamicproxy.HelloIF.class);
1) HelloIF.class is generated by wscompile (at compile time)
2) The port name (HelloIFPort) is specified by the WSDL file
3. Compile Client Code with Service Endpoint Interface class CLASSPATH
4. Package Client to a jar file with SEI class.


I appreciate your help!
Thank you,
Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
Yes, really useful.
vasu venki
Greenhorn

Joined: Oct 05, 2005
Posts: 19
yes really very useful ruijin


SCJP:70%<br />SCWCD:86%<br />SCBCD:90%<br />scdjws:98%<br />OCA<br />Nothing is impossible.Try and try until you achieve it.<br /> <br />Interstesigning and developing web Components
 
Consider Paul's rocket mass heater.
 
subject: Dynamic Proxy Client