[prev in list] [next in list] [prev in thread] [next in thread]
List: xmlrpc-user
Subject: Re: <i4> and array type question,please help
From: rjoshi () dataarmor ! net
Date: 2005-11-10 15:14:20
Message-ID: 437360FC.5030703 () dataarmor ! net
[Download RAW message or body]
Hi Manav,
The only way I could think of doing this was to hack XmlRpcClient and
XmlRpcClientWorker classes.
In XmlRpcClientWorker.java do the following -
*1. declare a private variable*
private String xmlStr;
*2. decalre two methods*
public setXmlStr(String str)
{
this.xmlStr = str;
}
public String getXmlStr()
{
return this.xmlStr;
}
*3. In **XmlRpcClientWorker **hack the method (maybe on line 55)*
public Object execute(XmlRpcClientRequest xmlRpcRequest,
XmlRpcTransport transport)
throws XmlRpcException, XmlRpcClientException, IOException
{
long now = 0;
Object response = PROCESSING_ERROR_FLAG;
if (XmlRpc.debug)
{
now = System.currentTimeMillis();
}
try
{
byte[] request = requestProcessor.encodeRequestBytes
(xmlRpcRequest, responseProcessor.getEncoding());
/ *// ADD ONE LINE HERE*
*setXmlStr(new String(request));*
/
InputStream is = transport.sendXmlRpc(request);
response = responseProcessor.decodeResponse(is);
return response;
}
catch (IOException ioe)
{
throw ioe;
}
// more code bla bla
}
}
}
}
}
*4. In **XmlRpcClient **hack the method (maybe on line 187)*
public Object execute(XmlRpcClientRequest request, XmlRpcTransport
transport)
throws XmlRpcException, IOException
{
XmlRpcClientWorker worker = getWorker(false);
try
{
Object retval = worker.execute(request, transport);
/* // Get your XML String and use the way you want
String str = worker.getXmlStr();*/
return retval;
}
finally
{
releaseWorker(worker, false);
}
}
Thats All! (ofcourse you have to recompile the classes)
Its strange that there are no straightforward methods of getting the xml
string directly.
I am sending this mail to group coz it will be great to know if there IS
another way!
Manvendra Baghel wrote:
>hi Yixing
>
>I am new to XML RPC .Please can you tell how to view
>XML of XML-RPC request
>
>
>><array>
>> <data>
>> <value><i4>1404</i4></value>
>> <value><string>Something Here</string></value>
>> </data>
>></array>
>>
>>
>>
>
>Thanks in advance
>
>MANAV
>
>
>
>--- Yixing Ma <Yixing.Ma@interfacemgmt.net> wrote:
>
>
>
>>Hi,
>>
>>As I'm starting to use apache's XML-RPC java api, I
>>found couple of questions.
>>
>>1) The standard XML-RPC spec defines the array type
>>as something like:
>>
>>
>>
>**********************************************************************
>
>
>><array>
>> <data>
>> <value><i4>1404</i4></value>
>> <value><string>Something Here</string></value>
>> </data>
>></array>
>>
>>
>>
>***********************************************************************
>
>
>>But I was unable to put <i4> into the array by using
>>java Vector. I could only put <int></int> instead of
>><i4>. Also the <string></string> tag in red is
>>missing. The blank space was replaced by " " in
>>the generated XML.
>>
>>My code is:
>>**********************************
>>Vector v=new Vector(); *
>>v.add(new Integer("1404")); *
>>v.add("Something Here"); *
>>**********************************
>> The result XML is
>>
>>
>>
>**********************************************************************
>
>
>><array>
>> <data>
>> <value><int>1404</int></value>
>> <value>Something Here</value>
>> </data>
>></array>
>>
>>
>>
>**********************************************************************
>
>
>>Is there a way to produce the exact same XML as
>>XML-RPC defined by using apache's api?
>>
>>2) If I want to generate
>><array>
>> <data>
>> <value><i4>001404</i4></value>
>> </data>
>></array>
>>
>>as I want to preserve the zero before 1404. What
>>should I do?
>>
>>Best regards,
>>Yixing Ma
>>
>>
>>
>>
>>
>
>
>
>
>
>__________________________________
>Yahoo! Mail - PC Magazine Editors' Choice 2005
>http://mail.yahoo.com
>
>
>
--
Thanks,
Rahul Joshi
_________ 'Don't Even Think About Clicking Here' __________
<http://www.mindistortion.net/iwantyoursoul/?i_am=curse%20of%20samara>
[Attachment #3 (multipart/related)]
[Attachment #5 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Verdana">Hi Manav,<br>
<br>
The only way I could think of doing this was to hack </font></font><font
size="-1"><font face="Verdana">XmlRpcClient and </font></font><font
size="-1"><font face="Verdana">XmlRpcClientWorker classes.<br>
<br>
In </font></font><font size="-1"><font face="Verdana">XmlRpcClientWorker.java
do the following -<br>
<br>
<b>1. declare a private variable</b><br>
<br>
private String xmlStr;<br>
<br>
<b>2. decalre two methods</b><br>
<br>
public setXmlStr(String str)<br>
{<br>
this.xmlStr = str;<br>
}<br>
<br>
public String getXmlStr()<br>
{<br>
return this.xmlStr;<br>
}<br>
<br>
<b>3. In </b></font></font><b><font size="-1"><font face="Verdana">XmlRpcClientWorker
</font></font></b><font size="-1"><font face="Verdana"><b>hack the
method (maybe on line 55)</b><br>
<br>
public Object execute(XmlRpcClientRequest xmlRpcRequest,<br>
\
XmlRpcTransport transport)<br> throws \
XmlRpcException, XmlRpcClientException, IOException<br> {<br>
long now = 0;<br>
Object response = \
PROCESSING_ERROR_FLAG;<br> <br>
if (XmlRpc.debug)<br>
{<br>
now = \
System.currentTimeMillis();<br> }<br>
<br>
try<br>
{<br>
byte[] request = \
requestProcessor.encodeRequestBytes<br> \
\
(xmlRpcRequest, responseProcessor.getEncoding());<br> <br>
<i> <b>// ADD ONE LINE \
HERE</b><br> <br>
<b>setXmlStr(new \
String(request));</b><br> </i><br>
InputStream \
is = transport.sendXmlRpc(request);<br> \
response = \
responseProcessor.decodeResponse(is);<br> \
return \
response;<br> }<br>
catch (IOException ioe)<br>
{<br>
throw ioe;<br>
}<br>
<br>
// more code bla bla<br>
<br>
\
}<br> \
}<br> }<br>
}<br>
}<br>
<br>
</font></font><font size="-1"><font face="Verdana"><b>4. In \
</b></font></font><b><font size="-1"><font face="Verdana">XmlRpcClient \
</font></font></b><font size="-1"><font face="Verdana"><b>hack the method (maybe on \
line 187)</b><br> </font></font><font size="-1"><font face="Verdana"><br>
public Object execute(XmlRpcClientRequest request, XmlRpcTransport
transport)<br>
throws \
XmlRpcException, IOException<br> {<br>
XmlRpcClientWorker worker = \
getWorker(false);<br> try<br>
{<br>
Object retval = \
worker.execute(request, transport);<br> \
<br> \
<i><b> // Get your XML \
String and use the way you want<br> <br>
String str = \
worker.getXmlStr();</b></i><br> <br>
return retval;<br>
}<br>
finally<br>
{<br>
\
releaseWorker(worker, false);<br> }<br>
}<br>
<br>
<br>
Thats All! (ofcourse you have to recompile the classes)<br>
<br>
Its strange that there are no straightforward methods of getting the
xml string directly.<br>
I am sending this mail to group coz it will be great to know </font></font><font
size="-1"><font face="Verdana">if there IS another way</font></font><font
size="-1"><font face="Verdana">!<br>
<br>
<br>
</font></font><br>
Manvendra Baghel wrote:
<blockquote
cite="mid20051107093053.91665.qmail@web30404.mail.mud.yahoo.com"
type="cite">
<pre wrap="">hi Yixing
I am new to XML RPC .Please can you tell how to view
XML of XML-RPC request
</pre>
<blockquote type="cite">
<pre wrap=""><array>
<data>
<value><i4>1404</i4></value>
<value><string>Something Here</string></value>
</data>
</array>
</pre>
</blockquote>
<pre wrap=""><!---->
Thanks in advance
MANAV
--- Yixing Ma <a class="moz-txt-link-rfc2396E" \
href="mailto:Yixing.Ma@interfacemgmt.net"><Yixing.Ma@interfacemgmt.net></a> \
wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
As I'm starting to use apache's XML-RPC java api, I
found couple of questions.
1) The standard XML-RPC spec defines the array type
as something like:
</pre>
</blockquote>
<pre wrap=""><!---->**********************************************************************
</pre>
<blockquote type="cite">
<pre wrap=""><array>
<data>
<value><i4>1404</i4></value>
<value><string>Something Here</string></value>
</data>
</array>
</pre>
</blockquote>
<pre wrap=""><!---->***********************************************************************
</pre>
<blockquote type="cite">
<pre wrap="">But I was unable to put <i4> into the array by using
java Vector. I could only put <int></int> instead of
<i4>. Also the <string></string> tag in red is
missing. The blank space was replaced by " " in
the generated XML.
My code is:
**********************************
Vector v=new Vector(); *
v.add(new Integer("1404")); *
v.add("Something Here"); *
**********************************
The result XML is
</pre>
</blockquote>
<pre wrap=""><!---->**********************************************************************
</pre>
<blockquote type="cite">
<pre wrap=""><array>
<data>
<value><int>1404</int></value>
<value>Something Here</value>
</data>
</array>
</pre>
</blockquote>
<pre wrap=""><!---->**********************************************************************
</pre>
<blockquote type="cite">
<pre wrap="">Is there a way to produce the exact same XML as
XML-RPC defined by using apache's api?
2) If I want to generate
<array>
<data>
<value><i4>001404</i4></value>
</data>
</array>
as I want to preserve the zero before 1404. What
should I do?
Best regards,
Yixing Ma
</pre>
</blockquote>
<pre wrap=""><!---->
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
<a class="moz-txt-link-freetext" \
href="http://mail.yahoo.com">http://mail.yahoo.com</a>
</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<font color="gray" face="verdana" size="2">Thanks,<br>
<br>
Rahul Joshi</font><br>
<br>
<img src="cid:part1.02080407.08090107@dataarmor.net"><br>
<br>
<a
href="http://www.mindistortion.net/iwantyoursoul/?i_am=curse%20of%20samara"
target="_top"><font color="green" face="arial" size="1"><u>________
'Don't Even Think About Clicking Here' _________</u></font></a>
</div>
</body>
</html>
["mysig.jpg" (image/jpeg)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic