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="http://schemas.xmlsoap.org/soap/envelope/" 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>' +
        '</soapenv:Envelope>';
       System.debug('Message'+body);
    HTTP h = new HTTP();
    HTTPRequest r = new HTTPRequest();
    r.setEndpoint('https://wd3-impl-services1.workday.com/ccx/service/XXX/Revenue_Management/v31.1');
    Blob headerValue = Blob.valueOf('ISU_XXXX_XXx@tenent' + ':' + 'XXXXX!');
   String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
    r.setHeader('Authorization', authorizationHeader);
    r.setHeader('Content-Type','text/xml;charset=UTF-8');
    r.setHeader('AllowAutoRedirect', 'True');
    r.setHeader('UseDefaultCredentials','False'); 
      r.setHeader('AuthenticationLevel', 'Net.Security.AuthenticationLevel.None');
       r.setHeader('SOAPAction', 'https://wd3-impl-services1.workday.com/ccx/service/xxx/Revenue_Management/v31.1');
    r.setMethod('GET');
    r.setBody(body);
    HTTPResponse resp = h.send(r);
    system.debug('Body::'+resp.getbody());
 }
}
Many thanks,
Saniya
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.

Thanks,
Nagendra
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?