Notes when using ASP to call WebService (corrected)

Source: Internet
Author: User

This is an article in July. In fact, we found that this is not the reason at all. I hope you will not be poisoned by it. The real reason is at the bottom of the article:

After a test today, it is found that when the "name" keyword is used as the key value in the XML data returned by WebService, the ASP page cannot read the entire XML document, and the following error occurs:

The XML page cannot be displayed.

XML input cannot be viewed using the XSL style sheet. Correct the error and click Refresh or try again later.

Invalid characters are found in the text. An error occurred while processing the resource 'HTTP: // 192.168.0.41/aspserver/server. asp. Row 56th, Location: 11

    <Name>

// The Server ASP code is as follows. The WebService code is omitted. You only need to return a dataset value.

<%
Set objhttp = server. Createobject ("msxml2.xmlhttp ")
Set xmldoc = server. Createobject ("MSXML. domdocument ")
Strwebserviceurl = "http: // 192.168.0.41/webservice1/service1.asmx/Ds"
'Set parameters and their values
'Strrequest = "x = 2 & Y = 3"
Strrequest = "Fig = 123"
Objhttp. Open "Post", strwebserviceurl, false
'Setting this Content-Type is very important.
Objhttp. setRequestHeader "Content-Type", "application/X-WWW-form-urlencoded"
Objhttp. Send (strrequest)
Bok = xmldoc. Load (objhttp. responsexml)
'Look at the status value
If objhttp. Status = 200 then
Xmlstr = xmldoc. xml
Xmlstr = Replace (xmlstr, "& lt;", "<", 1,-1, 1)
Xmlstr = Replace (xmlstr, "& gt;", ">", 1,-1, 1)
Response. Write xmlstr
Else
Response. Write objhttp. Status & "<br>"
Response. Write objhttp. statustext
End if
%>

'The keyword name cannot be used in Database Design !!!!!!!!!!!!
'1970 note !!!

The real reason is that the storage format of XML files is incorrect. If XML is stored on the hard disk in ANSI format, this error is reported.
This error does not occur when the UTF-8 or 16-bit long encoding format is stored, so the fundamental problem lies in the storage of XML.

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.