2010-11-04 34 views
0

我正在使用經典的「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

回答

0

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

xmlDoc.Load(strResult) 

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

xmlDoc.LoadXML(strResult) 

欲瞭解更多信息,請參閱MSDN