How to extract HTTP header for connect soap response, not soap envelop header

We are calling a soap webservice using connect-soap and service return some http header along with response body. Is there a way to extract these http header?

Please note, I am referring to http header not soap envelop header, which can be parsed by using response header section in the connect-soap rule.

Any help will be greatly appreciated here.

@KAILASHC as already indicated in your closed support ticket INC-C7839 At this time, we do not have any out-of-the-box solutions to capture the response HTTP headers.

We notified you that we submitted a feedback request under FDBK-124654.

As you were already informed there is a workaround solution that involves overriding the invokeAxis2 method. Here’s how you can implement this approach:

  1. Create a custom activity that extends the standard connect-soap functionality
  2. Override the invokeAxis2 method to capture HTTP headers before they’re processed
  3. Store these headers in properties that you can access after the service call

Here’s a code snippet that shows the general approach (you’ll need to adapt this for reading headers rather than setting them):

Options options = new Options();
java.util.List list = new java.util.ArrayList();
com.pega.apache.commons.httpclient.Header header = new com.pega.apache.commons.httpclient.Header();

 
// For reading headers, you'd need to access them after the service call
// The response object will contain the HTTP headers
client.setOptions(options);

 
// After executing the service call, you can extract headers like this:
// This is conceptual and would need to be adapted to your specific implementation
org.apache.axis2.context.MessageContext responseMessageContext = client.getMessageContext();
Object httpHeadersObj = responseMessageContext.getProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS);
if (httpHeadersObj instanceof java.util.List) {
    java.util.List httpHeaders = (java.util.List)httpHeadersObj;
    // Process headers as needed
}

Alternative approaches you might consider:

  1. Use Connect-REST instead: If possible, REST connectors offer more direct access to HTTP headers through their response structure.
  2. Use Java Steps in Activity: If the SOAP call is made from within an activity, you could replace the connector with direct Java code that gives you complete control over the HTTP request and response.
  3. Proxy Service: Create an intermediary service that captures all HTTP headers and includes them in the response payload.

References:
Requirement to add endpointURL in HTTP header of Connect SOAP
How to add HTTP header to Connect-SOAP
Need to send Custom HTTP Header in Connect Soap request