[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlrpc-user
Subject:    RE: Newbie- any java samples
From:       Rachel Primrose <rprimrose () tollnz ! co ! nz>
Date:       2005-08-18 21:14:47
Message-ID: 102F3E6C89C4A04BBFFB37EE614BBFC902127BD8 () kinglet ! tranzrail ! co ! n
[Download RAW message or body]

http://ws.apache.org/xmlrpc/types.html

This url shows the java types that can be passed using XML-RPC. 
All objects passed must be one of these types, including objects stored
within other objects.
E.g A vector of strings is OK, however a vector of nodes is not.

http://ws.apache.org/xmlrpc/server.html

This url has some examples about server side implementation.  Try the "Using
the Built-in HTTP Server" section.
webserver.addHandler ("examples", someHandler); is important.  someHandler
is a class that you must create.  Methods to be used by xmlrpc must have a
return value in the allowed types.  They cannot return null.

Try this code:

Create a class called TestHandler.class with one method, 

public String testMethod(String inString)
{
	return "hello world.  you passed in: "+inString;
}

Give it an empty constructor.

Create another test class to run, with this main method:

public static void main(String[] args)
{
	try
	{
		TestHandler testHandler=new TestHandler();
		WebServer webserver = new WebServer (10001);
		webserver.addHandler ("TestHandler", testHandler); 
		webserver.start();
		XmlRpcClientLite client=new
XmlRpcClientLite("localhost",10001);
		Vector parameters=new Vector();
		parameters.add("hello xmlrpc server!");
	
System.out.println(client.execute("TestHandler.testMethod",parameters));
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}

There might be errors in this code, i didn't have time to test it, but it's
a start.  


-----Original Message-----
From: Nookala, Sridevi (Sridevi) [mailto:snookala@lucent.com]
Sent: Friday, 19 August 2005 6:23 a.m.
To: 'xmlrpc-user@ws.apache.org'
Subject: Newbie- any java samples


Hi,

I am newbies to XML-RPC web services. Can anybody point me where i could get
java examples for xml-rpc.

Especially how to pass java objects using XmlRpcClient synchronous calls

-thx,
Sri

[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: Newbie- any java samples</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2><A HREF="http://ws.apache.org/xmlrpc/types.html" \
TARGET="_blank">http://ws.apache.org/xmlrpc/types.html</A></FONT> </P>

<P><FONT SIZE=2>This url shows the java types that can be passed using XML-RPC. \
</FONT> <BR><FONT SIZE=2>All objects passed must be one of these types, including \
objects stored within other objects.</FONT> <BR><FONT SIZE=2>E.g A vector of strings \
is OK, however a vector of nodes is not.</FONT> </P>

<P><FONT SIZE=2><A HREF="http://ws.apache.org/xmlrpc/server.html" \
TARGET="_blank">http://ws.apache.org/xmlrpc/server.html</A></FONT> </P>

<P><FONT SIZE=2>This url has some examples about server side implementation.&nbsp; \
Try the &quot;Using the Built-in HTTP Server&quot; section.</FONT> <BR><FONT \
SIZE=2>webserver.addHandler (&quot;examples&quot;, someHandler); is important.&nbsp; \
someHandler is a class that you must create.&nbsp; Methods to be used by xmlrpc must \
have a return value in the allowed types.&nbsp; They cannot return null.</FONT></P>

<P><FONT SIZE=2>Try this code:</FONT>
</P>

<P><FONT SIZE=2>Create a class called TestHandler.class with one method, </FONT>
</P>

<P><FONT SIZE=2>public String testMethod(String inString)</FONT>
<BR><FONT SIZE=2>{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>return &quot;hello \
world.&nbsp; you passed in: &quot;+inString;</FONT> <BR><FONT SIZE=2>}</FONT>
</P>

<P><FONT SIZE=2>Give it an empty constructor.</FONT>
</P>

<P><FONT SIZE=2>Create another test class to run, with this main method:</FONT>
</P>

<P><FONT SIZE=2>public static void main(String[] args)</FONT>
<BR><FONT SIZE=2>{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>try</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>TestHandler testHandler=new \
TestHandler();</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>WebServer webserver = new \
WebServer (10001);</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>webserver.addHandler \
(&quot;TestHandler&quot;, testHandler); </FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>webserver.start();</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>XmlRpcClientLite client=new \
XmlRpcClientLite(&quot;localhost&quot;,10001);</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>Vector parameters=new \
Vector();</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>parameters.add(&quot;hello \
xmlrpc server!&quot;);</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT \
SIZE=2>System.out.println(client.execute(&quot;TestHandler.testMethod&quot;,parameters));</FONT>
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>}</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>catch(Exception e)</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>e.printStackTrace();</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>}</FONT> <BR><FONT \
SIZE=2>}</FONT> </P>

<P><FONT SIZE=2>There might be errors in this code, i didn't have time to test it, \
but it's a start.&nbsp; </FONT> </P>
<BR>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Nookala, Sridevi (Sridevi) [<A \
HREF="mailto:snookala@lucent.com">mailto:snookala@lucent.com</A>]</FONT> <BR><FONT \
SIZE=2>Sent: Friday, 19 August 2005 6:23 a.m.</FONT> <BR><FONT SIZE=2>To: \
'xmlrpc-user@ws.apache.org'</FONT> <BR><FONT SIZE=2>Subject: Newbie- any java \
samples</FONT> </P>
<BR>

<P><FONT SIZE=2>Hi,</FONT>
</P>

<P><FONT SIZE=2>I am newbies to XML-RPC web services. Can anybody point me where i \
could get java examples for xml-rpc.</FONT> </P>

<P><FONT SIZE=2>Especially how to pass java objects using XmlRpcClient synchronous \
calls</FONT> </P>

<P><FONT SIZE=2>-thx,</FONT>
<BR><FONT SIZE=2>Sri</FONT>
</P>

</BODY>
</HTML>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic