Link to home
Start Free TrialLog in
Avatar of speedygonzalez
speedygonzalez

asked on

Difference between SOAP & HTTPRequest Headers?

Hello,

I have a webservice I need to call which contains a <soap12:Header> element within its XML.

<soap12:Header>
    <ServiceAuthHeader xmlns="http://dummyNameForExpertsExc">
      <User>string</User>
      <Password>string</Password>
    </ServiceAuthHeader>
  </soap12:Header>

In calling the webservice I will be doing so using the HttpRequest and HttpResponse apex classes.

the HttpRequest class has a method called setHeader.

In examples I have seen it is used to set attributes such as content type in the following

HttpRequest req = new HttpRequest();
req.setEndpoint('http://dummyNameForBlogPost.com/serviceTest.asmx ');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/soap+xml');
req.setTimeout(60000);

There is a setBody method for HttpRequest also.

Should my SOAP Header actually go with the rest of my XML in  the setBody method?
Avatar of speedygonzalez
speedygonzalez

ASKER

Sorry accidently saved before finishing my question.

My question is

Should my SOAP Header actually go with the rest of my XML in  the setBody method? or should it be set in the HTTPRequest.setHeader() method?

This has really confused me.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Holger101497
Holger101497

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. This answer is very useful!