The xml file is as follows:
[Html]
<? 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 # obtain the "wsse: UsernameToken" Xmlelement from the code.
[Csharp]
XmlDocument doc = new XmlDocument ();
Doc. Load (@ "C: \ Documents ents and Settings \ 10015042 \ My Documents ents \ Visual Studio Projects \ 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 );
Author: wangxianshou