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.
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?
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)
Joined: Oct 26, 2002
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
Joined: Apr 29, 2001
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 ]
Joined: Oct 26, 2002
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.