2014-04-07 4 views
0

웹 서비스의 비누 메시지를 Xdocument로 가지고 있으며 나중에 사용할 수 있도록 세션 id 요소를 추출하려고합니다. 나는 아래의 코드를 사용하여 응답을 통해 루프 수 있어요,하지만 어떻게 내가 세션 id를Query Xdocument

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
XNamespace ws = "http://myweb.com/webservices"; 
string sessionId = (string)Response.Descendants(ws + "sessionId").FirstOrDefault(); 
+0

감사 마틴, 즉 도움 제비. – joebohen