• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Customising wsimport classes

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kia ora - I have a couple of questions about accepted/common practices in web services.

I am using NetBeans to generate the client for a web service. I have approx. zero control over the WSDL and the resulting classes generated by wsimport are pretty dreadful. Is it possible to manually define a class for de-serialising the WS response? At the moment I'm stuck with a List of JAXBElement.class, one List entry for each of the response items.

Also, some of the xml data in the response payload is in a format that would be useful for performing XSL transforms to generate html web controls. Is this a really dumb idea or is this a reasonable practice. It seems a bit silly to convert my xml ws response to Java objects only to then subsequently generate html output from the Java and I find XSL to be much less verbose than the equivalent Java for generating html. If it is possible, how do I access the payload from my app?

Thanks
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David Clarke:
Is it possible to manually define a class for de-serialising the WS response?



You should be able use JAXB Binding Customizations to coerce the code generation process towards classes that are more to your liking.

Outside of NetBeans Axis2 provides the option of using JiBX. Basically you have to provide all the classes and the JiBX mapping for the XML elements in the message - WSDL2Java will then generate the remaining glue code (Starting from WSDL).

Is this a really dumb idea or is this a reasonable practice.



It is reasonable - it just isn't the current default. The default behaviour of the code generation (in an attempt to please the majority of users) attempts to produce code that has the look-and-feel of Java with all its advantages and disadvantages - that doesn't necessarily mean that it is perfect or the best option, especially considering that circumstances always vary.

Again you might be able to use JAXB binding customization to prevent the marshalling to custom Java objects - in the extreme case you may have to doctor the WSDL that you are using and replace the elements in question with <xs:any /> (Mapping of <xs:any />) - "any" is always mapped to org.w3c.dom.Element.
 
David Clarke
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply - I think I'm beginning to get a handle on things. The WSDL for the web service is generated by an object database development environment called Jade. Everything in Jade derives from an Object and this is reflected in the WSDL by for example:

Object is itself defined in WSDL as

This really hoses the generated java type classes, with everything being a list of JAXBElement's. If I edit the WSDL and remove the <xsd:complexContent/> and <xsd:extension/> nodes, i.e. making the sequence a direct child of the parent of <xsd:complexContent/> then the java generated is exactly what I want.

So I guess to rephrase my original question, what is the best way to achieve this? Manually editing the wsdl isn't really a good long term option as far as I can see. I've had a look at javaType binding declarations but don't think that is necessarily the right approach either. Any suggestions?
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic