简体   繁体   English

名称不能以 '<' 字符十六进制值 0x3c 开头

[英]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.

相关问题 XDocument错误名称不能以&#39;&lt;&#39;字符开头,十六进制值0x3C - XDocument Error Name cannot begin with the '<' character, hexadecimal value 0x3C WCF服务参考 - 获取“XmlException:名称不能以&#39;&lt;&#39;字符开头,十六进制值0x3C”在客户端 - WCF Service Reference - Getting “XmlException: Name cannot begin with the '<' character, hexadecimal value 0x3C” on Client Side &#39;&lt;&#39;,十六进制值 0x3C,是无效的属性字符 - '<', hexadecimal value 0x3C, is an invalid attribute character DataContractSerializer-名称不能以“。”开头 字符,十六进制值0x2E - DataContractSerializer - Name cannot begin with the '.' character, hexadecimal value 0x2E 名称不能以&#39;&#39;字符开头,十六进制值0x20 - Name cannot begin with the ' ' character, hexadecimal value 0x20 名称不能以“1”字符开头,十六进制值0x31。 从xml文件中读取时 - Name cannot begin with the '1' character, hexadecimal value 0x31. while reading from an xml file 将Firebase广告添加到Xamarin.Forms会导致:名称不能以&#39;$&#39;字符开头,十六进制值为0x24 - Adding Firebase Ads to Xamarin.Forms causes: Name cannot begin with the '$' character, hexadecimal value 0x24 使用xslt时,名称不能以&#39;=&#39;字符十六进制值0x3d开头 - Name cannot begin with the '=' character hexadecimal value 0x3d when use xslt xml.Linq:“名称不能以 &#39;?&#39; 开头字符,十六进制值 0x3F&quot; - xml.Linq: "Name cannot begin with the '?' character, hexadecimal value 0x3F" 名称不能以“1”字符开头,十六进制值0x31。 第2行,第2位 - Name cannot begin with the '1' character, hexadecimal value 0x31. Line 2, position 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM