function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfDevelopersfDeveloper 

Issue: helma.xmlrpc AND org.apache.xmlrpc

Hello all,

 

Now I have an other issue :

 

The first time I got started with sForce I've received java samples with the helma.xmlrpc from the support of sForce. It works perfectly. After a while I found out that the helma is out of date and there is a new version on <http://ws.apache.org/xmlrpc/>. The new xmlrpc classes are now called "org.apache.xmlrpc".


So I've downloaded the new version and I replaced the import form (import elma.xmlrpc.*) into (import org.apache.xmlrpc.*).

After that al my sForce code fails, because the new xmlrpcClient class doesn't have the method:
instanceOfxmlrpcClient.setSessionId(
"the returned session_id from login call");

And as you know before every call in sForce the xmlrpcClient needs the session_id except the login call.

I wish to use the new version of xmlrpc, but how should I solve the session_id problem. I'm sure there is some way to let the xmlrpcClient know what the sessionId is.

Would somebody help me with a code example (Java wil xmlrpc)?

 

Thank you.
sfDeveloper

DevAngelDevAngel

Hi sfDeveloper,

You should be able to swap Apache for Helma and apply the changes below to handle our authentication issues.
 
The change to org.apache.xmlrpc.XmlRpcClient is pretty simple.
 
Create a protected String "sessionId" in XmlRpcClient. Add this method:
 
    public void setSessionId(String sid) {
        this.sessionId = sid;
    }
 
Also, during the execute method, pass up the sessionId in the headers for every request:
 
    Object execute(String method, List params) throws XmlRpcException, IOException {
 
        ....
 
            if (sessionId != null) {
                con.setRequestProperty("SessionId", sessionId);
            }
 
        ....
 
    }
 
Obviously, your initial call will return a session id parameter, which you then use to call setSessionId() on the XmlRpcClient. From there on, your calls will all be authenticated.
 
For requests over a long period of time, you'll also have to handle auto-login when the session times out.
 
This, of course means, rebuilding the Apache XML RPC jar.
 
sfDevelopersfDeveloper

Hi Dave,

 

Oke, I can modify the source code of the XmlRpcClient class.

 

One more question:

 

Which version of xmlrpc you recommend (v1.0, v 1.1 or v1.2-b1) 

 

 

sfDeveloper
DevAngelDevAngel

Hi sfDeveloper,

I recommend the latest, non-beta version of Apache XML-RPC.