Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Help selecting a particular XML Node from a Soap Request

Posted on 2010-08-18
2
748 Views
Last Modified: 2013-12-19
XML is this...
<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">
  <soap:Header>
    <MyHeader xmlns="http://v1x1.identityheader.wbxml.ts.xx.net/">
      <SenderID>X434150</SenderID>
    </MyHeader>
    <MyRequestHeader xmlns="http://v1x1.requestheader.wbxml.ts.xx.net/">
      <SendingTimeStamp>2010-08-18T10:36:59.6925796-04:00</SendingTimeStamp>      
    </MyRequestHeader>
    <wsa:Action>AddCustomer</wsa:Action>
  </soap:Header>
  <soap:Body>
    <AddCustomerRequest xmlns="http://v1x5.addcustomer.message.retail.xx.net/">
    </AddCustomerRequest>
  </soap:Body>
</soap:Envelope>


I need to select the SenderID, SendingTimeStamp and wsa:Action.

I have tried...

select extractvalue(xmltype('<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">
  <soap:Header>
    <MyHeader xmlns="http://v1x1.identityheader.wbxml.ts.xx.net/">
      <SenderID>X434150</SenderID>
    </MyHeader>
    <MyRequestHeader xmlns="http://v1x1.requestheader.wbxml.ts.xx.net/">
      <SendingTimeStamp>2010-08-18T10:36:59.6925796-04:00</SendingTimeStamp>      
    </MyRequestHeader>
    <wsa:Action>AddCustomer</wsa:Action>
  </soap:Header>
  <soap:Body>
    <AddCustomerRequest xmlns="http://v1x5.addcustomer.message.retail.xx.net/">
    </AddCustomerRequest>
  </soap:Body>
</soap:Envelope>'),'//Envelope/Header/MyRequestHeader/SendingTimeStamp') a from dual

but this returns null...

Thanks for your help...

G
0
Comment
Question by:gswitz
2 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 33466277
you need to include the namespaces in your extraction
SELECT EXTRACTVALUE(
           xml,
           '//SenderID',
           '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="http://v1x1.identityheader.wbxml.ts.xx.net/"'
       )
           senderid,
       EXTRACTVALUE(
           xml,
           '//SendingTimeStamp',
           '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="http://v1x1.requestheader.wbxml.ts.xx.net/"'
       )
           sendingtimestamp,
       EXTRACTVALUE(
           xml,
           '//wsa:Action',
           '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="http://v1x1.identityheader.wbxml.ts.xx.net/"'
       )
           action
FROM (SELECT xmltype(
                 '<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">
  <soap:Header>
    <MyHeader xmlns="http://v1x1.identityheader.wbxml.ts.xx.net/">
      <SenderID>X434150</SenderID>
    </MyHeader>
    <MyRequestHeader xmlns="http://v1x1.requestheader.wbxml.ts.xx.net/">
      <SendingTimeStamp>2010-08-18T10:36:59.6925796-04:00</SendingTimeStamp>      
    </MyRequestHeader>
    <wsa:Action>AddCustomer</wsa:Action>
  </soap:Header>
  <soap:Body>
    <AddCustomerRequest xmlns="http://v1x5.addcustomer.message.retail.xx.net/">
    </AddCustomerRequest>
  </soap:Body>
</soap:Envelope>'
             )
                 xml
      FROM DUAL)

Open in new window

0
 

Author Closing Comment

by:gswitz
ID: 33466425
Thanks!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question