1 2 Previous Next 20 Replies Latest reply on Oct 10, 2007 11:05 AM by marklittle

    Will using JAXB Introductions with JBossWS affect the genera

    mstine

      Hi,

      I am attempting to expose a legacy EJB 2.0 service using JBossWS. What I have done is to implement an EJB 3.0 session bean that connects to the EJB 2.0 session bean I want to expose. I defined a method for the service I need and delegated it to the EJB 2.0 bean. The method returns a value object graph that is obviously unannotated since it is living in the Java 1.4.2 world.

      Since we don't have the benefit of generics in 1.4.2, JAXB is unable to discern the type of the Collection based fields in my value object graph. Thus, when JAXB attempts to serialize the response, the context is unaware of several of our classes.

      It seems that JAXB Introductions will do what I need. I have installed it into my copy of JBoss 4.2.0.GA running JBossWS 2.0.0. I put my jaxb-intros.xml file into the META-INF of my service.ejb3 jar file. Here it is:

      <?xml version = "1.0" encoding = "UTF-8"?>
      <jaxb-intros xmlns="http://www.jboss.org/xsd/jaxb/intros">
      
       <Class name="org.stjude.common.object.SampleFront">
       <XmlType name="sampleFront"/>
       <Field name="refToOrder">
       <XmlElement type="org.stjude.common.object.OrderFront"/>
       </Field>
       <Field name="sampleInfo">
       <XmlElement type="org.stjude.app.lims.common.sample.util.SampleInfo"/>
       </Field>
       <Field name="workflow">
       <XmlElement type="org.stjude.common.object.Workflow"/>
       </Field>
       <Field name="workflows">
       <XmlElement type="org.stjude.common.object.Workflow"/>
       </Field>
       </Class>
      
       <Class name="org.stjude.common.object.Workflow">
       <XmlType name="workflow"/>
       <Field name="workflowDetails">
       <XmlElement type="org.stjude.common.object.WorkflowDetail" nillable="true"/>
       </Field>
       </Class>
      
      </jaxb-intros>
      


      This is not the entire graph, but I figured it would be enough to have some affect and see if this will work. What I've noticed is that the WSDL g
      generated for the SampleFront type still shows an untyped Collection for the workflows property:

      <xs:complexType name="sampleFront">
      <xs:sequence>
      <xs:element minOccurs="0" name="refToOrder" type="tns:orderFront"/>
      <xs:element minOccurs="0" name="sampleInfo" type="tns:sampleInfo"/>
      <xs:element minOccurs="0" name="workflow" type="tns:workflow"/>
      <xs:element maxOccurs="unbounded" minOccurs="0" name="workflows" nillable="true" type="xs:anyType"/>
      </xs:sequence>
      </xs:complexType>
      


      Is this what I should expect to see? I was expecting that the workflows property would be properly typed so that JAXB would continue marshalling down that path. If this doesn't happen then the client code I generated from the WSDL will be incomplete.

      Please let me know what the correct behavior should be and also if I have done something incorrect.

      Thanks!

      Matt Stine
      Senior Software Engineer
      Information Sciences
      St. Jude Children's Research Hospital
      Memphis, TN

        • 1. Re: Will using JAXB Introductions with JBossWS affect the ge
          tfennelly

           

          "mstine" wrote:
          What I've noticed is that the WSDL generated for the SampleFront type still shows an untyped Collection for the workflows property:

          <xs:complexType name="sampleFront">
          <xs:sequence>
          <xs:element minOccurs="0" name="refToOrder" type="tns:orderFront"/>
          <xs:element minOccurs="0" name="sampleInfo" type="tns:sampleInfo"/>
          <xs:element minOccurs="0" name="workflow" type="tns:workflow"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="workflows" nillable="true" type="xs:anyType"/>
          </xs:sequence>
          </xs:complexType>
          


          Is this what I should expect to see? I was expecting that the workflows property would be properly typed so that JAXB would continue marshalling down that path. If this doesn't happen then the client code I generated from the WSDL will be incomplete.

          Please let me know what the correct behavior should be and also if I have done something incorrect.


          wsdl2Java/java2wsdl has nothing to do with JAXB Intros, so either I'm not reading your post correctly, or there's something missing in it.

          Check out and play with some of the junit tests in the JAXB Intros codebase. Another thing you can try is to, as a test, implement some of what you're trying to do as JAXB annotated code and then work back from that (once working) by translating those working annotations into an equivalent JAXB Intros config.

          • 2. Re: Will using JAXB Introductions with JBossWS affect the ge
            mstine

            Let me try to restate my question. I have deployed my session bean and annotated it as a web service. I have also added a jaxb-intros.xml file to that deployment. I expected that when JBossWS generated the WSDL for my web service at deployment time that it would properly type the Collections as opposed to giving them the xs:anyType type. If this doesn't happen, then the clients that I generate from this WSDL will be incomplete. As it is I am receiving (javax.xml.bind.JAXBException - "This class" nor any of its super class is known to this context) for all type that reside below the deepest Collection type in my graph.

            Essentially what I want is to be able to marshall this object graph without forcing the legacy codebase to change JDK's and add 1.5 language features. Is there another route I should be taking or will using Introductions accomplish this for me?

            Thanks,

            Matt

            • 3. Re: Will using JAXB Introductions with JBossWS affect the ge
              burrsutter

              It doesn't sound like this question is ESB specific/related. Other than the fact it was ESB that added the JAXB Intros tech.

              Here is another random thought:
              Instead of making the EJB2.x bean a WS, why not write a 181 annotated Web Service (examples in quickstarts webservice_producer and native_client) that serves as a facade for the EJB2x. bean?

              I've not tried it but that would be my initial strategy. I would then have full control over the WS endpoint and then be able to make that into the EJB2.x SLSB any way I wanted.

              Burr

              • 4. Re: Will using JAXB Introductions with JBossWS affect the ge
                mstine

                Burr,

                The only reason I posted here is that this was the suggested location for questions on the Introductions wiki page.

                Perhaps I'm confused, but I think I've already implemented your suggestion. Here is my webservice bean:

                package org.stjude.hc.srm.webservices;
                
                import javax.ejb.Stateless;
                import javax.jws.WebMethod;
                import javax.jws.WebParam;
                import javax.jws.WebService;
                import javax.xml.bind.annotation.XmlSeeAlso;
                
                import org.stjude.app.common.util.DelegateFactory;
                import org.stjude.app.lims.common.delegate.LimsDelegate;
                import org.stjude.common.object.ObjectDetails;
                import org.stjude.common.object.SampleFront;
                import org.stjude.common.object.Deliverable;
                
                @Stateless
                @WebService(name = "ReportsService",
                 serviceName = "ReportsService")
                @XmlSeeAlso(Deliverable.class)
                public class ReportsServiceImpl implements ReportsService {
                
                 /* (non-Javadoc)
                 * @see org.stjude.hc.srm.webservices.ReportsService#getSampleById(java.lang.String)
                 */
                 @WebMethod
                 public SampleFront getSampleById(@WebParam(name = "serviceCode") String serviceCode, @WebParam(name = "sampleId") String sampleId) {
                 LimsDelegate limsDelegate = DelegateFactory.getLimsDelegate(Integer.parseInt(serviceCode));
                 ObjectDetails objectDetails = new ObjectDetails();
                 objectDetails.setAll(true);
                
                 return limsDelegate.getSampleById(Integer.parseInt(sampleId), objectDetails);
                 }
                }
                


                In this code, LimsDelegate is the Business Delegate to the EJB 2.x SLSB in question. This part is actually working perfectly. I can submit the SOAP request and watch the EJB 2.x SLSB fulfill it through the console messages. It's when JAXB attempt to marshall the response back to XML that I'm running into problems.

                • 5. Re: Will using JAXB Introductions with JBossWS affect the ge
                  mstine

                  Oh, please ignore the @XmlSeeAlso annotation....I misunderstood the purpose of that annotation and forgot to take it off.

                  • 6. Re: Will using JAXB Introductions with JBossWS affect the ge
                    burrsutter

                    Very good. You have now entered the area where I know nothing! :-)
                    JAXB Intros is Tom F's baby and he'll have to tell us what incantations and rituals are needed to make this piece of magic work.

                    My next suggestion would be to eliminate the EJB2 from your sample and just use a SampleFront that is constructed programmatically.

                    Now, I'm not sure if JBossWS WSDL generation will respect that that Intros is in place so you might still have to hand tweak the WSDL produced by JBossWS to get it exactly as you would like it.

                    • 7. Re: Will using JAXB Introductions with JBossWS affect the ge
                      tfennelly

                      No Matt, I think what you're trying to do is legit, if I read you correctly - use the jdk1.4 based types from your EJB2 Service to define your webservice interface. If this is the case, this is exactly what JAXB Intros are for.

                      Did you follow this to configure your JBossWS container?

                      • 8. Re: Will using JAXB Introductions with JBossWS affect the ge
                        mstine

                        Yeah I did follow that instruction set exactly. Interestingly enough, it only seems to work on JBossWS 2.0. JBossWS 2.0.1 has a completely different jboss-beans.xml file.

                        It seems to be working because I initially placed my jaxb-intros.xml file into the EAR file's META-INF. When I did that I saw a log message from Introductions stating that it didn't find a configuration. When I moved the jaxb-intros.xml into my EJB jar, that log message disappeared.

                        Is there any way to turn on more verbose logging to see what might be happening? Right now there seems to be no effect on the WSDL with or without the jaxb-intros.xml file.

                        Thanks,
                        Matt

                        • 9. Re: Will using JAXB Introductions with JBossWS affect the ge
                          tfennelly

                           

                          "mstine" wrote:
                          Interestingly enough, it only seems to work on JBossWS 2.0. JBossWS 2.0.1 has a completely different jboss-beans.xml file.


                          Yep, the goalposts have moved in JBossWS 2.0.1 :-( I think they may have had their hands slapped for that though!

                          "mstine" wrote:
                          Is there any way to turn on more verbose logging to see what might be happening?


                          It uses log4j logging, so...., but I'm not sure how much info you'll get and how useful it'll be.

                          "mstine" wrote:
                          Right now there seems to be no effect on the WSDL with or without the jaxb-intros.xml file.


                          So you're talking about the WSDL generated by JBossWS, or are you trying to use the JAXB schemagen tool?

                          Re WSDL generation in JBossWS.... JAXB Intros will have no impact there. Re schemagen... no impart there either... at least I haven't tried and I'm not sure if the hooks are there in JAXB RI.

                          • 10. Re: Will using JAXB Introductions with JBossWS affect the ge
                            mstine

                            So essentially it sounds like I'm going to have to manually construct the WSDL. I'm guessing a correct Introductions configuration would ensure that the XML marshalled from the response would be consistent with the WSDL I write, but it wouldn't help me in generating that WSDL. Am I getting that right?

                            Matt

                            • 11. Re: Will using JAXB Introductions with JBossWS affect the ge
                              marklittle

                              Don't use JBossWS 2.0.1 for now ;-) I'll know more next week.

                              • 12. Re: Will using JAXB Introductions with JBossWS affect the ge
                                tfennelly

                                 

                                "mstine" wrote:
                                So essentially it sounds like I'm going to have to manually construct the WSDL. I'm guessing a correct Introductions configuration would ensure that the XML marshalled from the response would be consistent with the WSDL I write, but it wouldn't help me in generating that WSDL. Am I getting that right?

                                Matt


                                Right.... Generation of the WSDL with JBossWS is a separate issue and you'll need to talk with those guys on their form for help with that.

                                JBossWS 2.x is designed to support multiple SOAP stacks (jbossws-native, cxf, metro etc), so has it's own independent mechanisms for generating the WSDL. The JBossWS native SOAP stack happens to use JAXB for binding, but I guess they don't have a way of hooking into the underlying SOAP stack for WSLD generation. Total speculation though, so take with a grain of salt :-)

                                • 13. Re: Will using JAXB Introductions with JBossWS affect the ge
                                  marklittle

                                   

                                  "tfennelly" wrote:
                                  JBossWS 2.x is designed to support multiple SOAP stacks (jbossws-native, cxf, metro etc), so has it's own independent mechanisms for generating the WSDL. The JBossWS native SOAP stack happens to use JAXB for binding, but I guess they don't have a way of hooking into the underlying SOAP stack for WSLD generation. Total speculation though, so take with a grain of salt :-)


                                  Just a minor correction: JBossWS 2.1.0GA should be the one that supports multiple Web Services stacks.

                                  JBossWS 2.0.1GA should be only bug fixes and no SPI changes. If they can't undo them or do changes in a backwardly compatible more then 2.0.1GA may become 2.1.0GA and what was 2.1.0GA may have to shift up too.

                                  • 14. Re: Will using JAXB Introductions with JBossWS affect the ge
                                    heiko.braun

                                    IMO this is a bug. When the WSDL is generated (deploy time) the JAXBIntros are not taken into account. Currently they get passed along with the MessageContext, which is not available at that time.

                                    1 2 Previous Next