Pergunta

How can I return an arbitrary XML document using an Eclipse/AXIS2 POJO Service?

For full background details, see this question: Java Web Service returns string with &gt; and &lt; instead of > and <

To deploy the web service, I have a dynamic web project with a class that defines the interface of my service. The method I am concerned with returns a String type. To create and deploy the web service I right click on the class (contained in the dynamic web project) and select create web service, here I indicate that I want a "Bottom up Java bean Web Service" and that the service implementation comes from the class in my dynamic web project. This starts my service and creates a WSDL that has the definition of my ports and endpoints.

The types section of the wsdl are automatically generated based on the code that will become the service. The function of intrest has an org.w3c.DOM.Document that holds the XML that I want to return. This Document is converted to a string and returned, because the Document object is not serialized and does not have a public constructor. Is there another type that I can use as the return type for my function that will hold the XML structure throught the service call?

Foi útil?

Solução

I don't think it can be done via the technologies and process you are using.

Ideally you could just return a org.w3c.dom.Document (or a comparable DOM object in that framework) and it would supply the "any" type in the WSDL but, unfortunately, it doesn't seem to work like that. AXIS2 is strongly typed and needs a data binding technology (e.g. ADB, XmlBeans, JiBX, possibly JAXB) for request and response data. It seems to have support for the <xsd:any> and <xsd:anyType> elements via AXIOM services, but that is a different implementation style than you are using.

See this interesting discussion "Unknown type can not serialize" Exception. Also, here is a related SO question, AXiS2 - Problem in returning the String value. < and > are getting converted to &lt; and &gt;

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top