8 Replies Latest reply on Feb 7, 2013 1:43 PM by Keith Babo

    JAXB Transformer for document/literal wrapped SOAP

    Calvin Chu Newbie

      Hi,

       

      I tried the transform-jaxb quickstarts and it perfectly transform the SOAP message body using JAXB, but when I try to generate the WSDL again with the option [Use "wrapped" message] checked, the transformation is not working anymore, below exception is raised

       

      Caused by: org.switchyard.exception.SwitchYardException: org.switchyard.exception.SwitchYardException: Failed to unmarshall for 'java:org.switchyard.quickstarts.transform.jaxb.Order'.

          at org.switchyard.component.soap.InboundHandler.invoke(InboundHandler.java:229) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

          at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:113) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

          at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:43) [switchyard-component-soap-0.7.0.Final.jar:0.7.0.Final]

          at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source) [:1.6.0_37]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_37]

          at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_37]

          at org.jboss.ws.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:111)

          at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:181)

          ... 31 more

       

      I use SoapUI as client and I think it is failed because the <order> node in the request is wrapped by the <urn:submitOrder>, can SwitchYard ignore the operation name in the SOAP body for document/literal wrapped style ? Thanks!

        • 1. Re: JAXB Transformer for document/literal wrapped SOAP
          Rob Cernich Master

          This is a shot in the dark, but when you configured the soap binding on the promoted servce did you check "Unwrapped Payload"?

          • 2. Re: JAXB Transformer for document/literal wrapped SOAP
            Calvin Chu Newbie

            It turns out adding <soap:messageComposer unwrapped="true"/> in the binding configuration, I tried both true and false value and JAXB transform failed in both cases

            • 3. Re: JAXB Transformer for document/literal wrapped SOAP
              Magesh Bojan Master

              can SwitchYard ignore the operation name in the SOAP body for document/literal wrapped style ? Thanks!

              From the description here it seem to say exactly that https://issues.jboss.org/browse/SWITCHYARD-809.

               

              It turns out adding <soap:messageComposer unwrapped="true"/>

               

              What is the error message that you get when this is set to true? Could you enable trace logging using this handler in your config

              <domain>
                  <handlers>
                      <handler class="org.switchyard.handlers.MessageTrace" name="MessageTrace"/>
                  </handlers>
              </domain>
              
              • 4. Re: JAXB Transformer for document/literal wrapped SOAP
                Calvin Chu Newbie

                Thanks for your reply. Please find below the message trace when <soap:messageComposer unwrapped="true"/>

                ------- Begin Message Trace -------

                Service -> {urn:switchyard-quickstart:transform-jaxb:1.0}OrderService

                Operation -> submitOrder

                Phase -> IN

                State -> OK

                Exchange Context ->

                Message Context ->

                    org.switchyard.messageId : 328d66db-d41f-4fad-800c-624ea68ba74d

                    org.switchyard.contentType : {urn:switchyard-quickstart:transform-jaxb:1.0}submitOrder

                    org.switchyard.soap.messageName : submitOrder

                Message Content ->

                <?xml version="1.0" encoding="UTF-8"?><order>

                            <orderId>1</orderId>

                            <itemId>2</itemId>

                            <quantity>3</quantity>

                         </order>

                ------ End Message Trace -------

                08:29:53,673 INFO  [org.switchyard.handlers.MessageTrace] (http--0.0.0.0-8080-1)

                ------- Begin Message Trace -------

                Service -> {urn:switchyard-quickstart:transform-jaxb:1.0}OrderService

                Operation -> submitOrder

                Phase -> OUT

                State -> FAULT

                Exchange Context ->

                    org.switchyard.exchangeDurationMS : 32

                    org.switchyard.exchange.transaction.beforeInvoked : true

                Message Context ->

                    org.switchyard.relatesTo : 328d66db-d41f-4fad-800c-624ea68ba74d

                    org.switchyard.messageId : d6424234-7c0b-49d7-9f8c-053709275cdf

                Message Content ->

                org.switchyard.HandlerException: org.switchyard.exception.SwitchYardException: Failed to unmarshall for 'java:org.switchyard.quickstarts.transform.jaxb.Order'.

                --- Caused by org.switchyard.exception.SwitchYardException: Failed to unmarshall for 'java:org.switchyard.quickstarts.transform.jaxb.Order'.

                --- Caused by javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"order"). Expected elements are <{urn:switchyard-quickstart:transform-jaxb:1.0}order>,<{urn:switchyard-quickstart:transform-jaxb:1.0}orderAck>

                ------ End Message Trace -------

                 

                Here is the SOAP message sent from SoapUI

                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:switchyard-quickstart:transform-jaxb:1.0">

                   <soapenv:Header/>

                   <soapenv:Body>

                      <urn:submitOrder>

                         <!--Optional:-->

                         <order>

                            <orderId>1</orderId>

                            <itemId>2</itemId>

                            <quantity>3</quantity>

                         </order>

                      </urn:submitOrder>

                   </soapenv:Body>

                </soapenv:Envelope>

                 

                From the message trace, it was complainting that order should be under namespace {urn:switchyard-quickstart:transform-jaxb:1.0}order, so, I changed the SOAP request as below,

                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:switchyard-quickstart:transform-jaxb:1.0">

                   <soapenv:Header/>

                   <soapenv:Body>

                      <urn:submitOrder>

                         <urn:order>

                            <orderId>1</orderId>

                            <itemId>2</itemId>

                            <quantity>3</quantity>

                         </urn:order>

                      </urn:submitOrder>

                   </soapenv:Body>

                </soapenv:Envelope>

                And it works ! But I am expecting the client would generate their own classes with the WSDL as standard WS and I am not able to enfore the format of the SOAP request. Does SwitchYard able to propagate the namespace to child node when a message is unwrapped ? Or there is something we can do in the JAXB annotation / ObjectFactory ?

                 

                I have my project src attached, only change is adding name in the @XmlType for Order and OrderAck object (otherwise WSDL won't generate) and changing {urn:switchyard-quickstart:transform-jaxb:1.0}order to {urn:switchyard-quickstart:transform-jaxb:1.0}submitOrder in jaxb tranform. Thank you very much !

                • 5. Re: JAXB Transformer for document/literal wrapped SOAP
                  Calvin Chu Newbie

                  I get it working by removing the package-info.java so the JAXB can unmarshal the SOAP message,

                   

                  my SOAP request

                  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:switchyard-quickstart:transform-jaxb:1.0">

                     <soapenv:Header/>

                     <soapenv:Body>

                        <urn:submitOrder>

                           <!--Optional:-->

                           <order>

                              <orderId>1</orderId>

                              <itemId>2</itemId>

                              <quantity>3</quantity>

                           </order>

                        </urn:submitOrder>

                     </soapenv:Body>

                  </soapenv:Envelope>

                  and getting response

                  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

                     <SOAP-ENV:Header/>

                     <SOAP-ENV:Body>

                        <submitOrder xmlns="urn:switchyard-quickstart:transform-jaxb:1.0">

                           <ns2:submitOrderResponse xmlns:ns2="urn:switchyard-quickstart:transform-jaxb:1.0">

                              <orderId>1</orderId>

                              <accepted>true</accepted>

                              <status>Order Accepted</status>

                           </ns2:submitOrderResponse>

                        </submitOrder>

                     </SOAP-ENV:Body>

                  </SOAP-ENV:Envelope>

                   

                  However, from SoapUI the expected response format is

                  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:switchyard-quickstart:transform-jaxb:1.0">

                     <soapenv:Header/>

                     <soapenv:Body>

                        <urn:submitOrderResponse>

                           <!--Optional:-->

                           <orderAck>

                              <orderId>?</orderId>

                              <accepted>?</accepted>

                              <status>?</status>

                           </orderAck>

                        </urn:submitOrderResponse>

                     </soapenv:Body>

                  </soapenv:Envelope>

                   

                  Looks like the XmlRootElement <orderAck> is missing during the marshalling, anything wrong with the JAXB annotations ?

                  • 6. Re: JAXB Transformer for document/literal wrapped SOAP
                    Keith Babo Master

                    There's a bug in the unwrap logic in SOAP message composer *and* an issue with JAXB unmarshaling that impacts doc-lit wrapped (the transform "to" definition is assumed to be the root element name).  Would you mind filing a JIRA and we'll get this fixed up in 0.8?  Unfortuantely, this means that response messages using the unwrap feature of SOAP gateway with JAXB transformers will not work in 0.7.  As a workaround, you could use a Java transformer and handle the JAXB unmarshaling yourself for the return message.  That will only be necessary in 0.7 though - this will be fixed for 0.8.

                     

                    thanks,

                    keith

                    • 8. Re: JAXB Transformer for document/literal wrapped SOAP
                      Keith Babo Master

                      The fix for this has been pushed and is available in the latest nightly build (0.8.0-SNAPSHOT).