ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rjo...@dataarmor.net
Subject Re: <i4> and array type question,please help
Date Thu, 10 Nov 2005 15:02:20 GMT
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>

Mime
View raw message