日期:2014-05-18  浏览次数:20822 次

WebService问题,急求!!!
本帖最后由 XIAyuzheng 于 2013-06-17 00:28:51 编辑
所用的是cxf2.7.5
所导入的jar包,如图:


客户端代码:

package org.lee;

import org.ws.HelloWorldInterface;
import org.ws.impls.HelloWorldImpls;

public class ClientMain {

public static void main(String[] args) {

HelloWorldImpls factory=new HelloWorldImpls();
//此处返回的是 远程WebService的代理.
HelloWorldInterface helloWorldInterface= factory .getHelloWorldImplsPort();
System.out.println(helloWorldInterface.sayHi("夏煜正"));
}

}


所报的异常:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Cannot create a secure XMLInputFactory
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:171)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:94)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:240)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
at $Proxy29.sayHi(Unknown Source)
at org.lee.ClientMain.main(ClientMain.java:13)


Java WebService 异常 XMLInputFactory

------解决方案--------------------
可以看下你生成的几个类吗?你可能是调用的时候出错了!
------解决方案--------------------
楼主是跟着视频做,然后遇到这个问题的吗?用的是cxf2.7的版本?我也遇到了,不知道怎么解决啊
------解决方案--------------------
+    private static boolean setRestrictionProperties(XMLInputFactory factory) {
+        //For now, we can only support Woodstox 4.2.x and newer as none of the other
+        //stax parsers support these settings
+        if (setProperty(factory, "com.ctc.wstx.maxAttributesPerElement", maxAttributeCount)
+            && setProperty(factory, "com.ctc.wstx.maxAttributeSize", maxAttributeSize)
+            && setProperty(factory, "com.ctc.wstx.maxChildrenPerElement", innerElementCountThreshold)
+            && setProperty(factory, "com.ctc.wstx.maxElementCount", maxElementCount)
+