This is a broad general question .

We already have a SOAP callout in place where we are hitting the endpoint url after creating the request header and other necessary elements and hitting the method in stub .

Question - How can I make the same callout using HTTP callout ?
How do we send the request xml to the endpoint?

2 Answers 2


You can hand code your own manual XML POST callout using HttpRequest. It will be on you to build up the required XML and then parse the response.

Alternatively, if you have a WSDL to work from, I created an alternative version of WSDL2Apex.

When you import the WSDL you are presented with a list of methods to import. At that stage you can opt to generate the Apex required to perform the HttpRequest.


You can use HTTPRequest class to build the request. The actual SOAP message is passed as the body of the request.

    Http http = new Http();
    HttpRequest request = new HttpRequest();
    request.setHeader('Content-Type', 'text/xml; charset=character encoding');

Now set the request body with SOAP XML String. Here SOAPXML variable contains the actual SOAP XML.

    HttpResponse response = http.send(request);

There are Apex classes to help you build XML: XMLStreamReader class enables you to read XML content and the XMLStreamWriter class enables you to write XML content.

To understand the content type or specify type of content being sent in the HTTP Request this document can help: https://www.rfc-editor.org/rfc/rfc3023#page-5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .