Advertisement
Guest User

Untitled

a guest
Jun 4th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. [XmlRoot("customHeader", Namespace = "http://somecompany.com/webservices/security/2012/topSecret")]
  2. public class customHeader: SoapHeader, IXmlSerializable
  3. {
  4. public customHeader()
  5. {
  6. Actor = "http://schemas.xmlsoap.org/soap/actor/next";
  7. MustUnderstand = false;
  8. }
  9.  
  10. public System.Xml.Schema.XmlSchema GetSchema()
  11. {
  12. return null;
  13. //throw new NotImplementedException();
  14. }
  15.  
  16. public void ReadXml(XmlReader reader)
  17. {
  18. //throw new NotImplementedException();
  19. }
  20.  
  21. public void WriteXml(XmlWriter writer)
  22. {
  23. writer.WriteAttributeString("soap:actor", Actor);
  24. writer.WriteAttributeString("soap:mustUnderstand", MustUnderstand ? "1" : "0");
  25. writer.WriteRaw("some encrypted data");
  26. //get it exactly the way you want it in here without mucking with Xml* property attributes for hours on end
  27. //writer.WriteElement(...);
  28. }
  29. }
  30.  
  31. public partial class AuthenticationWS
  32. {
  33. public SecurityHeader SEC = new Security() { username = "xxxx", password = "xxxx", apikey = "xxxx" };
  34.  
  35. protected override XmlWriter GetWriterForMessage(SoapClientMessage message, int bufferSize)
  36. {
  37. message.Headers.Add(SEC);
  38. return base.GetWriterForMessage(message, bufferSize);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement