0

I have this security envelope. How do I navigate to the Timestamp node inside Secuirty something like this /Envelope/Header/Security/TimeStamp

<?xml version="1.0" encoding="utf-8"?>
<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/08/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>
<wsse:Security soap:mustUnderstand="1"><wsu:Timestamp wsu:Id="Timestamp-dd0398f4-0844-4de9-997e-1fcbd7febd54"><wsu:Created>2013-06-21T04:25:00Z</wsu:Created>
 <wsu:Expires>2013-06-21T04:30:00Z</wsu:Expires></wsu:Timestamp><wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" 

Thank you

user575219
  • 2,346
  • 15
  • 54
  • 105
  • Im not very much sure but I think you need to resolve the namespaces for which the prefix are used `soap` , `wsse` and `wsu` , after that try something like this `\soap:Envelope\soap:Header\wsse:Security\wsu:Timestamp` – Sridhar Jun 21 '13 at 05:07
  • @Sridhar: This answers my question but let me extend the question. Can I delete the timestamp node from security element in a soap request. http://stackoverflow.com/questions/17223156/remove-timestamp-element-from-security – user575219 Jun 21 '13 at 14:00

1 Answers1

0

Your XML includes namespaces, which you either

  • Have to register and use all namespaces (rather similar like Sridhar proposed but for the wrong slashes)

    /soap:Envelope/soap:Header/wsse:Security/wsu:Timestamp
    

    Registering the namespaces heavily differs from programming language to programming language and XPath processor used, so you will have to look that up in the appropriate documentation.

  • Or ignore namespaces, which is easy starting from XPath 2.0 by using the "wildcard namespace"

    /*:Envelope/*:Header/*:Security/*:Timestamp
    

    For XPath 1.0, you cannot do this, you will have to select all elements and check for their name:

    /*[local-name() = "Envelope"]/*[local-name() = "Header"]/*[local-name() = "Security"]/*[local-name() = "Timestamp"]
    

    Generally, ignoring namespaces should be regarded bad practise, and especially in XPath 1.0 leads to horrible to read and probably slower queries.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
  • This answers my question but let me extend the question. Can I delete the timestamp node from security element in a soap request.http://stackoverflow.com/questions/17223156/remove-timestamp-element-from-security – user575219 Jun 21 '13 at 14:00
  • Sorry, cannot help you with that. – Jens Erat Jun 23 '13 at 13:56