ARCIMS Serverlet Connector查询属性,当属性为中文时乱码处理
2008-10-10 14:21
351 查看
问题救助描述:
我用AXL构造了一个SPATIALQUERY,返回字段中有一字段值是中文的(如BUILDLOC),但是我取得的是乱码。我查询的代码是:
Dim arcimsRequest As HttpWebRequest = CType(WebRequest.Create(_serverURL), HttpWebRequest)
arcimsRequest.Method = "POST"
arcimsRequest.ContentType = "application/x-www-form-urlencoded"
arcimsRequest.Timeout = _requestTimeout
Dim postWriter As StreamWriter = New StreamWriter(arcimsRequest.GetRequestStream())
postWriter.Write("<?xml version='1.0' encoding='UTF-8'?>")
postWriter.Write("<ARCXML version='1.1'>")
postWriter.Write(request.AXL)
postWriter.Write("</ARCXML>")
postWriter.Flush()
postWriter.Close()
arcimsRequest.Timeout = 100000 '100秒
Dim arcimsResponse As HttpWebResponse = CType(arcimsRequest.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader(arcimsResponse.GetResponseStream, System.Text.Encoding.Default)
Try
response = sr.ReadToEnd()
Finally
sr.Dispose()
End Try
查了其返回的XML中头一句中有"encoding='GBK'"
我的环境是:WIN2003 SERVER 中文版,ORA 9i ZHS16GBK,IMS 9.2
且使用BUILDLOC显示的中文标注是对的。
另:在请求中,可不可以设置ARCIMS返回的XML的encoding?
问题解决方案:
经过2天的测试,发现竟然是因为ARCIMS92 Serverlet Connector对请求的AXL中单引号处理出错所致!原来这些代码在IMS90中是运行好好的。
最后处理:
Dim strAXL As String = request.AXL
If Not String.IsNullOrEmpty(strAXL) Then 'XML正则化,可以防止返回因请求导致的中文乱码
Dim doc As XmlDocument = New XmlDocument()
doc.LoadXml(strAXL)
If doc.DocumentElement Is Nothing Then
Throw New NullReferenceException("Node not set to instance of an object. Can not parse AxlFragment.")
End If
strAXL = doc.DocumentElement.OuterXml
End If
Dim strRequest As String = "<?xml version=""1.0"" encoding=""UTF-8""?><ARCXML version=""1.1"">" & strAXL & "</ARCXML>"
让XmlDocument去正则化一次请求的AXL,这样就正常了。
我用AXL构造了一个SPATIALQUERY,返回字段中有一字段值是中文的(如BUILDLOC),但是我取得的是乱码。我查询的代码是:
Dim arcimsRequest As HttpWebRequest = CType(WebRequest.Create(_serverURL), HttpWebRequest)
arcimsRequest.Method = "POST"
arcimsRequest.ContentType = "application/x-www-form-urlencoded"
arcimsRequest.Timeout = _requestTimeout
Dim postWriter As StreamWriter = New StreamWriter(arcimsRequest.GetRequestStream())
postWriter.Write("<?xml version='1.0' encoding='UTF-8'?>")
postWriter.Write("<ARCXML version='1.1'>")
postWriter.Write(request.AXL)
postWriter.Write("</ARCXML>")
postWriter.Flush()
postWriter.Close()
arcimsRequest.Timeout = 100000 '100秒
Dim arcimsResponse As HttpWebResponse = CType(arcimsRequest.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader(arcimsResponse.GetResponseStream, System.Text.Encoding.Default)
Try
response = sr.ReadToEnd()
Finally
sr.Dispose()
End Try
查了其返回的XML中头一句中有"encoding='GBK'"
我的环境是:WIN2003 SERVER 中文版,ORA 9i ZHS16GBK,IMS 9.2
且使用BUILDLOC显示的中文标注是对的。
另:在请求中,可不可以设置ARCIMS返回的XML的encoding?
问题解决方案:
经过2天的测试,发现竟然是因为ARCIMS92 Serverlet Connector对请求的AXL中单引号处理出错所致!原来这些代码在IMS90中是运行好好的。
最后处理:
Dim strAXL As String = request.AXL
If Not String.IsNullOrEmpty(strAXL) Then 'XML正则化,可以防止返回因请求导致的中文乱码
Dim doc As XmlDocument = New XmlDocument()
doc.LoadXml(strAXL)
If doc.DocumentElement Is Nothing Then
Throw New NullReferenceException("Node not set to instance of an object. Can not parse AxlFragment.")
End If
strAXL = doc.DocumentElement.OuterXml
End If
Dim strRequest As String = "<?xml version=""1.0"" encoding=""UTF-8""?><ARCXML version=""1.1"">" & strAXL & "</ARCXML>"
让XmlDocument去正则化一次请求的AXL,这样就正常了。
相关文章推荐
- MySQL写入中文乱码之处理character_set_server编码
- MySQL写入中文乱码之处理character_set_server编码
- mysql查询使用Concat中文乱码处理
- mySQL写入中文乱码 免重装 处理character_set_server编码
- Microsoft SQL Server中条件字段是Nvarchar类型的,条件有中文的无法查询的原因及处理方法
- 写了一个查询数据库的程序,不熟的Tomcat6。查询条件为英文时运行正常,为中文时出现乱码。后在tomcap的server.xml中加入useBodyEncodingForURI="true解决了问题
- Python数据库查询中文乱码的问题处理
- Datastage JDBC Connector 中文乱码处理
- 关于使用ThinkPHP从Mssql2005中查询中文乱码的处理
- Linux Ubuntu Server 14.04 LTS 处理中文乱码及vi编辑器操作概要
- 表单提交数据乱码(datatables提交中文查询处理)
- MySQL5.5写入中文乱码之处理character_set_server编码
- Copy函数处理中文注意点,防止乱码
- 如何处理Oracle客户端查询乱码问题
- 命令行操作jar,文件写入中文乱码处理
- 处理中文乱码
- linux中文乱码处理小结
- SQLite数据库中文乱码处理
- linux中文乱码处理小结
- 处理request接收参数的中文乱码的问题