Solved

What is a Java Proxy class and where do you use it?

Posted on 2007-03-27
4
218 Views
Last Modified: 2010-03-31
Can someone tell me what a Java Proxy Class does and where you use it? How do you use it when you have a non-standard wsdl file, one that wasn't auto-generated?
0
Comment
Question by:yankeebushsoftware
  • 2
4 Comments
 
LVL 10

Expert Comment

by:ADSLMark
ID: 18803701
That is just a stub to communicate with the outside world. It can be automatically generated from your WSDL. You can use wsdl2java for that.
If that fails, you can always write the code yourself, or let wsdl2java generate some part of it and add your own later on.

Here is an example on wsdl2java:
http://ws.apache.org/axis/java/user-guide.html#WSDL2JavaBuildingStubsSkeletonsAndDataTypesFromWSDL

Mark
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 18803750
>> do you use it when you have a non-standard wsdl file, one that wasn't auto-generated?

For a non standard WSDL, it means it would be proprietary.

A proxy (in any programming language) basically implements the Proxy design pattern. You use it to call an object you don't have access to directly, and you access it like a local object but it results in calls to the remote object and handles the complications for you - like connecting, passing parameters, serialization/ de-serialization etc:

http://en.wikipedia.org/wiki/Proxy_pattern
0
 
LVL 26

Accepted Solution

by:
ksivananth earned 500 total points
ID: 18804266
you can think of the proxy instance of the internet proxy server - where in all the nodes request the proxy server for the internet requests. In java, all the calls are made the proxy instance and the proxy instance knows how to server the request.

For e.g., you have an interface may be thing of a stub,

interface myinterface{
  void method1( int a, int b ) ;

  void method2( String a, String b ) ;

//more method follows,
................
................
................
}

but the implementation reside on some other system, how you will make call to the system?

1. one way of doing the old fashion - text notation...
2. use the proxy pattern

class myinvocationhandler extends InvocationHandler{
    public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable{
         // all the myinterface interface calls are forwarded here using reflection...
         //your implementation to request the server here
    }
}

//here is how you make call to the myservice interface

myinterface service = return Proxy.newProxyInstance( myinterface.class.getClassLoader(), new Class[]{ myinterface.class }, new myinvocationhandler() ) ;

service.method1( 0, 2 ) ;
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 18804562
Might've been a split....
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Python 2.7 - French characters 6 47
array11 challenge 16 52
countHi2 challenge 7 44
word0 challenge 3 58
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now