我一直在尝试使用 Eclipse Juno、Maven 和 java2wsdl 插件部署 Apache Axis2 WebService。但是,我一直遇到一个问题,我认为这是由于映射造成的,希望有人能指出我正确的方向。
我试图在我的 WebService 上调用一个操作,该操作接受一个参数并返回一个自定义对象,但到目前为止还没有运气。
我的代码
为了说话,我有以下课程:
package com.example.models;
public class MyClass {
// Does something
}
我在以下操作中返回一个 MyClass 列表:
package com.example.service;
import com.example.models;
public class MyService {
public List<MyClass> getExampleData(// a parameter) {
// Do something
return aListOfMyClass;
}
}
我的 services.xml 文件:
<serviceGroup>
<service name="MyWebService" targetNamespace="http://com.example.service.MyWebService/">
<description>JNLPGenerator service</description>
<schema schemaNamespace="http://com.example.service.MyWebService/" />
<parameter name="ServiceClass" locked="false">com.example.service.MyWebService</parameter>
<operation name="getExampleData">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
</serviceGroup>
错误:
当我部署 WebService 时,我收到以下错误消息,这是由于未映射类 MyClass。
<Exception>org.apache.axis2.AxisFault: org.apache.axis2.AxisFault: Mapping qname not fond for the package: com.example.models
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:161)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:135)
at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130)
at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:817)
at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: org.apache.axis2.AxisFault: Mapping qname not fond for the package: com.example.models
at org.apache.axis2.databinding.utils.BeanUtil.getPropertyQnameList(BeanUtil.java:261)
at org.apache.axis2.databinding.utils.BeanUtil.getPullParser(BeanUtil.java:67)
at org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl.processProperties(ADBXMLStreamReaderImpl.java:994)
at org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl.next(ADBXMLStreamReaderImpl.java:831)
at org.apache.axis2.util.StreamWrapper.next(StreamWrapper.java:71)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:672)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
at org.apache.axiom.om.impl.llom.OMSerializableImpl.build(OMSerializableImpl.java:78)
at org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:745)
at org.apache.axiom.om.impl.llom.OMElementImpl.detach(OMElementImpl.java:723)
at org.apache.axiom.om.impl.llom.OMNodeImpl.setParent(OMNodeImpl.java:105)
at org.apache.axiom.om.impl.llom.OMElementImpl.addChild(OMElementImpl.java:297)
at org.apache.axiom.om.impl.llom.OMElementImpl.addChild(OMElementImpl.java:213)
at org.apache.axiom.soap.impl.llom.SOAPBodyImpl.addChild(SOAPBodyImpl.java:231)
at org.apache.axis2.rpc.receivers.RPCUtil.processResponseAsDocLitWrapped(RPCUtil.java:422)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:138)
... 25 more
Caused by: org.apache.axis2.AxisFault: Mapping qname not fond for the package: com.example.models
at org.apache.axis2.databinding.utils.BeanUtil.getPropertyQnameList(BeanUtil.java:117)
... 40 more
</Exception>
所以我想知道的是如何做到这一点。我读过类似的帖子,但老实说,我仍然不明白我必须在哪里添加这个映射来解决问题。还只是指出 Web 服务的部署很好,而且 wsdl 也可以很好地生成。
对不起,很长的帖子,但希望有人可以帮助我..