1 2 Previous Next 16 Replies Latest reply on Nov 11, 2014 11:00 AM by ozkin

    How to generate transformers for invoking external soap web service

    nmalhotra

      I am trying to create a switchyard application to invoke external soap web services, I am stuck at couple of things and need some advice
      I have created a dummy switch yard project.I did the following so far:

      1) Created a service
      2) Created a Bean
      3) Created a reference from the wsdl file from the external web services
      5) Created Java classes from the wsdl, by right clicking reference and using the option ‘Generate Java Interface’
      6) Created Java classes from xsd shared by external web services using JAXB plugin in eclipse

       

      When I created the reference the ‘Create required Transformer’ check box was checked/selected by default and I even didn’t have the option to check/ uncheck it. It didn’t create the transformers, I was hoping that it would auto generate transformers in the switchyard xml.

      Also, when I right click the composite and go to properties > Transform I don’t see any transformers and when I try to add one from the add option, it displays a pop-up saying ‘All required transforms are created’.

       

      Can you please guide me on the following?

      1) How can I auto generate the transformers or would I need to create them manually using @Transformer?
      2) Is there a way to test this locally using Junit etc i.e. to call the search/execute method in the web service and  debug it to see what’s happening. I tried using HTTPMixIn, but was no success?

      I have read couple of Jboss article which says, that the 'create required transforms' is editable only if there are no transformers in the project. In this case I don't have any.

       

      Also, I am referring the below link, is there any other link that can be useful in this case?

      https://developer.jboss.org/wiki/ConnectingJava-basedSwitchYardCompositesWithSOAPWebServicesTutorial

       

      Many thanks in advance

        • 1. Re: How to generate transformers for invoking external soap web service
          rcernich

          You will need to add transformers to your configuration.  Since you're using JAXB, you simply need to tell SwitchYard to use it when transforming between those types.  Right-click on the wire (or composite) and select "Create required transformers."  Select the type pairs (from/to) that you want and select JAXB for the type.  This will add the appropriate configuration to your switchyard.xml file and you should be good to go.

           

          Hope that helps,

          Rob

          1 of 1 people found this helpful
          • 2. Re: How to generate transformers for invoking external soap web service
            nmalhotra

            Hi Rob,


            Many Thanks for the reply.


            I tried it but it displays a pop-up saying 'All required transformers have been created'


            Kind Regards,

            Nishtha

            • 3. Re: How to generate transformers for invoking external soap web service
              jorgemoralespou_2

              Hi,

              Guessing here, but I think that the problem is that both ends of your wire are using same interface, so no transformers are required. This happens if you have a Java interface at the composite reference or a wsdl interface at the component reference.

              If you post the switchyard.xml it might be easier to help.

               

              Cheers

              1 of 1 people found this helpful
              • 4. Re: Re: How to generate transformers for invoking external soap web service
                nmalhotra

                Hi Jorge,

                 

                Thanks for replying.

                 

                Please find attached the switchyard.xml.

                 

                Thanks,

                Nishtha

                • 5. Re: How to generate transformers for invoking external soap web service
                  jorgemoralespou_2

                  Hi Nishtha,

                  Composite seems fine, with a java interface at component reference promoted as a wsdl interface at composite reference. Of course, it needs the transformers, so my take here is that it is a bug on JBDS.

                   

                  My suggestions is adding the lines for the transformers manually and see if it works, and if it does, create a JIRA for the bug.

                   

                  And don't take my word for granted, I do not develop switchyard, I'm just a long time follower.

                  • 6. Re: How to generate transformers for invoking external soap web service
                    nmalhotra

                    Hi Jorge,

                     

                    Thanks for replying.

                     

                    I could generate the transformers some how. Had to delete the component reference (on the left), re-create and then generate wsdl from it. And on right click, generate tranfomers option, generated the transformer for me, but they need to be modified as per the reques to be sent to the external web service.

                    I am trying that just now.

                     

                    On my second question in the same post, Is there sample qucikstart available which I can refer to create a test client to debug the request and transformers being sent to the web service. I am trying to test the web service from soapUI but it is not of much help, I am not able to connect.

                     

                    Many thanks.

                    • 7. Re: How to generate transformers for invoking external soap web service
                      kcbabo

                      One possibility is that the following interface has annotations which map the operation type to the same type name used in the WSDL:

                      com.example.switchyard.poc.chi.wsdl.generated.model.CHISearchSoap

                       

                      That's really just a guess though.  Can you attach the entire project?

                      • 8. Re: How to generate transformers for invoking external soap web service
                        jorgemoralespou_2

                        Hi,
                        We have been experiencing the same behavior here, all required transformers are there. I can not add the switchyard.xml (as it is sensitive) but some tips.

                        It has 2 composite services (both SOAP bindings with different wsdl definition) and one of the services has properly configured the transformers to the component (java). I guess that once we added the second composite service is when it didn't detect any new transformers.

                        • 9. Re: How to generate transformers for invoking external soap web service
                          nmalhotra

                          Hi Jorge,

                           

                          Try removing both the soap bindings and add both the wsdl again one by one. It should allow you to check-uncehck the ' create required transformer' check box and select the type of transformers you want.

                           

                          Kind Regards,

                          Nishtha

                          • 10. Re: How to generate transformers for invoking external soap web service
                            jorgemoralespou_2

                            Thanks Nishtha,

                            I did add them manually, but I guess that this is a bug, since having to do this is not straight forward. I'll raise a JIRA.

                            • 11. Re: How to generate transformers for invoking external soap web service
                              ozkin

                              Hi all,

                               

                              I have a similar issue as the author of this thread. When we say "generated transformers" do we mean the following lines (or similar) in switchyard.xml or really additional Java code?

                               

                              <sy:transforms>

                                <transform:transform.jaxb from="java:java.lang.String" to="{urn:com:example:webservice}doSomething"/>

                                <transform:transform.jaxb from="{urn:com:example:webservice}doSomething" to="java:java.lang.String"/>

                              </sy:transforms>

                               

                              In my case above lines were automatically generated into switchyard.xml, but no any Java code was generated. Is that all right?

                               

                              I am still getting Failed to unmarshal exceptions.. but maybe it is a different issue...

                              • 12. Re: How to generate transformers for invoking external soap web service
                                ozkin

                                hmm.. I just noticed that methods with @XmlElementDecl were not generated... is it a feature of JBDS?

                                • 13. Re: How to generate transformers for invoking external soap web service
                                  jorgemoralespou_2

                                  Hi Max,

                                  If you select JAXB as the required transformers, you need to provide with those JAXB classes. You can simply execute wizard for "Create Java Classes from WSDL" and then add @XMLRooElement annotation to those classes.

                                  Transformations are not automagic, the only thing that JBDS provides is with the ability to detect the missing transforms. You need to provide with the implementation though.

                                  And of course, if doing a transform like the one you are showing, probably you should do it in Java, as with JAXB will be complex. Otherwise, create wrapper objects, or unwrap the payload at the binding.

                                   

                                  Cheers,

                                  • 14. Re: How to generate transformers for invoking external soap web service
                                    ozkin

                                    Hi Jorge,

                                    Thanks for your reply.

                                    Yes, I already had Java classes generated by selecting "Create Java Classes from WSDL". I also already had automatically generated @XmlRootElement annotation for those classes.

                                    The only missing bit was @XmlElementDecl annotated methods in the generated ObjectFactory class, something like this:

                                         @XmlElementDecl(namespace="urn:com:example:webservice", name="requestMsg")

                                         public JAXBElement<RequestMsg> createRequestMsg(RequestMsg value) {

                                              return new JAXBElement<RequestMsg>(_RequestMsg_QNAME, RequestMsg.class, null, value);

                                         }

                                    I had to add such methods manually. I thought those could also be generated.

                                    P.S. RequestMsg is a wrapped object instead of java.lang.String. Transform element in switchyard.xml was changed accordingly.

                                    1 2 Previous Next