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
Manoj kumar.ax391Manoj kumar.ax391 

Login calls for webservice apex methods

Hi,

 

I am developing a webservice method that needs to be accessed through the WSDL file from an external .net program. Here is the sample code (rather a very simple one)

 

global class CustomerInterface{

  Webservice static String createCustomer(String customerName){
//perform some logic here

  return 'Successfull';
 
}
Now when I generate a WSDL file for this it only contains this method. If an external .net service needs to access this webservice I should do the following steps
1. Consume a partner wsdl and then call the login method
2. Take the sessionid from the previous call
3. Consume my CustomerInterface WSDL and then add the sessionid from step 2 into the header of the createCustomer call
This means my client should consume 2 WSDL files. Is there any way where I can reduce this to one. Say add a login method in the CustomerInterface.wsdl?
Thanks,
Manoj Ganapathy

 

Bhawani SharmaBhawani Sharma

Instead of doing all these things manually , you can create a code snippet, which will call the login api and will fetch the session Id from it . Same time it will make the another call for customerinterface.

 

like :

XmlStreamReader reader =  stub.login();

//parse the reader instance and get the session Id

String sessionId = reader.getLocalName('sessionId');

 

//now use the sessionId for customer Interface

stub.customerInterface();