Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to add SOAPAction header to request?

Hi

I have been trying to add a header to soap 1.2 request, because gcp's load balancer cannot read content of request if it is in 1.2 version, adding additional header (legacy) is supported by soap 1.2 (due to separate the traffic using headers)

Ive been trying both ways

 

<AssignMessage continueOnError="false" enabled="true" name="AM-manual-header">
  <DisplayName>AM-manual-header</DisplayName>
  <AssignVariable>
    <Name>SOAPAction</Name>
    <Ref>request.header.SOAPAction</Ref>
    <Value>some_value</Value>
  </AssignVariable>
  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
  <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

 

and

 

<AssignMessage continueOnError="false" enabled="true" name="AM-inject-header">
  <DisplayName>AM-inject-header</DisplayName>
  <Properties/>
  <Set>
    <Headers/>
    <Header name="SOAPAction">{soap.ACTION}</Header>
  </Set>
  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
  <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

 

both did not add header

my preflow:

 

 <Step>
        <Condition>soap.ACTION = "some_header"  </Condition>
        <Name>AM-inject-header</Name>
      </Step>
      <Step>
        <Condition>soap.ACTION = "some_header"  </Condition>
        <Name>AM-manual-header</Name>
      </Step>

 

variable is extracted one step above but I know till assign message everything is working fine, debugging shows soap.action variable extraction.

0 3 471
3 REPLIES 3

I'm not clear on what you are trying to do. 

to assign a header in Apigee you just use AssignMessage and set the header to the value you want. An example is

 

<AssignMessage name="AM-inject-header">
  <Set>
    <Headers>
      <Header name="SOAPAction">{soap.ACTION}</Header>
    </Headers>
  </Set>
</AssignMessage>

 

Your AssignMessage configuration was broken: it had closed the Headers element before the Header element. So it would not do anything.

Some notes on that:

  1. It seems like a bug that Apigee allows you to deploy a proxy containing a policy with such an obviously broken configuration. That's frustrating. 
  2. You would have been made aware of this had you used apigeelint to scan that policy configuration.  I highly recommend adopting apgeelint.  I use it before deploying any API proxy. It's a good hygiene thing, a good tool to embrace.

 

oh, I must have missed it, closed header section.  
AssignMessage still does not want to cooperate, maybe its having difficulties because of soap 1.2? 

I can add header using HTTPModifier, this arrs header as expected


<HTTPModifier continueOnError="false" enabled="true" name="HTTPM-customHeader">
  <DisplayName>HTTPM-customHeader</DisplayName>
  <Properties/>
  <Set>
    <Headers>
      <Header name="SOAPAction">{soap.ACTION}</Header>
    </Headers>
  </Set>
  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
  <AssignTo createNew="false" transport="http" type="request"/>
</HTTPModifier>



Hmmm interesting. 

You might have somehting else out of p[lace. Try running apigeelint on your proxy (with the misbehaving AssignMessage policy). 

Or, don't. That HTTPModifier will just work.