You need to sign in to do that
Don't have an account?
Terminusbot
SOAP Request in APEX - Error Bad Request 400
I am sending a SOAP Request from Salesforce and I am getting a bad request 400 response.
I have a succesfull POST request through POSTMAN so I decided to take the raw XML and insert it into string variables. Here is what I am sending.
I have a succesfull POST request through POSTMAN so I decided to take the raw XML and insert it into string variables. Here is what I am sending.
public class ClientInsertCallout { @future (callout=true) public static void sendNotification(String name, ID Id) { // Test Variables Integer divisionNumber = 01; String addr1 = '2972 Anderson Circle SE'; Integer postalCode = 30080; String city = 'Smyrna'; String state = 'GA'; Integer phone1 = null; String contactMethod = 'Email'; String email = 'rlopez@rampartinsurance'; HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); // Login Variables String account = 'xxxx'; String username = 'xxxx'; String password = 'xxxx'; String serverpool = 'xxxx'; // Setting login variables - commented out to try raw xml //Blob headerValue = Blob.valueOf(Account + ':' + Username + ':' + Password + ':' + Serverpool); // Body of Request - XML in a string string soapBody = '<ClientImportRecord>' + '' + '<Guid>'+ Id + '</Guid>' + '' + '<ClientName>' + name + '</ClientName>' + '' + '</ClientImportRecord>'; string headerValue = '<Account>' + account + '</Account>' + '' + '<Username>' + username + '</Username>' + '' + '<Password>' + password + '</Password>' + '' + '<Accesscode xsi:nil="true" />' + '' + '<Serverpool>' + serverpool + '</Serverpool>'+ '' + '<Onlinecode xsi:nil="true"/>'; String authorizationHeader = headerValue; req.setHeader('Authorization', authorizationHeader); req.setHeader('Accept-Encoding','gzip,deflate'); req.setHeader('Content-Type', 'text/xml'); req.setHeader('SOAPAction','http://amsservices.com/clientInsert'); req.setEndpoint('http://xxx.xxx.xxx.xxx/sagittaws/transporter.asmx'); req.setMethod('POST'); req.setBody(soapBody); System.debug('Full XML' + soapBody); req.setCompressed(true); // otherwise we hit a limit of 32000 try { res = http.send(req); } catch(System.CalloutException e) { System.debug('Callout error: '+ e); System.debug(res.toString()); } } }
Here is my successful SOAP request XML. You can see there is more than just username and password.
I added some debug entries but I can't get the full request to post to the logs. Do you know have to see the entire POST message?
Here is what I see in the logs currently. Not very helpful. I want to see the entire POST along with header, body, ect..
Just checking in with you - did you ever get Salesforce to communicate successfully with your web service?