2

I Have a requirement to call Soap API of Exact target via a callout from my Salesforce CRM Apex class. I am using the WSDL2APex approach and i'm able to successfully make the call to exact target and receive the response when i pass the security tag with Usernametoken details.

However, due to some implicit requirements, I have a necessity to pass the fueloauth element instead of username and password in the soap envelop.

Below is the sample inner class i have for the header. However, it is adding an additional wrapper <Header> which I am not able to figure out how to remove. Need some help here.

 public class Header{
        public String fueloAuth;
        private String[] fueloAuth_type_info = new String[]{'fueloAuth','http://exacttarget.com','String','1','-','false'};
        private String[] apex_schema_type_info = new String[]{'','true','false'};
        private String[] field_order_type_info = new String[]{'fueloAuth'};       
   }   

code in my stub class is as below to add the header, where i have the webserviceCallout.invoke method.

  public ETPartnerAPI.Header Header;
  private String Header_hns = 'env:Header=www.exacttarget.com'; 

generated output is

<env:Header>
  <env:Header xmlns="www.exacttarget.com">
     <fueloAuth>somevalue</fueloAuth>
  </env:Header>
</env:Header>

What i'm looking at is

  <env:Header xmlns="www.exacttarget.com">
     <fueloAuth>somevalue</fueloAuth>
  </env:Header>
5
  • Have you look into using the Marketing Cloud Connector app in AppExchange? Depending on your project goals, you may be able to use this app to couple Salesforce and the Marketing Cloud (aka ExactTarget), rather than writing custom apex. Commented Sep 2, 2015 at 18:40
  • Are you able to share the WSDL? One option would be to generate the corresponding HttpRequest. This could be modified as required. Commented Sep 2, 2015 at 20:22
  • @DavidDevoy , Thanks . Connector we are unable to use as it is a strict one to one environment mapping. one Instance of Salesforce connected to one instance of ET. We wanted to go with API since we could re-use the ET instance from multiple Salesforce org. Commented Sep 3, 2015 at 5:23
  • Yes, we are moving with construction of HttpRequest now , though I wish the WSDL approach would have been much easier and easy to maintain. Commented Sep 3, 2015 at 5:25

1 Answer 1

2

My understanding is a simple string soap header isn't supported.

From apex_callouts_wsdl2apex.htm

WSDLs that don’t use the document literal wrapped style. The following WSDL snippet doesn’t use document literal wrapped style and results in an “Unable to find complexType” error when imported.

You must log in to answer this question.

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