5 Replies Latest reply on May 20, 2010 5:05 AM by felix-friedrich

    wsconsume generates JAXBelement<String> instead of just String for xs:string

    vgarmash

      I generated client code for Bing Maps Search Web service using this command:

       

      D:\tools\jboss-portal-2.6.3.GA\bin\wsconsume.bat -k http://dev.virtualearth.net/webservices/v1/metadata/searchservice/dev.virtualearth.net.webservices.v1.search.wsdl
      

       

      It has completed job without errors but in the result I got all xs:string properties mapped as JAXBElement<String>. See attached Credentials.java and Category.java for mapping example.

       

      When I generated client code using wsimport from Sun Metro it didn't do that and xs:string was mapped as plain String.

       

      Please let me know if it is possible to customize the way of mapping xs:string OR convince me that JAXBElement<String> is way much better than String.

       

      P.S. Please do not offer upgrade my JBoss, JBoss-WS or anything because it is not an option for me. We currently stuck with portal 2.6.3 (JBoss AS 4.2.2) and whatever comes with it.

        • 1. Re: wsconsume generates JAXBelement<String> instead of just String for xs:string
          ropalka

          This is the question for JAXB project team on java.net because JBossWS is reusing Sun tools.

          • 2. Re: wsconsume generates JAXBelement<String> instead of just String for xs:string
            vgarmash

            you are right - this is binding customization problem. the issue was fixed when I used customized binding file customForMaps.xml (attached) with following content:

             

            <jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
                xmlns:xs="http://www.w3.org/2001/XMLSchema">
                <jxb:globalBindings generateElementProperty="false" />
            </jxb:bindings>
            

             

            I've added option --binding=<path/to/customForMap.xml> to the command line and finally got correctly generated xs:string properties as lava.lang.String (see attachment)

            • 3. Re: wsconsume generates JAXBelement<String> instead of just String for xs:string
              felix-friedrich

              Hej hej,

               

              in some cases your solution solved my problem. But I still have some cases where the JAXBElement occures in the Java code.

              This definition in the WSDL...

               

              <element name="Name" type="tv:NameType"/>
              <complexType name="NameType">
                   <sequence minOccurs="1" maxOccurs="unbounded">
                        <element name="begin" type="xsd:time" minOccurs="1" maxOccurs="1"/>
                        <element name="end" type="xsd:time" minOccurs="1" maxOccurs="1"/>
                   </sequence>
                        <attribute name="begin" type="tv:AnotherType" use="required"/>
                        <attribute name="end" type="tv:AnotherType" use="optional"/>
              </complexType>

               

              ... will be this Java code:

               

              @XmlElementRefs({
                   @XmlElementRef(name = "begin", namespace = "http://...", type = JAXBElement.class),
                   @XmlElementRef(name = "end", namespace = "http://...", type = JAXBElement.class)
              })
                   protected List<JAXBElement<XMLGregorianCalendar>> beginAndEnd;
                   @XmlAttribute(required = true)
                   protected AnotherType begin;
                   @XmlAttribute
                   protected AnotherType end;

               

               

              I do not know why there is still this occurence of the JAXBElement and it is not very nice to use in the code. Any suggestions/explanations?

               

               

              Thanks,

               

              F.


              • 4. Re: wsconsume generates JAXBelement<String> instead of just String for xs:string
                jim.ma

                Do you really need the  maxOccurs="unbounded" in the  <sequence  minOccurs="1" maxOccurs="unbounded"> ?   This attribute makes JAXB  generate the JAXBElement list .

                 

                If the maxOccurs="unbounded" is what you have to define, then you can try to create another type element for the begin and end  sequence to see if this will resolve your problem .

                • 5. Re: wsconsume generates JAXBelement<String> instead of just String for xs:string
                  felix-friedrich

                  Hej,

                   

                  thanks for your answer, but changing the .wsdl is unfortunately not an option for me.

                   

                   

                  Felix