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?
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.
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?