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
firefoxfirefox 

performance tuning - avoiding multiple stubs in a single session

Hi, 

 

 I am implementing a client using Axis2, and partner.wsdl 

 

 I've read that creation of multiple stubs will lead to performance issues. 

 

 In the Axis2, we need to pass each and every parameter like sessionheader, calloptions, etc for each call (query, update, etc) we make.

 

- So, I am just thinking of reusing the same stub once it's endpoint is changed after the login 

   - across a single session

   - or for an entire application. (Does the URL change every time we login?)

 

BTW, are there any other points  to consider to improve performance.

 

Please clarify. 

Best Answer chosen by Admin (Salesforce Developers) 
Abhinav GuptaAbhinav Gupta

You can use either partner or enterprise wsdl for login, using the default url. On return what API endpoint you get depends on which WSDL you used for login i.e. Partner or Enterprise. 

 

So here is the general template of sfdc endpoint

 

https://<NODE-API host name>/services/Soap/u/<api-version>

 

Partner URL is having something like "/u/", if its Enterprise its having "/c/"

 

Once session is created you get LoginResult from the login call. It has the session id, that is reusable across all WSDLs. You just need to form correct API endpoint. I usually do it using LoginResult.getMetadataServerUrl() and constructing other required endpoints. A code sample  is shown below

 

        public String getPartnerServerUrl() {
                return metadataServerUrl.replaceAll("/m/", "/u/");
        }

        public String getEnterpriseServerUrl() {
                return metadataServerUrl.replaceAll("/m/", "/c/");
        }

        public String getApexServerUrl() {
                return metadataServerUrl.replaceAll("/m/", "/s/");

All Answers

Abhinav GuptaAbhinav Gupta

This is a very common problem when working with web services. We need to do a couple of things like

 

  • Cache Session, to avoid repeated login calls and for better memory mgmt etc
  • Retry failures because of network issues like connection failures etc.
So I created a generic framework called Tolerado to address all above problems, it gives a few utility APIs too.
Tolerado comes in two flavors i.e.
 I suggest you try Force.com Connector, aka WSC, this API is very good and easy to use, its maintained and enhanced by salesforce dev. evangalists.  I am focusing more on WSC based version of Tolerado these days and have added some enhancements that are not available in Axis version.
Let me know if you have queries.

 

firefoxfirefox

Thanks for the reply Abhinav. 

 

WSC seems to be a better solution. However, I need to stick to the Axis2 for consistency. (We use many webservices and all of them were implemented using Axis2)

 

Please share if you have any info on Axis2-sforce tuning. 

 

Another question - 

--> Does the URL (endpoint) change after every login? 

 

Abhinav GuptaAbhinav Gupta

No endpoint URL remains the same even after login. It just slightly changes across WSDLs like metadata,partner or apex. 

 

Try digging into Tolerado Axis version for details on session caching etc. I am not sure to port Tolerado to Axis 2, it requires decent effort. 

 

Though will try adding a blog post about this soon.

firefoxfirefox

Thanks Abhinav. 

 

I' m  sorry, getting confused.  You mentioned - 

" It just slightly changes across WSDLs like metadata,partner or apex. "

 

I'm just wondering that the partner wsdl/created stubs remain the same once the application is deployed. So, when does the endpoint change. 

 

Here is my question. 

-> I use default URL to login. Then I get the new endpoint for every login. 

-> Does the return endpoint URL depend on login credentials? otherwise it should remain the same whatever the case. (unless multiple server for load balancing)

 

I apologize if I missed some obvious points.

 

I'm thinking of reusing the stub after referring to WSO2 link

Abhinav GuptaAbhinav Gupta

You can use either partner or enterprise wsdl for login, using the default url. On return what API endpoint you get depends on which WSDL you used for login i.e. Partner or Enterprise. 

 

So here is the general template of sfdc endpoint

 

https://<NODE-API host name>/services/Soap/u/<api-version>

 

Partner URL is having something like "/u/", if its Enterprise its having "/c/"

 

Once session is created you get LoginResult from the login call. It has the session id, that is reusable across all WSDLs. You just need to form correct API endpoint. I usually do it using LoginResult.getMetadataServerUrl() and constructing other required endpoints. A code sample  is shown below

 

        public String getPartnerServerUrl() {
                return metadataServerUrl.replaceAll("/m/", "/u/");
        }

        public String getEnterpriseServerUrl() {
                return metadataServerUrl.replaceAll("/m/", "/c/");
        }

        public String getApexServerUrl() {
                return metadataServerUrl.replaceAll("/m/", "/s/");
This was selected as the best answer