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
SiddharthSiddharth 

Using APEX class as WSDL in ASP.Net

Friends,
 
I have created a simple APEX class with a function named HELLO() which accepts a string, searched in accounts for name starting with that string and returns a count in string format. I have generated it as a Web Method so that I can use this in .Net. I further generated a WSDL file from it and tried to use it ASP.NET.
 
After creating an instance of my web service, i get the Hello method accessible, but how do I set the login credentials for my APEX call. It says invalid session Id. Snippet from ASP.Net code.
 

protected void Page_Load(object sender, EventArgs e)

{

Test.HelloWorld2Service obj = new CellsMerge.Test.HelloWorld2Service();

string a = obj.Hello("s");

}

 

Any suggestions as how can we achieve this functionality.

Siddharth

WhyserWhyser
You'll need to login to Salesforce like you would normally such as the API code here
 
 
Look under the function login()
 
using the session ID generated from the login, pass that value to your obj.SessionHeaderValue.SessionId
 
so something like
 
obj.SessionHeaderValue = new Test.SessionHeader();
obj.SessionHeaderValue.sessionId = sfdc.SessionHeaderValue.sessionId;
 
Then run your apex webservice.