Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 161
Java: The Public Class Main 4 66
Java program running SQL query 5 67
Setup GlassFish 4 55
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
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 viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

759 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