removing/extracting soap header and body from soap message

后端 未结 1 1016
醉梦人生
醉梦人生 2021-01-17 01:45

I have a soap message shown below. I would like to get only request element and its child nodes.




        
1条回答
  •  时光说笑
    2021-01-17 02:08

    You have the wrong namespace in your second example, and you didn't follow the complete example from the linked answer.

    XNamespace.Get("soap="http://www.w3.org/2003/05/soap-envelope")
    

    The parameter passed in to XNamespace.Get should be the URI only:

    XNamespace.Get("http://www.w3.org/2003/05/soap-envelope")
    

    Then your second example will return something like:

    
      
      
    
    

    If you want just the child(ren) elements of the Body, then you need to add FirstNode like this:

    SoapBody = myXDocument.Descendants(Xns + "Body").First().FirstNode.ToString()
    

    Which will give you this:

    
    
    

    0 讨论(0)
提交回复
热议问题