'How to force XJB to generate the classes, marshalling the XML code with the namespace without prefix independently on exact namespace value?

I have the situation there is an web service implemented in old Visual Studio 2008, which accepts the SOAP requests with content having namespaces only in this form:

<Root xmlns="http://A">
    <A>
       <A1 />
    </A>
    <B xmlns="http://B">
       <B1 />
    </B>
 </Root>

All other forms of the XML (unqualified, or qualified with namespace prefix) are causing problems even if the wsdl and referenced xsd structures are manipulated and modified in various ways and the service is recompiled in Visual Studio 2008, the author of the ASP.NET web service is not able to get any other form of XML working.

Is there any way how to achieve the generation of the classes for our Java client accessing this web service by using the external JAXB binding specification, used during the class generation, so the XML would be from the objects marshalled in the above described form?

Am I right, if I think, this could be achieved by the forcing the JAXB to generate the class(ses in multiple directories) package-info.java instead of the default form

@javax.xml.bind.annotation.XmlSchema(
  namespace = "http://some/custom/namespace", 
  elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package some.custom.namespace;

in the following form?

@javax.xml.bind.annotation.XmlSchema(
  namespace = "http://some/custom/namespace", 
  elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
  xmlns = {@XmlNs(prefix = "", namespaceURI = "http://some/custom/namespace")})
package some.custom.namespace;
  • and if I am right, is there any way to do it? I am unfamiliar with writing the XJB bindings, so any pointer would be appreciated...

Or maybe, after the generation the source code of this class should be postprocessed by something like ant task, which would modify the initially generated JAXB form into the form I think it was the desired content of the class package-info.java?

Could this be somehow achieved by one universal jxb binding file for all usages without necessity to modify it for every namespace folder creating its own package?

I hope this could really work even with multiple different namespaces without prefixes, because the xmlns definitions are then used in JAXBContextImpl as a set of XmlNs types, so if there is an prefix or not hopefully should not matter... Am I right?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source