5 Replies Latest reply on Jul 29, 2014 11:39 AM by jorgemoralespou_2

    How to get access to http headers in SOAP binding service

    jorgemoralespou_2

      Hi,

      I want to do similar functionality as done with other product and I need to have a service exposed as SOAP binding and have access to http headers also, cause we use a custom http header for internal purposes, and want to do some logic on this http header, although the service is SOAP.

       

      I have enabled message tracing and it seems none http header is progressed, I have added .* as well as http.* and no header is progressed/displayed, but it is in an http/rest service.

        • 1. Re: How to get access to http headers in SOAP binding service
          kcbabo

          Hmm ... SOAP and HTTP headers should be added to the context for SOAP bindings.  Do you have an example project which demonstrates the problem?

          • 2. Re: Re: How to get access to http headers in SOAP binding service
            jorgemoralespou_2

            Hi,

            Following up on this:

             

            Sample project here: jorgemoralespou/fsw-poc-soap-rest-camel · GitHub

             

            Sample project has SOAP binding, passing all http headers in message composer (.*) and logging in camel route all headers with: <to uri="log:com.mycompany.order?showAll=true"/>

             

            I'm sending 2 custom http headers, checked they are coming in:

            13:57:54,293 FINE  [org.apache.cxf.transport.http.Headers] (http-/127.0.0.1:8080-5) Request Headers: {accept-encoding=[gzip,deflate], connection=[Keep-Alive], Content-Length=[478], content-type=[text/xml;charset=UTF-8], custom=[hello], host=[localhost:8080], myheader=[test], SOAPAction=[""], user-agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
            

             

            But in MessageTrace from SwitchYard does not appear:

            ------- Begin Message Trace -------
            Consumer -> {urn:com.example.switchyard:soap:1.0}Payment
            Provider -> [unassigned]
            Operation -> transferFunds
            MEP -> IN_OUT
            Phase -> IN
            State -> OK
            Exchange Context -> 
              CamelCreatedTimestamp ..........................: Fri Jul 25 13:48:48 CEST 2014
              CamelFilterMatched .............................: false
              CamelToEndpoint ................................: direct://%7Burn:com.example.switchyard:soap:1.0%7DPayment
              org.switchyard.bus.camel.consumer ..............: ServiceReference [name={urn:com.example.switchyard:soap:1.0}Payment, interface=SWITCHYARD010007: BaseServiceInterface [type=wsdl, operations=[SWITCHYARD010008: transferFunds : IN_OUT : [{http://ws.camelcookbook.org/payment-service/types}transferRequest, {http://ws.camelcookbook.org/payment-service/types}transferResponse, null]]], domain=ServiceDomain [name=null]]
              org.switchyard.bus.camel.contract ..............: org.switchyard.metadata.BaseExchangeContract@6b4c37a1
              org.switchyard.bus.camel.dispatcher ............: org.switchyard.bus.camel.ExchangeDispatcher@4ca8ebd2
              org.switchyard.bus.camel.labels ................: {org.switchyard.exchangeGatewayName=[org.switchyard.label.behavior.transient], org.switchyard.exchangeInitiatedNS=[org.switchyard.label.behavior.transient], org.switchyard.security.context.SecurityContext=[org.switchyard.label.behavior.transient]}
              org.switchyard.bus.camel.phase .................: IN
              org.switchyard.bus.camel.replyHandler ..........: org.switchyard.component.common.SynchronousInOutHandler@58d8620f
              org.switchyard.exchangeGatewayName .............: soap1
              org.switchyard.exchangeInitiatedNS .............: 10403850359902
              org.switchyard.security.context.SecurityContext : DefaultSecurityContext@1712190554[systemUUID=d2e95bde-29c9-4972-a76e-8c5170581f37, expirationMillis=0, credentials=[ConfidentialityCredential@505771278[confidential=false]], securityDomainsToSubjects={}]
            Message Context -> 
              Accept ...................................................: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
              breadcrumbId .............................................: ID-localhost-localdomain-39600-1406288868146-3-19
              org.switchyard.bus.camel.labels ..........................: {org.switchyard.contentType=[org.switchyard.label.behavior.transient], org.switchyard.bus.camel.messageSent=[org.switchyard.label.behavior.transient], {http://ws.camelcookbook.org/payment-service/types}amount=[org.switchyard.label.component.soap, org.switchyard.label.endpoint.soap], Accept=[org.switchyard.label.endpoint.http, org.switchyard.label.component.soap]}
              org.switchyard.bus.camel.messageSent .....................: true
              org.switchyard.contentType ...............................: {http://ws.camelcookbook.org/payment-service/types}transferRequest
              org.switchyard.messageId .................................: ID-localhost-localdomain-39600-1406288868146-3-19
              org.switchyard.soap.messageName ..........................: TransferRequest
              {http://ws.camelcookbook.org/payment-service/types}amount : 1000
            Message Content -> 
            <typ:transferRequest xmlns:typ="http://ws.camelcookbook.org/payment-service/types">
              <typ:bank>My Bank</typ:bank>
              <typ:from>Jorge</typ:from>
              <typ:to>Another person</typ:to>
              <typ:amount>1000</typ:amount>
              </typ:transferRequest>
            ------ End Message Trace -------
            

             

            Debugged with help of Keith to https://github.com/jboss-switchyard/components/blob/master/soap/src/main/java/org/switchyard/component/soap/endpoint/BaseWebService.java#L86

            And only mime header is: Accept

             

            This is FSW 6.0.0

             

            Hope with this info Magesh can track down the problem, if any. I will wait for comments to open JIRA.

             

            Thanks

            • 3. Re: Re: How to get access to http headers in SOAP binding service
              jorgemoralespou_2

              Hi,

              Added an http binding, that also prints headers, to show how http bindings does good. Soap ui can send same request to both endpoints.

              • 4. Re: Re: How to get access to http headers in SOAP binding service
                jorgemoralespou_2

                Hi,

                I have modified the project to have same component (loggin my http header) with 3 bindings (rest, soap and http). It seems that only SOAP does not work.

                Soapui project has 3 endpoints configured, can be tested with same request.