com.ctc.wstx.exc.WstxParsingException:意外的结束标记;预期

问题描述 投票:0回答:1

我使用CXF wsdl2java工具创建了存根类。我正在将Apache CXF库与JCIFS一起使用。我通过几个工具验证了WSDL文件本身,这很好。这是代码。看来我必须做一些设置。

// JCIFS认证相关代码

jcifs.Config.setProperty("jcifs.smb.client.domain", "NTS");
jcifs.Config.setProperty("jcifs.netbios.wins", "ecmchat.mark.gov");
jcifs.Config.setProperty("jcifs.smb.client.soTimeout", "300000"); // 5 minutes
jcifs.Config.setProperty("jcifs.netbios.cachePolicy", "1200"); // 20 minutes
jcifs.Config.setProperty("jcifs.smb.client.username", "user");
jcifs.Config.setProperty("jcifs.smb.client.password", "password");

//Register the jcifs URL handler to enable NTLM
jcifs.Config.registerSmbURLHandler();

// WSDL和客户端设置

URL wsdlURL = BF.WSDL_LOCATION;
if (args.length > 0 && args[0] != null && !"".equals(args[0])) {
    File wsdlFile = new File(args[0]);
    try {
        if (wsdlFile.exists()) {
            wsdlURL = wsdlFile.toURI().toURL();
        } else {
            wsdlURL = new URL(args[0]);
        }
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}

BF ss = new BF(wsdlURL, SERVICE_NAME);
BFSoap port = ss.getBFSoap12();

Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();

HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();

httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(32000);

http.setClient(httpClientPolicy);

//调用方法

System.out.println("Invoking testMethod...");
String _testMethod__return = port.testMethod();
System.out.println("testMethod.result=" + _testMethod__return);

我收到以下异常

Caused by: com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </span>; expected </br>.
 at [row,col,system-id]: [59,22,"https://ecmchat.mark.gov/BF/BF.asmx"]
    at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:621)
    at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:491)
    at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:475)
    at com.ctc.wstx.sr.BasicStreamReader.reportWrongEndElem(BasicStreamReader.java:3365)
    at com.ctc.wstx.sr.BasicStreamReader.readEndElem(BasicStreamReader.java:3292)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2911)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1123)
    at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1361)
    at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1255)
    at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1183)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:235)
    ... 9 more

如果我注释掉JCIFS NTLM身份验证代码,则会收到HTTP 401错误。因此,我相信,至少它正在通过某种授权步骤。

并且,如果我使用本地WSDL代替远程URL WSDL,则在该方法的调用上会出现不同的错误,例如“未实现方法”。可能是由于我没有正确使用本地WSDL。我什至不知道我们是否可以将本地WSDL参考用于远程服务。

然后,我使用此WSDL创建了一个SoapUI虚拟服务,并且相同的代码(但没有JCIFS身份验证代码)可以很好地工作,并成功地调用了这些方法。

在我看来,我必须在与配置相关的代码中添加一些更适当的设置。对于NTLM身份验证和Apache CXF,我对吗,您知道吗?

但是解析错误令人困惑???

cxf cxf-client
1个回答
0
投票

我不知道这是否相关。我给的原始WSDL URL是这个。https://ecmchat.mark.gov/BF/BF.asmx我添加了一个如下所示的?wsdlhttps://ecmchat.mark.gov/BF/BF.asmx?wsdl然后我遇到了另一个错误。

我想知道为什么如果我访问同一WSDL服务的本地SoapUI版本而不是远程服务,为什么它会起作用。

Invoking testMethod...
Jan 07, 2020 10:47:25 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {https://ecmchat.mark.gov}BF#{https://ecmchat.mark.gov}testMethod has thrown exception, unwinding now
java.lang.UnsupportedOperationException: Method not implemented.
    at java.net.URLStreamHandler.openConnection(URLStreamHandler.java:96)
    at java.net.URL.openConnection(URL.java:1028)
    at org.apache.cxf.transport.https.HttpsURLConnectionFactory.createConnection(HttpsURLConnectionFactory.java:92)
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit.createConnection(URLConnectionHTTPConduit.java:121)
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit.setupConnection(URLConnectionHTTPConduit.java:125)
    at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:505)
    at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:47)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:441)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:356)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:314)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
    at com.sun.proxy.$Proxy33.testMethod(Unknown Source)
    at edison.learn.BFSoap_BFSoap12_Client.main(BFSoap_BFSoap12_Client.java:90)

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Method not implemented.
    at org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:195)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
    at com.sun.proxy.$Proxy33.testMethod(Unknown Source)
    at edison.learn.BFSoap_BFSoap12_Client.main(BFSoap_BFSoap12_Client.java:90)
Caused by: java.lang.UnsupportedOperationException: Method not implemented.
    at java.net.URLStreamHandler.openConnection(URLStreamHandler.java:96)
    at java.net.URL.openConnection(URL.java:1028)
    at org.apache.cxf.transport.https.HttpsURLConnectionFactory.createConnection(HttpsURLConnectionFactory.java:92)
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit.createConnection(URLConnectionHTTPConduit.java:121)
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit.setupConnection(URLConnectionHTTPConduit.java:125)
    at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:505)
    at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:47)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:441)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:356)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:314)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
    ... 2 more
© www.soinside.com 2019 - 2024. All rights reserved.