如何使用 Eclipse/AXIS2 POJO 服务返回任意 XML 文档
如何使用 Eclipse/AXIS2 POJO 服务返回任意 XML 文档?
有关完整的背景详细信息,请参阅此问题: Java Web 服务返回带有 & 的字符串; > >且<而不是 > <
为了部署 Web 服务,我有一个动态 Web 项目,其中有一个定义服务接口的类。我关心的方法返回一个 String 类型。要创建和部署 Web 服务,我右键单击该类(包含在动态 Web 项目中)并选择创建 Web 服务,这里我指出我想要一个“自下而上的 Java bean Web 服务”,并且该服务实现来自我的动态网络项目中的类。这将启动我的服务并创建一个 WSDL,其中包含我的端口和端点的定义。
wsdl 的类型部分是根据将成为服务的代码自动生成的。 intrest 函数有一个 org.w3c.DOM.Document,它保存我想要返回的 XML。这个Document被转换为字符串并返回,因为Document对象没有序列化并且没有公共构造函数。是否有另一种类型可以用作我的函数的返回类型,该函数将通过服务调用保存 XML 结构?
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 > and < 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这不能通过您正在使用的技术和流程来完成。
理想情况下,您可以只返回一个
org.w3c.dom.Document
(或该框架中的类似 DOM 对象),它将提供 WSDL 中的“any”类型,但不幸的是,它不会似乎就是这样工作的。 AXIS2 是强类型的,需要用于请求和响应数据的数据绑定技术(例如ADB、XmlBeans、JiBX,可能还有JAXB)。它似乎通过 AXIOM 服务,但这与您使用的实现风格不同。请参阅这个有趣的讨论“未知类型无法序列化”异常< /a>.另外,这里有一个相关的问题,AXiS2 - 返回字符串值时出现问题。 <和>正在转换为 <和>
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 < and >