You need to sign in to do that
Don't have an account?
Saniya 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
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
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.
- https://developer.salesforce.com/forums/?id=906F000000092J1IAI
Hope this helps.Thanks,
Nagendra
I am sending the same way as It mentioned in that url but its not working.