msxml使用MS DOM和经典asp解析SOAP响应

msxml使用MS DOM和经典asp解析SOAP响应

问题描述:

我正在使用经典的“ASP”不会让我起来。只是还没有能够跳转到.Net呢。我只是在学习soap,并且已经成功地为web服务创建了一个SOAP请求。但是,我无法弄清楚如何解析响应并拉出单个节点。我正在使用MS DOM将响应加载到文档中。我可以得到屏幕响应。我尝试了以下,但我无法单独获取任何nodes_text。msxml使用MS DOM和经典asp解析SOAP响应

'Set the XML Object 
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM") 

'Set Asynchoronous = false 
xmlDoc.async = False 

'Load the XML file. 
'User Server.MapPath method is the XML is located in your site. 
'Else you can use the absolute path. 

xmlDoc.Load (strResult) 

'If there is any errors pasring the file the notify 

If xmlDoc.parseError.errorCode = 0 Then 

Response.Write "Error Parsing XML" 

Response.Write "Rason :" & xmlDoc.parseError.reason & "Error Line: " & xmlDoc.parseError.line 

End If 

'Get ALL the Elements by the tag name book 

Set sessionid = xmlDoc.getElementsByTagName("session_id") 

'Now Iterate through the List and Display 
response.write"sessionid ="&sessionid&"<BR>" 
For i = 0 to (sessionid.Length-1) 
    Response.Write "session_id " & sessionid.item(i).childNodes(0).text & "<br/>" 

Next 

这里是我试图解析

<ns:getSessionResponse xmlns:ns="http://services.axis.openmeetings.org"> 
    <ns:return xmlns:ax217="http://basic.beans.data.app.openmeetings.org/xsd" 
       xmlns:ax218="http://basic.beans.hibernate.app.openmeetings.org/xsd" 
       type="org.openmeetings.app.hibernate.beans.basic.Sessiondata"> 
     <ax218:id>71</ax218:id> 
     <ax218:language_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /> 
     <ax218:organization_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /> 
     <ax218:refresh_time>2010-11-04T15:17:13.717Z</ax218:refresh_time> 
     <ax218:sessionXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /> 
     <ax218:session_id>5f0415d9cdb72681816095debf3735de</ax218:session_id> 
     <ax218:starttermin_time>2010-11-04T15:17:13.717Z</ax218:starttermin_time> 
     <ax218:storePermanent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /> 
     <ax218:user_id xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /> 
    </ns:return> 
</ns:getSessionResponse> 

我需要从这种消减拉SESSION_ID只是不似乎能够做到这一点的响应。是的,我正在寻找移动到.NET很快。

+0

响应示例的格式似乎在翻译中丢失了。你能再次包含XML响应吗? – jveazey 2010-11-04 20:34:40

如果strResult是一个URL到XML文件,那么你可以使用:

xmlDoc.Load(strResult) 

但如果strResult代表XML的内容,你需要使用:

xmlDoc.LoadXML(strResult) 

欲了解更多信息,请参阅MSDN