如何从轴 Web 服务返回复杂对象
我正在编写一个简单的 Web 服务来返回一个具有 2 个属性的对象。
我正在将该服务嵌入到现有的 Web 应用程序中。
我的 wsdd 看起来像这样。
<globalConfiguration>
<parameter name="adminPassword" value="admin"/>
<parameter name="sendXsiTypes" value="true"/>
<parameter name="sendMultiRefs" value="true"/>
<parameter name="sendXMLDeclaration" value="true"/>
<parameter name="axis.sendMinimizedElements" value="true"/>
<requestFlow>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="session"/>
</handler>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="request"/>
<parameter name="extension" value=".jwr"/>
</handler>
</requestFlow>
</globalConfiguration>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
<service name="helloService" provider="java:RPC" style="document" use="literal">
<parameter name="className" value="ws.example.HelloService"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="application"/>
</service>
我能够成功部署它。
如果我尝试调用返回字符串的方法,它会成功返回字符串。
但是当我调用返回对象的方法时,出现以下错误。
AxisFault 故障代码: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException 故障子代码: 故障字符串: org.xml.sax.SAXParseException: 文件过早结束。故障演员:
故障节点:故障详细信息: {http://xml.apache.org/axis/}stackTrace:org.xml.sax .SAXParseException: 文件过早结束。在 org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(未知 来源)于 org.apache.xerces.util.ErrorHandlerWrapper.fatalError(未知 来源)于 org.apache.xerces.impl.XMLErrorReporter.reportError(未知 来源)于 org.apache.xerces.impl.XMLErrorReporter.reportError(未知 来源)于 org.apache.xerces.impl.XMLVersionDetector.defineDocVersion(未知 来源)于 org.apache.xerces.parsers.XML11Configuration.parse(未知 来源)于 org.apache.xerces.parsers.XML11Configuration.parse(未知 来源)于 org.apache.xerces.parsers.XMLParser.parse(未知 来源)于 org.apache.xerces.parsers.AbstractSAXParser.parse(未知 来源)于 org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(未知 来源)于 javax.xml.parsers.SAXParser.parse(SAXParser.java:395) 在 org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) 在 org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) 在 org.apache.axis.Message.getSOAPEnvelope(Message.java:424) 在 org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796) 在 org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144) 在 org.apache.axis.strategies.InitationStrategy.visit(InitationStrategy.java:32) 在 org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) 在 org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) 在 org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) 在 org.apache.axis.client.Call.invokeEngine(Call.java:2765) 在 org.apache.axis.client.Call.invoke(Call.java:2748) 在 org.apache.axis.client.Call.invoke(Call.java:2424) 在 org.apache.axis.client.Call.invoke(Call.java:2347) 在 org.apache.axis.client.Call.invoke(Call.java:1804) 在 ws.example.ws.HelloServiceSoapBindingStub.getAwardById(HelloServiceSoapBindingStub.java:202) 在 Test.main(Test.java:21)
任何人都可以帮忙吗?
I am writing a simple web service to return an object with 2 properties.
I am embedding the service into an existing web application.
My wsdd looks like this.
<globalConfiguration>
<parameter name="adminPassword" value="admin"/>
<parameter name="sendXsiTypes" value="true"/>
<parameter name="sendMultiRefs" value="true"/>
<parameter name="sendXMLDeclaration" value="true"/>
<parameter name="axis.sendMinimizedElements" value="true"/>
<requestFlow>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="session"/>
</handler>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="request"/>
<parameter name="extension" value=".jwr"/>
</handler>
</requestFlow>
</globalConfiguration>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
<service name="helloService" provider="java:RPC" style="document" use="literal">
<parameter name="className" value="ws.example.HelloService"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="application"/>
</service>
I am able to deploy it successfully.
If I try to invoke the method which returns a String, it is successfully returning the String.
But when I invoke the method which returns an object, I am getting the following error.
AxisFault faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode: faultString:
org.xml.sax.SAXParseException:
Premature end of file. faultActor:
faultNode: faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException:
Premature end of file. at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source) at
org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown
Source) at
org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source) at
org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source) at
org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source) at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source) at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source) at
org.apache.xerces.parsers.XMLParser.parse(Unknown
Source) at
org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source) at
org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source) at
javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at
org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at
org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
at
org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at
org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at
org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at
org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at
org.apache.axis.client.Call.invokeEngine(Call.java:2765)
at
org.apache.axis.client.Call.invoke(Call.java:2748)
at
org.apache.axis.client.Call.invoke(Call.java:2424)
at
org.apache.axis.client.Call.invoke(Call.java:2347)
at
org.apache.axis.client.Call.invoke(Call.java:1804)
at
ws.example.ws.HelloServiceSoapBindingStub.getAwardById(HelloServiceSoapBindingStub.java:202)
at Test.main(Test.java:21)
Can any body help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我根据其他论坛提供的信息对此进行了排序。
如果需要返回复杂类型,我们需要使用
。谢谢。
I sorted this by following information provided at other forums.
We need to use
<beanMapping/>
if complex types need to be returned.Thank you.