axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ashish Varan" <ashish_va...@NextLinx.com>
Subject RE: RE: Passing user-defined objects between Java server (Apache AXIS) and a C# (:Net) Client
Date Wed, 26 May 2004 19:46:26 GMT
With this you can pass alomost anything you want ( all axis datatypes -
key value in hashtable ) and don't need to do any more R & D.
If you add a handler key ( a class that handles the request and returns
hashtable ( server side ) , you may write 1000 web service call in 7
days !!!
( w/o writing any additional line in framework )
Try a string key and vector having string values etc.

Client Call
________________________________________________
Object[] params = new Object[2];
params[0] = new RPCParam("parms", your hashtable instance);
params[1] = new RPCParam("parms2","anyOtherParam");

//you can add as many params you want 

Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL("your url"));
HashMap h = (HashMap) call.invoke("myservice", params );

return new Hashtable(h);

Server Side
________________________________________________
class MyServiceProvider{
public static Hashtable myservice(Hashtable h, String anyOtherParam){
 
 //you get your hashtable here after the call
 //process the request and return hashtable

//optional  get the HTTP Request if you want to get other params as well
MessageContext mc = MessageContext.getCurrentContext();
ServletContext sc =
((HttpServlet) mc.getProperty(HTTPConstants.MC_HTTP_SERVLET))
.getServletContext();
//get the attributes of the request object that will be used to
HttpServletRequest request =
(HttpServletRequest) mc.getProperty(
HTTPConstants.MC_HTTP_SERVLETREQUEST);

  retyrn hashtable;
}
}
_________________________________________________
Axis server condig.wsdd file

<service name="MyServiceProvider" provider="java:RPC">
  <parameter name="allowedMethods" value="myservice"/>
  <parameter name="className" value="mypackage.MyServiceProvider"/>
 </service>

HTH
Ashish
Senior Software Enginner ( NextLinx Corp )



-----Original Message-----
From: NITESH GUPTA [mailto:nitesh.gupta@epfl.ch] 
Sent: Wednesday, May 26, 2004 11:30 AM
To: axis-user@ws.apache.org
Subject: Re: RE: Passing user-defined objects between Java server
(Apache AXIS) and a C# (:Net) Client


Hi Ashish,

Thanks for the mail. Since I'm new to this sort of stuff its a bit hard
for me to figure out how to do it with hash tables and vectors. It would
be great if you could givem some directions about this or an example. 

Thanks a lot for the help,

Nitesh

----- Original Message -----
From: Ashish Varan <ashish_varan@NextLinx.com>
Date: Wednesday, May 26, 2004 5:15 pm
Subject: RE: Passing user-defined objects between Java server (Apache
AXIS) and a C# (:Net) Client

> Why don't u put all this in Hashtable. A few lines of code can pass
> anthing. Vector is suppored, so you can pass vector of all supported
> datatypes.
> 
> 
> -----Original Message-----
> From: NITESH GUPTA [nitesh.gupta@epfl.ch] 
> Sent: Tuesday, May 25, 2004 11:06 AM
> To: axis-user@ws.apache.org
> Subject: Passing user-defined objects between Java server (Apache 
> AXIS)and a C# (:Net) Client
> 
> 
> Hi,
> 
> I'm new to SOAP and AXIS and want some help. 
> 
> I am trying to implement a simple hello world type of example on a PDA
> which has a C# .Net webservice client and  a java server on Apache 
> AXISserver running on some machine.  
> 
> Till now I have been able to pass objects like int, strings and arrays
> of strings but am not able to figure out how to pass user-defined
> objects. 
> 
> I have deployed the server in form of a .jws using Tomcat server
> 
> this is what the server side code looks like: 
> 
> public class HelloServer
> {
> 	public String sayHelloTo(String name)
> 	{
>          System.out.println("sayHelloTo(String name)");
>          return "Hello " + name + ", How are you doing?";      
> 	}
> 
> 	public String sayHelloTo(String[] names)
> 	{
>        	String reply = "";
>        	for(int i = 0; i < names.length; i++)
>        	{
>                	System.out.println("sayHelloTo(String name)");
>                	reply += "Hello " + names[i] + ", How are you
> doing? \n";
>        	}
>        	return reply;
> 	}
> 
> 	public int add(int num1, int num2)
> 	{
>        	return num1 + num2;
> 	}
> }	
> 
> I want to pass a user-defined object  . some thing like :
> 
> public class HelloUser {
> 	int userID;
> 	String userName;
> 	String[] userAdd; 
> }
> 
> If someone can guide me about how to do this, the help would be really
> appriciated.
> 
> Thanks,
> Nitesh
> 
> 


Mime
View raw message