如何使用Eclipse/AXIS2 POJO服务返回任意XML文档 [英] How to return arbitrary XML Document using an Eclipse/AXIS2 POJO Service

查看:131
本文介绍了如何使用Eclipse/AXIS2 POJO服务返回任意XML文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Eclipse/AXIS2 POJO服务返回任意XML文档?

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

有关完整背景的详细信息,请参见以下问题: Java Web Service返回带有& gt;和& lt;而不是>和<

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

要部署Web服务,我有一个动态Web项目,其中包含一个定义服务接口的类.我关注的方法返回String类型.要创建和部署Web服务,请右键单击该类(包含在动态Web项目中),然后选择创建Web服务",此处表示我需要自下而上的Java Bean Web服务",并且该服务的实现来自于我的动态网络项目中的课程.这将启动我的服务,并创建一个具有我的端口和端点定义的WSDL.

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.

wsdl的类型部分是根据将成为服务的代码自动生成的. intrest函数具有一个org.w3c.DOM.Document,该文件包含我要返回的XML.该Document转换为字符串并返回,因为Document对象未序列化并且没有公共构造函数.我是否可以将其他类型用作函数的返回类型,以在整个服务调用中保留XML结构?

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?

推荐答案

我认为无法通过您使用的技术和过程来完成.

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

理想情况下,您可以只返回一个org.w3c.dom.Document(或该框架中的一个类似DOM对象),它将在WSDL中提供"any"类型,但不幸的是,它似乎无法正常工作. AXIS2是强类型的,并且需要用于请求和响应数据的数据绑定技术(例如ADB,XmlBeans,JiBX,可能是JAXB).它似乎通过

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.

请参阅此有趣的讨论 未知类型无法序列化"异常 .另外,这是一个相关的SO问题, AXiS2-返回字符串值时出现问题. <和>正在转换为& lt;和& gt;

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;

这篇关于如何使用Eclipse/AXIS2 POJO服务返回任意XML文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆