You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by "fahad.aizaz" <fa...@gmail.com> on 2008/03/12 10:24:55 UTC

embedding a string in struct method

Hi guys!

I recently used apache xml-rpc library to create a client that send XML data
to the server to get individual details.

Now the server is created by a third party entity and they have provided us
the guidelines to create clients accordingly.

The XML data that is needed to be sent to the server is as follows:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
<?xmlversion="1.0"?>
<methodCall><methodName>GetAccountDetailsRequest</methodName>
<params>

<value>
<struct>
<member><name>originNodeType</name><value><string>TEST</string></value></member>
<member><name>originHostName</name><value><string>TEST</string></value></member>
<member><name>originTransactionID</name><value><int>12345</int></value></member>
<member><name>originTimeStamp</name><value><dateTime.iso8601>20080229T13:37:00+0000</dateTime.iso8601></value></member>
<member><name>subscriberNumber</name><value><string>826953722</string></value></member>
</struct>
</value>

</params>
</methodCall>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Now i am unable create exact structure for this kind of XML data. The code
is below:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
import java.net.*;
import java.util.*;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.*;

public class XMLClient {
    
    public XMLClient() {
    }

    public static void main(String[] args) {
        
        HashMap data = new HashMap();
        data.put("originNodeType", new String("TEST") );
        data.put("originHostName", new String("TEST") );
        data.put("originTransactionID", new Integer(12345));
        data.put("originTimeStamp", new Date());
        data.put("subscriberNumber", new String("826629828") );
        
        
        Vector params = new Vector();
        Object paramsR =  new Object();
        params.addElement(data);
        
        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        try 
        {
            config.setServerURL(new
URL("http://accountdetailsserver:8080/RPC2"));
            XmlRpcClient client = new XmlRpcClient();
            client.setConfig(config);
            client.execute("BalanceEnquiryTRequest", params);
            paramsR = (Object)client.execute("GetAccountDetailsRequest",
params);
  
        } catch (MalformedURLException e) 
        {
            System.err.println(e);
        } catch (XmlRpcException e) 
        {
             System.err.println(e);
        }
        System.out.println( paramsR );
    }
    
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The output of this code is as below

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
<?xmlversion="1.0"?>
<methodCall><methodName>GetAccountDetailsRequest</methodName>
<params>

<value>
<struct>
<member><name>originNodeType</name><value>TEST</value></member>
<member><name>originHostName</name><value>TEST</string></member>
<member><name>originTransactionID</name><value><int>12345</int></value></member>
<member><name>originTimeStamp</name><value><dateTime.iso8601>20080229T13:37:00+0000</dateTime.iso8601></value></member>
<member><name>subscriberNumber</name><value>826953722</value></member>
</struct>
</value>

</params>
</methodCall>

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The tag <string></string> is missing from the output xml data above.

<member><name>originNodeType</name><value><string>TEST</string></value></member>
<member><name>originHostName</name><value><string>TEST</string></value></member>
<member><name>subscriberNumber</name><value><string>826953722</string></value></member>

and therefore the query responds with an error code from the server end.
Please help me solve this issue, i ve tried to search for the solution a lot
but all in vain.

Regards,

Fahad 
-- 
View this message in context: http://www.nabble.com/embedding-a-string-in-struct-method-tp16000638p16000638.html
Sent from the Apache Xml-RPC - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org