Solved

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

Posted on 2007-03-27
4
222 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: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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
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…

777 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