Axis2 does not return native objects

I wrote several web services where some return a simple string (these work) and others return a list of objects. No, axis2 (1.5.1) cannot handle collection types, so I changed my return type to Object[] , but still get this exception

 [ERROR] java.lang.RuntimeException: org.apache.axis2.AxisFault: Mapping qname not fond for the package: de.ac.dto org.apache.axis2.AxisFault: java.lang.RuntimeException: org.apache.axis2.AxisFault: Mapping qname not fond for the package: de.ac.dto 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.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.axiom.om.OMException: java.lang.RuntimeException: org.apache.axis2.AxisFault: Mapping qname not fond for the package: de.ac.dto at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:260) at org.apache.axiom.om.impl.llom.OMNodeImpl.build(OMNodeImpl.java:335) at org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:737) at org.apache.axiom.om.impl.llom.OMElementImpl.detach(OMElementImpl.java:706) at org.apache.axiom.om.impl.llom.OMNodeImpl.setParent(OMNodeImpl.java:124) 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:381) at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:138) ... 19 more Caused by: java.lang.RuntimeException: org.apache.axis2.AxisFault: Mapping qname not fond for the package: de.ac.dto 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:998) at org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl.next(ADBXMLStreamReaderImpl.java:835) at org.apache.axis2.util.StreamWrapper.next(StreamWrapper.java:71) at javax.xml.stream.util.StreamReaderDelegate.next(StreamReaderDelegate.java:60) at org.apache.axiom.om.impl.builder.SafeXMLStreamReader.next(SafeXMLStreamReader.java:183) at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:597) at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:172) ... 28 more Caused by: org.apache.axis2.AxisFault: Mapping qname not fond for the package: de.ac.dto at org.apache.axis2.databinding.utils.BeanUtil.getPropertyQnameList(BeanUtil.java:117) ... 36 more 

The service is created by a master equipped with an eclipse. Is axis2 unable to return these objects? Only returning primitive types do not match my need.

0
source share
2 answers

Axis cannot find the mapping that is needed to translate objects that you submit via XML. He does not know how to translate XML into an object or vice versa. A good idea is to return an object containing an array of objects.

With Axis, you have to say how to make a mapping between XML and an object. This is determined using the WSDL and the classes themselves.

1) Look at the WSDL generated by the web service: you can find this by looking at http: // localhost: 8080 / Service? Wsdl . Check that this is normal.

2) Axis finds this mapping by looking at the return value of Class.getTypeDesc (); Verify that this match is correct.

For one of my services, I have the following mapping, defined as the return value of a web service (RechercherBatimentRetour class, subclass of Retour class).

 typeDesc.setXmlType(new QName("sbatimentto", "RechercherBatimentRetour")); // 1 org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("batiments"); elemField.setXmlName(new QName("", "batiments")); // 2 elemField.setXmlType(new QName("sbatimentto", "ResumeBatimentTo")); elemField.setNillable(true); typeDesc.addFieldDesc(elemField); 

This defines the return value of this SOAP service.

// 1 → This means that the WSDL ComplexType RechercherBatimentRetour is in the namespace 'sbatimentto'.

// 2 → We add the 'batiments' field to the ComplexType, which is defined through getter and setter in the class as:

 public ResumeBatimentTo[] getBatiments() { return batiments; } public void setBatiments(ResumeBatimentTo[] batiments) { this.batiments = batiments; } 

ResumeBatimentTo is also in the same namespace. So it ends with a WSDL that contains (among others)

  <complexType name = "Retour">
     <sequence>
      <element name = "codeRetour" nillable = "true" type = "xsd: string" />
      <element name = "message" nillable = "true" type = "xsd: string" />
      <element name = "statut" type = "xsd: boolean" />
     </sequence>
     </complexType>

     <complexType name = "RechercherBatimentRetour">
     <complexContent>
      <extension base = "tns1: Retour">
       <sequence>
        <element name = "batiments" nillable = "true" type = "impl: ArrayOf_tns1_ResumeBatimentTo" />
       </sequence>
      </extension>
     </complexContent>
   </complexType>

All classes used must have the correct definitions getTypeDesc, getSerializer, and getDeserializer before they can be used.

+2
source

Actually, the return type of the web service method must be nonequivalent.

it should not be an object or just a list ...

therefore, we return a specific object of the Person class. If one object of the Person class should be returned or if there is a list of objects ..... use ... a list .....

make a change .... and enjoy .... !!!!!

0
source

Source: https://habr.com/ru/post/1445775/


All Articles