Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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 step-by-step guide to install VisualVM launcher in eclipse.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

914 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

15 Experts available now in Live!

Get 1:1 Help Now