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
Cory CowgillCory Cowgill 

.NET Web Service Callouts - System.Net.Credential in Force.com? How to pass basic authentication

Does anyone have any experience calling .NET Web Service from Salesforce?

 

I have used the WSDL2Apex to generate my Apex Classes, however I am having troubling figuring out how to pass user login, password, and domain. The Web Service has examples for calling the WS from .NET, but it uses some System.Net.Credenitals class that is generated in Visual Studio and obviously we are on Apex Platform. Since this is a Web Service, this should be able to be called from any platform. I can't find an example on how to pass this type of information across to a .NET Web Service.

 

Specific Details: I am trying to invoke a Sharepoint Out-of-theBox WS from Apex Callout. I am contnually getting 401 Authorization Errors and can't figure out how to pass my usernmae/password/domain in the Sharepoint call.

HaagenHaagen

Hi Cory,

 

I have not tried this myself, but might be worth a go. You should be able to add a HttpHeader to your outbound call and handle the basic authentication that way. 

 

Have a look here:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex.htm#http_header_support

 

There is a small example dealing with basic authentication.

 

Cheers!

 

Martin