• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

STUB, Dynamic Proxy, DII

 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between STUB, Dynamic Proxy and DII??, Can anyone exaplein indeatil the advantages/ diadvantages with respect to each other.?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a nutshell speaking ,the difference between Dynamic Proxy and Generated Stub is the implementation of Remote Interface,since the Remote Interface of Dynamic Proxy is generated dynamically at runtime.
(Remember that Generated Stub is generated during deployment time by JAX-RPC compiler ,which generates both remote interface (called Endpoint Interface) and stub ,which implements corresponding remote interface.)
The Stub of Dynamic Proxy is generated while "javax.xml.rpc.Service.getPort()" was executed.
=============================================================
DII (It's acronyms for "Dynamic Invocation Interface") can invoke web service operation without using remote interface or stub.
Because you can directly get a reference to the web service by using "javax.xml.rpc.Service.createCall()".
(The things you should know are either "port" name or "operation" name.)
QName portName = new QName("http://blablabla","Foo");
Call call=createCall(portName);
Object[] inputs = new Object(1);
String name=(String)call.invoke(inputs);

==================================================
Worawisut P.
[ May 10, 2004: Message edited by: Worawisut P. ]
[ May 10, 2004: Message edited by: Worawisut P. ]
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andy,
There is a pretty comprehensive comparison table in WebServices BluePrints Chapter 4. Section 4.6.1.4 (Page 141). That should answer many questions.
Dushy
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a late add, feel free to add any updates.....

Web Services can be invoked in three different ways

1. Using Generated Stub
2. Using Dynamic Proxies
3. Using Dynamic Invocation Interface (DII)

In Generated Stub, client depends on generated interfaces of service (last block in WSDL) and portType (business definition), and their implemented stub & proxy classes. The code need to create the specific service from generated stub, and get its specific portType object from it. Then call business method

In Dynamic Invocation Interface, client does not care about the generated service stub, but creates the framework “Service” object by passing the actual service name. From the framework Service object, the client gets the generated portType object by passing the portType name. Then call the business method on the portType object

In Dynamic Invocation Interface (DII), the client does not use any generated class. It creates a Service object, and creates a Call object out of it. To the call object, client sets the name of Service, name of portType and invoke it by passing an Object array of parameters.

In short, Generated Stub uses all generated classes
Dynamic Proxy uses only generated portType
DII does not use any generated classes

Example code below (using Axis)



package com.test.webmain;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.naming.NamingException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.client.ServiceFactory;

import com.test.HelloTest;
import com.test.HelloTestService;
import com.test.HelloTestServiceLocator;

public class WebMain {

/**
* @param args
* @throws ServiceException
* @throws MalformedURLException
* @throws RemoteException
* @throws NamingException
*/
public static void main(String[] args) throws ServiceException,
MalformedURLException, RemoteException, NamingException {

//Accessing through stub
HelloTestService service1 = new HelloTestServiceLocator();
HelloTest test = service1.getHelloTest();
System.out.println(test.sayHello("Unni"));

//Dynamic Proxy
try {

ServiceFactory serviceFactory = (ServiceFactory) ServiceFactory.newInstance();
System.out.println("Got the service factory");

String endpoint = "http://localhost:8080/TestWS/services/HelloTest?wsdl";
URL wsdlURL = new URL(endpoint);

Service service = (Service) serviceFactory.createService(
wsdlURL, new QName("http://test.com", "HelloTestService"));
System.out.println("Got the service: " + service);

HelloTest test1 = (HelloTest) service.getPort(
new QName("http://test.com", "HelloTest"), HelloTest.class);

System.out.println("Sent 'Unni!', got '" + test1.sayHello("Unni") + "'");
} catch (Exception e) {
System.err.println(e.toString());
}

//Dynamic Invocation Interface
try {
String endpoint = "http://localhost:8080/TestWS/services/HelloTest";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("sayHello"));
String ret = (String) call.invoke(new Object[] { "Unni" });
System.out.println("Sent 'Unni!', got '" + ret + "'");
} catch (Exception e) {
System.err.println(e.toString());
}
}
}

 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic