Java 无法通过web服务方法返回org.w3c.dom.Document

Java 无法通过web服务方法返回org.w3c.dom.Document,java,xml,web-services,axis2,Java,Xml,Web Services,Axis2,我试图从JavaAxis2 web服务返回一个XML文档对象。当我试图在客户端获取文档对象时,它会给我这些异常 org.apache.axis2.AxisFault: org.apache.axis2.AxisFault: Mapping qname not fond for the package: com.sun.org.apache.xerces.internal.dom at org.apache.axis2.util.Utils.getInboundFaultFromMessa

我试图从JavaAxis2 web服务返回一个XML文档对象。当我试图在客户端获取文档对象时,它会给我这些异常

org.apache.axis2.AxisFault: org.apache.axis2.AxisFault: Mapping qname not fond for the package: com.sun.org.apache.xerces.internal.dom
    at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at com.turnkey.DataCollectorStub.getData(DataCollectorStub.java:194)
    at com.turnkey.TestClient.main(TestClient.java:28)
我不能从Web服务返回文档对象吗?? 但此服务确实返回XML字符串

下面是我正在使用的方法的伪代码

import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public Document getData(args)
    {
     String xmlSource = "/*XML string*/";
     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     DocumentBuilder builder = factory.newDocumentBuilder();
     Document xmlDoc = builder.parse(new InputSource(new StringReader(xmlSource)));
     return xmlDoc;
    }
顺便说一句,这个方法在服务器端可以正常工作,但是在客户端我无法接收Document对象


任何人都可以帮助我。

Simple way不使用
文档
作为返回值,因为axis2在模式中找不到合适的导入。如果每次生成wsdl时都应该将import org.w3c.dom.Document添加到wsdl模式(这是一个不方便的解决方案)。这就是为什么在我看来,最好的方法是返回特定的实体

 public Credit[] getCreditList(){
            Credit[] credits = null;
            try {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder documentBuilder = factory.newDocumentBuilder();
                Document xmlDoc = documentBuilder.parse(XML_REAL_PATH);

                Element root = xmlDoc.getDocumentElement();

                List<Credit> creditsList = new ArrayList<>();

            NodeList creditNodes = root.getElementsByTagName(CREDIT);
            int countCreditNodes = creditNodes.getLength();

            for (int i = 0; i < countCreditNodes; i++) {
                Element creditElement = (Element) creditNodes.item(i);

                Credit credit = new Credit();

                Element child = (Element) creditElement.getElementsByTagName(OWNER).item(0);
                String owner = child.getFirstChild().getNodeValue();
                credit.setOwner(owner);

                //...
                creditsList.add(credit);
            }
            credits = creditsList.toArray(new Credit[creditsList.size()]);

        } catch (SAXException | IOException | ParserConfigurationException ex) {
            Logger.getLogger(CreditPayService.class.getName()).log(Level.SEVERE, null, ex);
        }
        return credits;
}
public Credit[]getCreditList(){
Credit[]credits=null;
试一试{
DocumentBuilderFactory工厂=DocumentBuilderFactory.newInstance();
DocumentBuilder DocumentBuilder=factory.newDocumentBuilder();
documentxmldoc=documentBuilder.parse(XML\u REAL\u PATH);
元素根=xmlDoc.getDocumentElement();
List creditsList=新建ArrayList();
NodeList creditNodes=root.getElementsByTagName(CREDIT);
int countCreditNodes=creditNodes.getLength();
对于(int i=0;i