[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>
&nbsp;&nbsp;&nbsp; this.xmlStr = str;<br>
}<br>
<br>
public String getXmlStr()<br>
{<br>
&nbsp;&nbsp;&nbsp; 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>
&nbsp;&nbsp;&nbsp; public Object execute(XmlRpcClientRequest xmlRpcRequest,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
XmlRpcTransport transport)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throws \
XmlRpcException, XmlRpcClientException, IOException<br> &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long now = 0;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object response = \
PROCESSING_ERROR_FLAG;<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (XmlRpc.debug)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; now = \
System.currentTimeMillis();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] request = \
requestProcessor.encodeRequestBytes<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
(xmlRpcRequest, responseProcessor.getEncoding());<br> <br>
<i>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>// ADD ONE LINE \
HERE</b><br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>setXmlStr(new \
String(request));</b><br> </i><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputStream \
is&nbsp; = transport.sendXmlRpc(request);<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response = \
responseProcessor.decodeResponse(is);<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return \
response;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (IOException ioe)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw ioe;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // more code bla bla<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
}<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
}<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<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>
&nbsp;&nbsp;&nbsp; public Object execute(XmlRpcClientRequest request, XmlRpcTransport
transport)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throws \
XmlRpcException, IOException<br> &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlRpcClientWorker worker = \
getWorker(false);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object retval = \
worker.execute(request, transport);<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> \
<i><b>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; // Get your XML \
String and use the way you want<br> <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; String str = \
worker.getXmlStr();</b></i><br> <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return retval;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finally<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
releaseWorker(worker, false);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<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="">&lt;array&gt;
  &lt;data&gt;
    &lt;value&gt;&lt;i4&gt;1404&lt;/i4&gt;&lt;/value&gt;
    &lt;value&gt;&lt;string&gt;Something Here&lt;/string&gt;&lt;/value&gt;
  &lt;/data&gt;
&lt;/array&gt;

    </pre>
  </blockquote>
  <pre wrap=""><!---->
Thanks in advance

MANAV



--- Yixing Ma <a class="moz-txt-link-rfc2396E" \
href="mailto:Yixing.Ma@interfacemgmt.net">&lt;Yixing.Ma@interfacemgmt.net&gt;</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="">&lt;array&gt;
  &lt;data&gt;
    &lt;value&gt;&lt;i4&gt;1404&lt;/i4&gt;&lt;/value&gt;
    &lt;value&gt;&lt;string&gt;Something Here&lt;/string&gt;&lt;/value&gt;
  &lt;/data&gt;
&lt;/array&gt;

    </pre>
  </blockquote>
  <pre wrap=""><!---->***********************************************************************
  </pre>
  <blockquote type="cite">
    <pre wrap="">But I was unable to put &lt;i4&gt; into the array by using
java Vector. I could only put &lt;int&gt;&lt;/int&gt; instead of
&lt;i4&gt;. Also the &lt;string&gt;&lt;/string&gt; 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="">&lt;array&gt;
  &lt;data&gt;
    &lt;value&gt;&lt;int&gt;1404&lt;/int&gt;&lt;/value&gt;
    &lt;value&gt;Something Here&lt;/value&gt;
  &lt;/data&gt;
&lt;/array&gt;

    </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 
&lt;array&gt;
  &lt;data&gt;
    &lt;value&gt;&lt;i4&gt;001404&lt;/i4&gt;&lt;/value&gt;
  &lt;/data&gt;
&lt;/array&gt;

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