0

We are moving from Weblogic to Tomcat.

In Weblogic, we used weblogic.ant.taskdefs.webservices.clientgen.ClientGenTask, with ant, to generate the webservice client jars from WSDLs. In Tomcat, we are trying to use Axis 1.4 with Maven, to generate the same webservice clients.

One of the webservice calls is responding with the following example:

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(........)26787&#x2;00000  000  </MyRequestResult>
</MyRequestResponse>
</s:Body></s:Envelope>

However, we are getting a runtime exception when we invoke/call the webservice client generated by Axis 1.4:

org.xml.sax.SAXParseException; lineNumber: x; columnNumber: y; Character reference "&#

It appears that the Axis' SAX Parser isn't expecting an XML entity with a # after &. Unfortunately, we can't alter the behavior/content of the webservice responses.

Is there any way to resolve this problem on the client side by, for example, disabling the XML validation or make it understand those entities?

Code invoking the client:

service = new BrowserServiceLocator();
service.setEndpointAddress("HttpWebService", webserviceUrl);
IBrowserService myService = (IBrowserService) service.getHttpWebService();
myResponse = myService.myRequest(object, verb, user.getMyUser(), user.getCenter(), inputData);

Note: we are currently not able to update to Axis 2 because we are using RPC-encoded WSDLs.

EDIT - Please see below how Weblogic was handling this character.

In Eclipse Debugger (using Weblogic) In Eclipse Debugger

In Notepad++ (response retrieved with Weblogic as above) In Notepad

Nuno
  • 3,082
  • 5
  • 38
  • 58
  • 2
    Axis behavior is correct here, see https://stackoverflow.com/a/28152666/180100. See also https://issues.apache.org/jira/browse/AXIS-2025 –  Jul 07 '17 at 17:20
  • @RC. I understand Axis behavior might be correct here. However, I want to still be able to parse the XML (as 1.1 if needed) and make it understand the entities (as they are valid anyway). Is there any way to do it? Thank you. – Nuno Jul 07 '17 at 21:50
  • I would probably workaround by using some request to fetch the content (HttpClient), replace the faulty content (or ` –  Jul 08 '17 at 08:04
  • @RC. Thank you very much. Please see my edit above. Weblogic seems to be able to read the XML entity and handle it in its own way. At least we were able to get the response and process it. With Tomcat and Axis 1.4, we simply don't get the response because it crashes with the above exception. With Axis 2, we just get "null" when we make this request. Do you have any idea whether we could make Tomcat/Axis behave the same way as Weblogic? Very kind regards. – Nuno Jul 09 '17 at 19:53
  • Could you try to start the java vm with -Dfile.encoding=UTF-8? If that does not help try -Dfile.encoding=ISO-8859-1. I know that sounds strange but I found that information as workaround in https://issues.apache.org/jira/browse/AXIS-2342. Maybe that helps in your case too? – Arigion Jul 13 '17 at 12:51

1 Answers1

0

Tomcat is able to process those kind of characters, it's axis' XML parser that can't.

Try to use a Filter to intercept the response and replace the wrong characters with a space to keep the response structure if that's important for you: How to write response filter?

Replace response body using filter

Obviously, if possible, fix the service that's sending your app those kind of characters in the response.

AIF
  • 61
  • 9