WebService solutions for passing special characters

Source: Internet
Author: User
Tags base64 cdata

WebService SOAP messages are interactive in XML format, where the delivery of special characters cannot be resolved, resulting in data processing failure.

The solution is 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 is preceded by%, and if stored in a database and queried in sql, it resolves to a wildcard character, which results in an error.

After the search using the improved version of Base64 transcoding, you can circumvent the problem, specific degree Niang.

The disadvantage of this approach is that all clients need to know how to decode, otherwise they cannot resolve.

2. In XML, use CDATA to tag special characters, which is not very good after analysis.

The current shortcomings have 2, one is required for each special character are converted, first of all I do not know what should be used to add <! [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. If you know how to solve this problem, please advise. 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 through an XML Document object, and the XmlDocument cannot be returned directly to the client because the XML document object in Java cannot be interpreted correctly, and we can only return an 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 ();
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.