I am at a loss on this. I have tried many different examples I have by googling but I'm still having issues. This is my XML:
I am trying to get the value of the Token node - "a really long string"Code:<?xml version="1.0" encoding="UTF-8"?> -<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://blah" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> -<soap:Body> -<ProcessRequestResponse xmlns="http://something.com/WebServices/"> -<ProcessRequestResult> -<fiAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://something.com" xsi:schemaLocation="http://some xsd file" xmlns:xenc="http://www.w3.org/2001/xmlenc#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ITI="http://somepage.com/"> +<fiHeader Version="2.2"> -<Response TypeOfResponse="LoginRs" ResponseID="ReqID" More="false"> +<Status> <Token>a really long string</Token> </Response> </fiAPI> </ProcessRequestResult> </ProcessRequestResponse> </soap:Body> </soap:Envelope>
I can get all of the response xml in a textbox so I do know I am getting a response. This is the code I am trying to use:
Any help will be greatly appreciatedCode:Try Dim objRequest As HttpWebRequest = CType(WebRequest.Create("http://some server page.asmx"), HttpWebRequest) Dim StrData As String Dim objXMLDoc As New XmlDocument() objXMLDoc.LoadXml(strSOA) 'xml data to send StrData = objXMLDoc.OuterXml objRequest.Method = "POST" Dim encoding As New System.Text.ASCIIEncoding() Dim byte1 As Byte() = Text.Encoding.UTF8.GetBytes(StrData) objRequest.ContentLength = byte1.Length objRequest.ContentType = "text/xml" objRequest.KeepAlive = False Dim streamToSend As Stream = objRequest.GetRequestStream() streamToSend.Write(byte1, 0, byte1.Length) streamToSend.Close() Dim objResponse As HttpWebResponse = objRequest.GetResponse() Dim StreamReader As StreamReader StreamReader = New StreamReader(objResponse.GetResponseStream()) Dim xmlDoc As New XmlDocument() xmlDoc.LoadXml(StreamReader.ReadToEnd()) txtResponse.Text = Server.HtmlDecode(xmlDoc.InnerXml) '*******This is where it breaks. Nothing is being returned************* Dim request As String = "Response" Dim strToken As XmlNodeList strToken = xmlDoc.DocumentElement.SelectNodes("ProcessRequestResponse") Dim strTokenNode As Xml.XmlNode For Each strTokenNode In strToken txtToken.Text = strTokenNode.SelectSingleNode("Token").InnerText Next StreamReader.Close() Catch ex As Exception txtResponse.Text = ex.Message End Try End Sub




Reply With Quote
