[英]Name cannot begin with the '<' character hexadecimal value 0x3c
I'm trying to get some data from a WebService using SOAP request.我正在尝试使用 SOAP 请求从 WebService 获取一些数据。 The SOAP body should contain an SQL query.
SOAP 主体应包含 SQL 查询。 Whenever I'm using the
<
character it causes the above mentioned error at SOAPReqBody.LoadXml()
.每当我使用
<
字符时,它都会导致SOAPReqBody.LoadXml()
出现上述错误。 How can I fix this?我怎样才能解决这个问题?
HttpWebRequest request = CreateSOAPWebRequest();
XmlDocument SOAPReqBody = new XmlDocument();
SOAPReqBody.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
<Query xmlns=""http://LifaOIS.DK/OISService"">
<UID>" + uid + @"</UID>
<PWD>" + pwd + @"</PWD>
<SQL>" + sql + @"</SQL>
<Meta>" + meta + @"</Meta>
</Query>
</soap:Body>
</soap:Envelope>");
This is ugly but if you really have to carry a SQL query within the message payload and the less than '<' character is a problem within the XML and you can't control packing and unpacking of the payload, then you might like to consider using BETWEEN...这很难看,但是如果您确实必须在消息有效负载中携带 SQL 查询,并且小于“<”字符是 XML 中的问题并且您无法控制有效负载的打包和解包,那么您可能需要考虑使用之间...
WHERE field NOT EQUAL minValue AND field BETWEEN minvalue AND upperValue
Note that BETWEEN's from and to values are inclusive - hence the need for the exclusion of minValue请注意,BETWEEN 的 from 和 to 值是包容性的 - 因此需要排除 minValue
Have you tried wrapping your sql
in <.[CDATA[...]]>
?您是否尝试将
sql
包装在<.[CDATA[...]]>
中?
Like:喜欢:
<SQL><![CDATA[" + sql + @"]]></SQL>
Instead of代替
<SQL>" + sql + @"</SQL>
See What does <?[CDATA[]]> in XML mean?请参阅XML 中的 <?[CDATA[]]> 是什么意思? for more details.
更多细节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.