I am integrating Salesforce with a program called IFS. I have the WSDL from IFS and have imported it into Salesforce. My problem is that the WSDL does not have anything about logging into IFS. I do not know how to pass the username and password to log in. When I make the connection I get a 401 unauthorized error. Anyone know how to pass the security to IFS?
As far as i know IFS is build on windows stack, so most likely it uses NTLM authentication. You can try this tool: https://github.com/natewallace/ApexNTLM.
Example of usage
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);
I found the error. It takes Basic Authentication. so in the example https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm#apex_System_HttpRequest_setTimeout they show how to do username and password. I was doing it right but had the word "BASIC" all caps like in the example and IFS only reads it if is "Basic". Don't you love it when you spend weeks and it is something stupid like an issue with capitalization.