AXiS2 - problem when returning String value. <and> are converted to & lt; and & gt;

I wrote a simple web service that takes a string as an argument and returns String output.

The service looks something like this:

 @WebService(name = "MyWebService", serviceName = "MyWebService", portName = "WS") @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) public class MyWebService { @WebMethod(action = "inputString") @WebResult(name = "resultString") public String serviceMethod( @WebParam(mode = WebParam.Mode.IN, name = "inputString") String inputString) { resultString ="<?xml version='1.0' encoding='UTF-8'?><Element><InnerElement>ElementValue</InnerElement></<Element>" System.out.println(resultString); return resultString; } } 

On the client side, I get:

 &lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;Element&gt;&lt;InnerElement&gt;ElementValue&lt;/InnerElement&gt;&lt;/&lt;Element&gt; 

This input is used in a third-party parser that tries to find <or> and my application breaks.

Anyone facing this problem? What could be the problem and work? Suggestions are welcome.

+1
source share
2 answers

I admit that I do not spend much time studying it, but the last time I looked, there was no good way to return an XML document as part of another XML document, which is basically what you are trying here. From what I remember, even CDATA partitions can cause problems. What you see is the standard encoding for these characters in XML. If I remember correctly my XML header, which messed up the CDATA sections, but then again, I looked at it for a long time.

NTN

+3
source

You probably have xsd: string in WSDL, so it should convert the special characters '<', '>' because it is just a string. Change wsdl document to ex. XSD :. any

0
source

All Articles