我从Web服务获得一条肥皂消息作为Xdocument,并希望提取会话ID元素以供将来使用。我可以使用下面的代码循环响应,但是如何查询soap以返回sessionid
Dim dnas = From node In Responce.DescendantNodes _
Select node
For Each node In dnas
If TypeOf node Is XElement Then
Debug.Print(DirectCast(node, XElement).Name.ToString)
Else
Debug.Print(node.ToString)
End If
Next
肥皂:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CreateResponse xmlns="http://myweb.com/webservices">
<CreateResult>
<ResultCode>0</ResultCode>
<ResultDescription>Authentication Successful</ResultDescription>
<sessionid>04e1b723-ff93-4af0-94f4-2245ccf11f42</sessionid>
</CreateResult>
</CreateResponse>
</soap:Body>
</soap:Envelope>
答案 0 :(得分:0)
XNamespace ws = "http://myweb.com/webservices";
string sessionId = (string)Response.Descendants(ws + "sessionId").FirstOrDefault();