Solved

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

Posted on 2007-03-27
4
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Mayank S
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:Mayank S
ID: 18804562
Might've been a split....
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Part One of the two-part Q&A series with MalwareTech.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

634 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