+ Start a Discussion
Tim__mTim__m 

Callout to a SOAP service that uses NTLM authentication

Is it possible to make a callout from APEX to a SOAP web service that uses NTLM authentication? If so is there documentation and or samples?

 

I was able to generate an apex class from the WSDL but I don't know how to use it with NTLM auth and I have a funny feeling its not even possible.

 

NTLM authentication is always getting in my way (unless I'm building in .NET) but I have no say in what authentication protocol is used.

mravagnamravagna

Tim, did you ever figure this out?  I'm stuck on the same thing.

Deepika GulatiDeepika Gulati
Hi 

I think i am little late but i recently solved this issue. 
We had MSD-SFDC integration where a SOAP Service was exposed on Nav2013 server. 

The mode of authentication used was NTLM authentication. 

I downloaded the classes from the below package in my org for Encryption of user name and password : 
https://github.com/natewallace/ApexNTLM

For integration, we made a HTTP call : 
        MSDCredentials__c mc = MSDCredentials__c.getValues('MSD Credentials');
        String username = mc.Domain__c + '\\' + mc.Username__c;
        String password = mc.Password__c;  
        HttpClient httpObj = new HttpClient(username,password,True);
        MSDIntegrationURL__c urlVar; 

        HttpRequest req = new HttpRequest();
        String body = createXMLRequest(request);    
        req.setBody(body);

        String ep;
        ep = urlVar.EndPointURL__c;
        Map<String,String> headerMap = new Map<String,String>();
        headerMap.put('SOAPAction',urlVar.SOAPAction__c);
        headerMap.put('Content-Type','text/xml;charset=UTF-8');
        headerMap.put('Accept-Encoding','gzip,deflate');
            
        req.setEndpoint(ep);
        req.setMethod('POST')

        Httpresponse res = new Httpresponse();
    
        res = httpObj.send(req,headerMap);


The SOAP Action can be obtained from RAW request in SOAP UI client.

Let me know if this helps. 

Thanks.

        
Willebaldo Páez MartínezWillebaldo Páez Martínez
Hello,
I have execute the code but I have a error: System.HttpResponse[Status=Bad Request, StatusCode=400]
I think is the BodyXML is wrong, someone have an example of this?

Thanks...