WebService SOAP messages are interactive in XML format, where the delivery of special characters cannot be resolved, resulting in data processing failure.
The workarounds are as follows:
1, before sending the message, the Base64 transcoding for the message, after escaping to avoid the message contains special characters.
The standard Base64, which starts with a%, assumes that it is stored in a database and queried in sql, which resolves to a wildcard character, which results in an error.
After the search using the improved version of Base64 for transcoding, to circumvent the problem, the details of the Niang a bit.
The disadvantage of this approach is that all clients need to know how to decode, otherwise they cannot parse.
2. In XML, it is not good to use CDATA to tag special characters in such a way that they are parsed.
At present, there are 2 shortcomings, one is the need for each of the special characters are converted, first of all I do not know what should be used to join? <! [cdata[]]> is the time when the property value is set, or when the message is last generated;
And using this, the data cannot contain characters such as [[]]. It is troublesome to infer this, and if you know how to solve this problem, please advise me. I am also just a web-learning.
3, still have to study what object of, did not study very much, please everybody discuss what mean:
The XML string is returned to the client via XML Document object, and the XmlDocument cannot be returned to the client directly, because the XML document object in Java cannot be interpreted correctly, we can only return the XML string:
Public String Getallnewspace () {
Document document = Documenthelper.createdocument ();
Element root=document.addelement ("root");
..............................
if (null! = DataSet) {
while (Dataset.next ()) {
Element user=root.addelement ("user");
Element username=user.addelement ("UserName");
Username.settext (dataset.getstring (1));
Element userid=user.addelement ("UserId");
Userid.settext (dataset.getstring (2));
}
}
return Document.asxml ();
}