VB6 解析SOAP协议的xml文件的事遇到了奇怪问题!谢谢各位帮忙看看!!非常着急谢谢!!

sky_hebiao 2009-12-08 01:24:36
最近做一个项目,VB客户端调用webservice 有的是AXIS开发,webservice会返回一个对象ReturnDataQuery,这里面报案两个变量,分别是:datas 和returnstatus,调用时生成的xml如下:
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Body>
- <queryCustInfoResponse xmlns:ns="http://webservices.cch.sinosoft.com">
- <ns:return xmlns:ax21="http://webservices.cch.sinosoft.com/xsd" type="com.sinosoft.cch.webservices.ReturnDataQuery">
- <ax21:datas type="com.sinosoft.cch.webservices.QueryInfo">
<ax21:channelType>01</ax21:channelType>
<ax21:contDate>1999-07-03</ax21:contDate>
<ax21:contDetail>3</ax21:contDetail>
<ax21:contPurpose xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:contResult>2</ax21:contResult>
<ax21:serviceType>1</ax21:serviceType>
</ax21:datas>
- <ax21:datas type="com.sinosoft.cch.webservices.QueryInfo">
<ax21:channelType>01</ax21:channelType>
<ax21:contDate>1988-01-01</ax21:contDate>
<ax21:contDetail>3</ax21:contDetail>
<ax21:contPurpose xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:contResult>2</ax21:contResult>
<ax21:serviceType>1</ax21:serviceType>
</ax21:datas>
- <ax21:datas type="com.sinosoft.cch.webservices.QueryInfo">
<ax21:channelType>01</ax21:channelType>
<ax21:contDate>1999-07-03</ax21:contDate>
<ax21:contDetail>6</ax21:contDetail>
<ax21:contPurpose xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:contResult>6</ax21:contResult>
<ax21:serviceType>6</ax21:serviceType>
</ax21:datas>
- <ax21:datas type="com.sinosoft.cch.webservices.QueryInfo">
<ax21:channelType>01</ax21:channelType>
<ax21:contDate>2009-12-08</ax21:contDate>
<ax21:contDetail>客户接</ax21:contDetail>
<ax21:contPurpose xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<ax21:contResult>101</ax21:contResult>
<ax21:serviceType>115</ax21:serviceType>
</ax21:datas>
<ax21:returnStatus>0</ax21:returnStatus>
</ns:return>
</queryCustInfoResponse>
</soapenv:Body>
</soapenv:Envelope>

当我用VB解析时出现了一个很奇怪的问题,VB代码:
Public Function CCGetCustListByCustNo(custNo As String, ByRef ReturnedList() As ReturnCustContInfo) As String
On Error GoTo err
'如果没有连接则重新连接
If Not Me.WSConnectionFlag Then
Dim initstr As String
initstr = Me.Init(Me.WSUrl)
If initstr <> "" Then
CCGetCustListByCustNo = initstr
Exit Function
End If

End If
Dim RetXMLList As IXMLDOMNodeList
Dim ListCount As Integer
Dim ResultXMLList As IXMLDOMNodeList
Set ResultXMLList = Soapclient.queryCustInfo(custNo)
MsgBox "调用完成"
MsgBox ResultXMLList(1).Text '结果是:011999-07-03321
MsgBox ResultXMLList(0).Text 'com.sinosoft.cch.webservices.ReturnDataQuery

MsgBox ResultXMLList(1).childNodes(0).Text '01
MsgBox ResultXMLList(1).childNodes(1).Text '1999-07-03
MsgBox ResultXMLList(1).childNodes(2).Text '3
MsgBox ResultXMLList(1).childNodes(3).Text '空
MsgBox ResultXMLList(1).childNodes(4).Text ’2
MsgBox ResultXMLList(0).childNodes(0).Text 'com.sinosoft.cch.webservices.ReturnDataQuery
MsgBox ResultXMLList(0).childNodes(1).Text '这里会报一个错,未设置对象变量或with block变量

MsgBox ResultXMLList(0).childNodes.length ’1
MsgBox ResultXMLList(0).Text
MsgBox ResultXMLList(1).Text
MsgBox ResultXMLList(0).childNodes(0).Text
If GetReturnCode(ResultXMLList) = 1 Then
ListCount = ResultXMLList(0).childNodes.length
MsgBox ListCount
If ListCount > 0 Then
ReDim ReturnedList(ListCount - 1)
For i = 0 To ListCount - 1
ReturnedList(0).channelType = ResultXMLList(0).childNodes(0).Text '接触渠道
ReturnedList(0).contDate = CStr(ResultXMLList(0).childNodes(1).Text) '接触时间
ReturnedList(0).contDetail = ResultXMLList(0).childNodes(2).Text '客户接触
ReturnedList(0).contPurpose = ResultXMLList(0).childNodes(3).Text '接触目的
ReturnedList(0).contResult = ResultXMLList(0).childNodes(4).Text '接触结果
ReturnedList(0).serviceType = ResultXMLList(0).childNodes(5).Text '业务类型
Next i
End If
CCGetCustListByCustNo = "没有查到您所需要的数据!"

Else
CCGetCustListByCustNo = ""
End If


代码打印出来的结果告诉我,是返回的datas 与 returnstatus 这两个节点的值调换了位置,可是webservice返回的节点并没有问题,我想请教大家如何解决这个问题,谢谢!!!


...全文
113 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
cds27 2009-12-08
  • 打赏
  • 举报
回复
不要用顺序来解析XML。而是应该采用XPATH,按照元素名来进行检索与解析。

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧