日期:2014-05-17  浏览次数:20644 次

【help】掉用webservice时候报错,如下
使用的是 tomcat + axis2(其中利用了rampart模块)调用的时候 报错

Exception in thread "main" org.apache.axis2.AxisFault: SOAP message MUST NOT contain a Document Type Declaration(DTD)

我的demo图


------解决方案--------------------
字面理解是xml里面不能包含dtd
在你的transportutils.createsoapmessage里面报的错、你打个断点跟一下吗
webservice也是能打断点得呀
------解决方案--------------------
类型有错误啊~
------解决方案--------------------
http://download.csdn.net/detail/s478853630/4200795
或许对你有帮助
------解决方案--------------------
Java code
public class AxisClient {

    public static void main(String[] args) throws Exception {

        String targetEndPoint = "http://localhost:8080/Asix2Demo/services/HelloWorld";
        Service ser = new Service();
        try {
            Call call = (Call) ser.createCall();
            call.setTargetEndpointAddress(targetEndPoint);
            call.setOperationName(new QName(targetEndPoint, "hello" ));
            call.setOperation("hello");
            String result = (String) call.invoke(new Object[] { new String("张三") });
            System.out.println("result=" + result);
            //call.setOperation("add");
            //int addResult = (Integer) call.invoke(new Object[] {new Integer(1), new Integer(1) });
            //System.out.println("addResult=" + addResult);
        } catch (ServiceException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }

    }

------解决方案--------------------
Java code

//直接调url就可以吧?
String para = "";//参数
String url = "http://192.198.1.1:80/Database.asmx/Method?para="+para;

DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); 
DocumentBuilder builder=factory.newDocumentBuilder(); 
org.w3c.dom.Document doc = builder.parse(url);

org.w3c.dom.NodeList list =doc.getElementsByTagName("Table");
//然后循环去读List吧。。。
//类似于这样//list.item(i).getChildNodes().item(1).getChildNodes().item(0).getNodeValue()