xml文件如下:
<?xml version = "1.0" ?>
<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"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsa:Action>urn:SumMtoN</wsa:Action>
<wsa:MessageID>uuid:88dbfb0a-0b8c-470d-a0cf-5716e3f6f117</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:To>http://localhost:2000/axis2/services/WS_rampart3</wsa:To>
<wsse:Security soap:mustUnderstand="1">
<wsu:Timestamp wsu:Id="Timestamp-f9782b0b-dc61-4926-a8e9-d90da4b3a259">
<wsu:Created>2012-06-30T03:04:08Z</wsu:Created>
<wsu:Expires>2012-06-30T03:09:08Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken>
<wsse:Username>axis2</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">rampart</wsse:Password>
<!--<wsse:Nonce>uv++05ae3bvoziMQfTTG/w==</wsse:Nonce>-->
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<SumMtoN xmlns="http://service.rampart.tutorial">
<x>1</x>
<y>100</y>
</SumMtoN>
</soap:Body>
</soap:Envelope>
c#代码获取【wsse:UsernameToken】Xmlelement
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\Documents and Settings\10015042\My Documents\Visual Studio Projects\Webservice\Webservice\SOAP.xml");
XmlNamespaceManager nm = new XmlNamespaceManager(doc.NameTable);
nm.AddNamespace("soap","http://schemas.xmlsoap.org/soap/envelope/");
nm.AddNamespace("wsse","http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
XmlNode xn = doc.SelectSingleNode("/soap:Envelope/soap:Header/wsse:Security/wsse:UsernameToken",nm);
XmlElement ele = (XmlElement)xn;
MessageBox.Show(ele.OuterXml);