【问题标题】:com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </span>; expected </br>com.ctc.wstx.exc.WstxParsingException:意外关闭标签</span>;预计</br>
【发布时间】:2020-01-08 01:52:19
【问题描述】:

我使用 CXF wsdl2java 工具创建了存根类。 我正在使用带有 JCIFS 的 Apache CXF 库。我通过几个工具验证了 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】:

    我不知道这是否相关。 我提供的原始 WSDL URL 是这个。 https://ecmchat.mark.gov/BF/BF.asmx 我添加了一个 ?wsdl 如下 https://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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-14
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多