Spring Integration
  1. Spring Integration
  2. INT-1532

Add HeaderMapper support for marshalling Web Service gateways and outbound Web Service gateways in general

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 2.0 RC1
    • Fix Version/s: 2.1 RC1
    • Component/s: Web Services
    • Labels:
      None

      Description

      Currently, the HeaderMapper<SoapHeader> can only be configured on a "simple" Web Service inbound gateway (one without a 'marshaller') due to the way we extend the abstract base class for the marshalling gateway. We would need to provide access to the headers at the same time we have the request/response Message context available. OTOH, when Marshalling, one could always map directly to/from Message instances rather than payloads, so maybe it's not a critical feature.

      Another thing that we should consider is adding support for 'mapped-request-headers' and 'mapped-response-headers' attributes rather than only providing the option of referencing the HeaderMapper strategy itself.

        Issue Links

          Activity

          Hide
          Ramanan S added a comment -

          Hi, Will DefaultSoapHeaderMapper (or the like) will be added to SimpleWebServiceOutboundGateway with this fix ?

          Show
          Ramanan S added a comment - Hi, Will DefaultSoapHeaderMapper (or the like) will be added to SimpleWebServiceOutboundGateway with this fix ?
          Hide
          Mark Fisher added a comment -

          Yes, that is the plan. Can you describe what you expect/need from such a mapper?

          Show
          Mark Fisher added a comment - Yes, that is the plan. Can you describe what you expect/need from such a mapper?
          Hide
          Mark Fisher added a comment -

          Moving to 2.0.3.

          Looking forward to getting some use-cases from the community. Feedback is welcome!

          Show
          Mark Fisher added a comment - Moving to 2.0.3. Looking forward to getting some use-cases from the community. Feedback is welcome!
          Hide
          Sukhmeet Sethi added a comment -

          Following use case might help....
          http://forum.springsource.org/showthread.php?p=345561#post345561

          We can create SI headers which can directly be transformed to SOAP Headers with outbound gateway.

          Show
          Sukhmeet Sethi added a comment - Following use case might help.... http://forum.springsource.org/showthread.php?p=345561#post345561 We can create SI headers which can directly be transformed to SOAP Headers with outbound gateway.
          Hide
          Oleg Zhurakousky added a comment -

          Pushing it to 2.1

          One way of accomplishing it would be simply remove MarshallingWebServiceInboundGateway and add marshalling and unmarshalling logic/attributes to SimpleWebServiceInboundGateway, while the benefit of MarshallingWebServiceInboundGateway is that it builds on Spring WS API. However it doesn't give us full access to SOAP Message structure

          Show
          Oleg Zhurakousky added a comment - Pushing it to 2.1 One way of accomplishing it would be simply remove MarshallingWebServiceInboundGateway and add marshalling and unmarshalling logic/attributes to SimpleWebServiceInboundGateway, while the benefit of MarshallingWebServiceInboundGateway is that it builds on Spring WS API. However it doesn't give us full access to SOAP Message structure
          Hide
          Damien Hollis added a comment -

          We have a use case for this:

          We add our own security information in the SOAP header. We have implemented our own SimpleWebServiceInboundGateway that replaces getRequestCallback(Message ...) with:
          protected WebServiceMessageCallback getRequestCallback(@NotNull final Message<?> requestMessage) {
          return new WebServiceMessageCallback() {
          public void doWithMessage(WebServiceMessage webServiceMessage) throws IOException, TransformerException {
          SoapMessage soapMessage = (SoapMessage) webServiceMessage;
          SoapHeader soapHeader = soapMessage.getSoapHeader();

          MessageHeaders headers = requestMessage.getHeaders();

          String headerContent = (String) headers.get(MessageHeaderConstants.SOAP_HEADER_KEY);
          if (headerContent != null)

          { Source unimarketHeaderSource = new StringSource(headerContent); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(unimarketHeaderSource, soapHeader.getResult()); }

          }
          };
          }

          A generic approach for adding headers will be great as long as it supports this use case.

          Show
          Damien Hollis added a comment - We have a use case for this: We add our own security information in the SOAP header. We have implemented our own SimpleWebServiceInboundGateway that replaces getRequestCallback(Message ...) with: protected WebServiceMessageCallback getRequestCallback(@NotNull final Message<?> requestMessage) { return new WebServiceMessageCallback() { public void doWithMessage(WebServiceMessage webServiceMessage) throws IOException, TransformerException { SoapMessage soapMessage = (SoapMessage) webServiceMessage; SoapHeader soapHeader = soapMessage.getSoapHeader(); MessageHeaders headers = requestMessage.getHeaders(); String headerContent = (String) headers.get(MessageHeaderConstants.SOAP_HEADER_KEY); if (headerContent != null) { Source unimarketHeaderSource = new StringSource(headerContent); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(unimarketHeaderSource, soapHeader.getResult()); } } }; } A generic approach for adding headers will be great as long as it supports this use case.
          Hide
          Shirish added a comment -

          My use case.

          using a Marshalling WSOutbound gateway utilizing JAXB2.0 as the marshaller and SOAP1.1 message-factory. All is well until we need to pass the message with a empty SOAPHeader tag.

          I am now required to add a custom header to the message so I try to do so on the MesageBuilder interface. When I do this based on the below example, the header is not added to the outbound message.
          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
          <soapenv:Header/>
          <soapenv:Body>
          <!-- data-->
          </soapenv:Body>
          </soapenv:Envelope>

          Message<String> message1 = MessageBuilder.withPayload("test")
          .setHeader("foo", "bar")
          .build();

          Also, we need to add the header with a custom namespace. Current setHeader method signature for : "org.springframework.integration.support.MessageBuilder<T>" has setHeader(String headerName, Object headerValue)
          Can we extend to add a custom namespace as well.

          Required SOAP XML structure:

          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
          <soapenv:Header>
          <abc:customID xmlns:abc="http://abc.com/abc">static value</abc:traceID>
          </soapenv:Header>
          <soapenv:Body>
          <!-- Maps to the JAXB object that corresponds perfectly to the SOAP Body to Message Payload.
          </soapenv:Body>
          </soapenv:Envelope>

          Show
          Shirish added a comment - My use case. using a Marshalling WSOutbound gateway utilizing JAXB2.0 as the marshaller and SOAP1.1 message-factory. All is well until we need to pass the message with a empty SOAPHeader tag. I am now required to add a custom header to the message so I try to do so on the MesageBuilder interface. When I do this based on the below example, the header is not added to the outbound message. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <!-- data--> </soapenv:Body> </soapenv:Envelope> Message<String> message1 = MessageBuilder.withPayload("test") .setHeader("foo", "bar") .build(); Also, we need to add the header with a custom namespace. Current setHeader method signature for : "org.springframework.integration.support.MessageBuilder<T>" has setHeader(String headerName, Object headerValue) Can we extend to add a custom namespace as well. Required SOAP XML structure: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <abc:customID xmlns:abc="http://abc.com/abc">static value</abc:traceID> </soapenv:Header> <soapenv:Body> <!-- Maps to the JAXB object that corresponds perfectly to the SOAP Body to Message Payload. </soapenv:Body> </soapenv:Envelope>

            People

            • Assignee:
              Oleg Zhurakousky
              Reporter:
              Mark Fisher
            • Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: