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
Saniya Khan 2Saniya Khan 2 

send xml data from salesforce to external server

Hi All,
I am trying to integrate salesforce with workday.
I tried with SoapUI APP for testing and its working fine but when I tried same xml in apex class using HTTPrequest its not working and throwing an error Invalid request.
Could anyone pleasde help me with this it will be appreciates.

Here is my apex code with xml string

public class Test2 {
   public static void test_m(){
     String body = '<soapenv:Envelope xmlns:soapenv="" xmlns:bsvc="urn:com.workday/bsvc">'+
           '<soapenv:Header>' +
              '<bsvc:Workday_Common_Header>' +
                 '<bsvc:Include_Reference_Descriptors_In_Response>'+'1'+'</bsvc:Include_Reference_Descriptors_In_Response>' +
              '</bsvc:Workday_Common_Header>' +
           '</soapenv:Header>' +
           '<soapenv:Body>' +
              '<bsvc:Get_Customer_Invoices_Request bsvc:version="v31.1">' +
                 '<bsvc:Request_References>' +
                    '<bsvc:Customer_Invoice_Reference bsvc:Descriptor="?">' +
                       '<bsvc:ID bsvc:type="WID">a36116d317ae81ecf995ece9cxxxxxxx</bsvc:ID>' +
                    '</bsvc:Customer_Invoice_Reference>' +
                               '</bsvc:Get_Customer_Invoices_Request>' +
           '</soapenv:Body>' +
    HTTP h = new HTTP();
    HTTPRequest r = new HTTPRequest();
    Blob headerValue = Blob.valueOf('ISU_XXXX_XXx@tenent' + ':' + 'XXXXX!');
   String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
    r.setHeader('Authorization', authorizationHeader);
    r.setHeader('AllowAutoRedirect', 'True');
      r.setHeader('AuthenticationLevel', 'Net.Security.AuthenticationLevel.None');
       r.setHeader('SOAPAction', '');
    HTTPResponse resp = h.send(r);
Many thanks,
NagendraNagendra (Salesforce Developers) 
Hi Saniya,

Sorry for this issue you are encountering.

May I suggest you please refer to below link from the forums community with a similar discussion which might help. Hope this helps.

Saniya Khan 2Saniya Khan 2
Hi Nagendra,
I am sending the same way as It mentioned in that url but its not working.
Saniya Khan 2Saniya Khan 2
@Nagendra Do you know how to write apex classes to construct and parse the soap messages any example?