Tomcat - 轴 1.4 - org.xml.sax.SAXParseException;行号:x;列号:y;字符引用“&#
Tomcat - Axis 1.4 - org.xml.sax.SAXParseException; lineNumber: x; columnNumber: y; Character reference "&#
我们正在从 Weblogic 迁移到 Tomcat。
在 Weblogic 中,我们使用 weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask
和 ant 从 WSDL 生成 web 服务客户端 jar。
在 Tomcat 中,我们尝试将 Axis 1.4 与 Maven 结合使用,以生成相同的 Web 服务客户端。
其中一个 Web 服务调用正在响应以下示例:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Tue, 04 Jul 2017 20:35:37 GMT
Connection: close
Content-Length: 898
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body>
<MyRequestResponse xmlns="http://tempuri.org/">
<MyRequestResult>~BLDSQPQP(........)2678700000 000 </MyRequestResult>
</MyRequestResponse>
</s:Body></s:Envelope>
但是,当我们 invoke/call Axis 1.4 生成的 web 服务客户端时,我们遇到运行时异常:
org.xml.sax.SAXParseException; lineNumber: x; columnNumber: y; Character reference "&#
Axis 的 SAX 解析器似乎不期望 XML 实体在 & 之后带有 #。
遗憾的是,我们无法更改网络服务响应的 behavior/content。
有没有办法在客户端解决这个问题,例如,禁用 XML 验证或让它理解那些实体?
调用客户端的代码:
service = new BrowserServiceLocator();
service.setEndpointAddress("HttpWebService", webserviceUrl);
IBrowserService myService = (IBrowserService) service.getHttpWebService();
myResponse = myService.myRequest(object, verb, user.getMyUser(), user.getCenter(), inputData);
注意:我们目前无法更新到 Axis 2,因为我们使用的是 RPC 编码的 WSDL。
编辑 - 请在下面查看 Weblogic 如何处理此字符。
在 Eclipse 调试器中(使用 Weblogic)
在 Notepad++ 中(如上所述使用 Weblogic 检索响应)
Tomcat 能够处理这类字符,但 axis 的 XML 解析器不能。
尝试使用过滤器拦截响应并用 space 替换错误字符以保持响应结构(如果这对您很重要):
How to write response filter?
显然,如果可能,请修复在响应中向您的应用发送此类字符的服务。
我们正在从 Weblogic 迁移到 Tomcat。
在 Weblogic 中,我们使用 weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask
和 ant 从 WSDL 生成 web 服务客户端 jar。
在 Tomcat 中,我们尝试将 Axis 1.4 与 Maven 结合使用,以生成相同的 Web 服务客户端。
其中一个 Web 服务调用正在响应以下示例:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Tue, 04 Jul 2017 20:35:37 GMT
Connection: close
Content-Length: 898
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body>
<MyRequestResponse xmlns="http://tempuri.org/">
<MyRequestResult>~BLDSQPQP(........)2678700000 000 </MyRequestResult>
</MyRequestResponse>
</s:Body></s:Envelope>
但是,当我们 invoke/call Axis 1.4 生成的 web 服务客户端时,我们遇到运行时异常:
org.xml.sax.SAXParseException; lineNumber: x; columnNumber: y; Character reference "&#
Axis 的 SAX 解析器似乎不期望 XML 实体在 & 之后带有 #。 遗憾的是,我们无法更改网络服务响应的 behavior/content。
有没有办法在客户端解决这个问题,例如,禁用 XML 验证或让它理解那些实体?
调用客户端的代码:
service = new BrowserServiceLocator();
service.setEndpointAddress("HttpWebService", webserviceUrl);
IBrowserService myService = (IBrowserService) service.getHttpWebService();
myResponse = myService.myRequest(object, verb, user.getMyUser(), user.getCenter(), inputData);
注意:我们目前无法更新到 Axis 2,因为我们使用的是 RPC 编码的 WSDL。
编辑 - 请在下面查看 Weblogic 如何处理此字符。
在 Eclipse 调试器中(使用 Weblogic)
在 Notepad++ 中(如上所述使用 Weblogic 检索响应)
Tomcat 能够处理这类字符,但 axis 的 XML 解析器不能。
尝试使用过滤器拦截响应并用 space 替换错误字符以保持响应结构(如果这对您很重要): How to write response filter?
显然,如果可能,请修复在响应中向您的应用发送此类字符的服务。