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 

Returned server_url by login call is empty

Hi all,

 

As you know, the login call returnes "session_id", "server_url" and "userID". After executing this login call, the server_url is always empty (has a null value).

My first question is:  Why is the returned server_url empty ??

I read in one of the messages in the community that the server_url is needed for all Api calls except the login call.

My second question is : How do I assign the server_url to an other call? (Note: describe/query and insert calls do not require any server-url).  

Thank you, sfDeveloper

****************************************************** this is my code

public static void main(String arg [])

throws MalformedURLException

{

  ...

 

  XmlRpcClient rpcClient=new XmlRpcClient("https://emea.salesforce.com/servlet/servlet.Api");

  Hashtable param=new Hashtable();

  param.put("username","MyUserName");

  param.put("password", "MyPassword");

  param.put("version", "2.0");

  java.lang.Boolean secure=new Boolean(true);

  param.put("secure", secure);

  Vector params=new Vector();

  params.add(param);

 

Object result=null;

Hashtable hashResult=null;

try

{

  result= rpcClient.execute("sfdc.login",params);

  hashResult=(Hashtable)result;

  Enumeration enu = hashResult.keys();

  while(enu.hasMoreElements())

  {

    String key=(String)enu.nextElement();

    printMsg("\t" + key + " = " + hashResult.get(key));

  }

}

 

catch(XmlRpcException ex)

{

  printMsg("FATAL : "+ex.toString());

  printMsg("FATAL Exception code: "+ex.code);

  ex.printStackTrace();

}

catch(IOException ex)

{

  printMsg("FATAL Exception : "+ex.toString());

  ex.printStackTrace();

}

....

}

DevAngelDevAngel

Hi sfDeveloper,

You will not recieve a login call when you execute a login against one of the app servers.  In your code snippet, you have the url as https://emea.salesforce.com/servlet/servlet.Api which is an app server.  You should always and forever execute you login call against https://www.salesforce.com/servlet/servlet.Api.  If you do, you will recieve the url to the app server to use for all other calls.

The url is not to be "assigned" but used as the endpoint at which to make additional calls.  In your snippet you wrote:

XmlRpcClient rpcClient=new XmlRpcClient("https://emea.salesforce.com/servlet/servlet.Api");

This is the statement you need to execute after getting the server_url.  The url in your constructor is the app server that you will probably receive at login (emea is for European sfdc orgs, although not exclusively).  So the logic is Create your client using www.salesforce.com, obtain the url from that call, re-instantiate your client using the url from the login, make all the other calls.

sfDevelopersfDeveloper

Hi Dave,

 

I don't know if I understand you very well. I'll write down the steps you mentioned:

 

1 - I have to create a xmlrpcClient with this url https://www.salesforce.com/servlet/servlet.Api like this:

 

XmlRpcClient rpcClient=new XmlRpcClient("https://www.salesforce.com/servlet/servlet.Api");

 

2 - Then I have to excute the login call and get the "server_url" from the response of the login call. By the way I tried that and I get the "server_url" with a value. It is not empty like last time .

 

3 -  Now I have to re-instantiate the rpcClient using the "server_url" I get from the login call. If I go on with the same rpcClient without re-instantiating I get this error:

 

(helma.xmlrpc.XmlRpcException: unknown method name querycode: 1113).

 

So how can I re-instantiate the rpcClient ?

 

4 - Now can I excute the rest of calls.

 

Did I understand you well ?

sfDeveloper

DevAngelDevAngel

Hi sfDeveloper,

Here is some code from an xml-rpc sample.  Notice that there are actually 2 instances of the XmlRpcClient one called xmlrpc_login used only for login, one called xmlrpc used for other calls and constructed with the url returned from the login.

        // The following server is used only to determine the target server
        // URL for the org referenced by the above username.
        String server = https://www.salesforce.com/servlet/servlet.Api;
        XmlRpcClient xmlrpc_login = new XmlRpcClient(server);

        //Execute the login call using the parameters built above
       Hashtable result =  (Hashtable) xmlrpc_login.execute("sfdc.login", loginParms);
       String mySessionID = (String)result.get("session_id");
       String myServer = (String)result.get("server_url");


        // Construct an XMLRPC Client object connecting to the server returned from login call
        XmlRpcClient xmlrpc = new XmlRpcClient(myServer);

        // Save the session ID in the xmlrpc client object for subsequent API calls
        xmlrpc.setSessionId(mySessionID);

 

Message Edited by DevAngel on 08-13-2003 08:18 AM

sfDevelopersfDeveloper

Thank you very much. it works but after several times I get this IOException:

java.io.IOException: java.security.cert.CertificateException: Could not find trusted certificate

I think that this happend because there are different app servers and it seems that one of these has no trusted certificate. Wat do you think ??

sfDeveloper

Message Edited by sfDeveloper on 08-14-2003 06:34 AM

DevAngelDevAngel

Hi sfDeveloper,

No, that is not the reason.  All our servers have ssl certs that are valid and up-to-date.  I think the issue is more likely cacheing of certs or something like that on your workstation.

My face is red.  There is an intermittant problem w/respect to SSL. 

Message Edited by DevAngel on 08-14-2003 09:32 AM