Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:41:47+00:00 2026-06-11T18:41:47+00:00

I would like to extract an element called ServiceGroupID from the SOAP header, which

  • 0

I would like to extract an element called ServiceGroupID from the SOAP header, which specifies the session of the transaction. I would need this so that I could direct the request to the same server using SOAP session. My XML is as follow:

<?xml version="1.0" encoding="http://schemas.xmlsoap.org/soap/envelope/" standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address>
<wsa:ReferenceParameters>
<axis2:ServiceGroupId xmlns:axis2="http://ws.apache.org/namespaces/axis2">urn:uuid:99A029EBBC70DBEB221347349722532</axis2:ServiceGroupId>
</wsa:ReferenceParameters>
</wsa:ReplyTo>
<wsa:MessageID>urn:uuid:99A029EBBC70DBEB221347349722564</wsa:MessageID>
<wsa:Action>Perform some action</wsa:Action>
<wsa:RelatesTo>urn:uuid:63AD67826AA44DAE8C1347349721356</wsa:RelatesTo>
</soapenv:Header>

I would like to know how I could extract the Session GroupId from the above XML using Xpath.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:41:48+00:00Added an answer on June 11, 2026 at 6:41 pm

    You haven’t specified a technology, so assuming that you haven’t set up the equivalent of a .NET NameSpace manager or similar, you can use namespace agnostic Xpath as follows:

    /*[local-name()='Envelope']/*[local-name()='Header']
          /*[local-name()='ReplyTo']/*[local-name()='ReferenceParameters']
          /*[local-name()='ServiceGroupId']/text()
    

    Edit Updated for Java

    Without namespace aliases

    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    XPathExpression expression = xpath.compile("/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='ReplyTo']/*[local-name()='ReferenceParameters']/*[local-name()='ServiceGroupId']/text()");
    System.out.println(expression.evaluate(myXml));
    

    With NamespaceContext

    NamespaceContext context = new NamespaceContextMap(
        "soapenv", "http://schemas.xmlsoap.org/soap/envelope/", 
        "wsa", "http://www.w3.org/2005/08/addressing",
        "axis2", "http://ws.apache.org/namespaces/axis2");
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    xpath.setNamespaceContext(context);
    XPathExpression expression = xpath.compile("/soapenv:Envelope/soapenv:Header/wsa:ReplyTo/wsa:ReferenceParameters/axis2:Serv‌​iceGroupId/text()");
    System.out.println(expression.evaluate(myXml));
    

    local-name() gives the tag name of the element agnostic of its namespace.
    Also, the encoding in your above xml document doesn’t look right.

    Edit

    Assuming that urn:uuid: is a constant, the following XPath will strip off the first 9 characters of the result (use with either of the above XPath). If urn:uuid isn’t constant, then you’ll need to tokenize / split etc, which is beyond my skills.

    substring(string(/*[local-name()='Envelope']/*[local-name()='Header']
                     /*[local-name()='ReplyTo']/*[local-name()='ReferenceParameters']
                     /*[local-name()='ServiceGroupId']/text()), 10)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to extract items from this sample html, more specificly, i would
I have a div element in an HTML document. I would like to extract
I would like to extract the GPS EXIF tag from pictures using php. I'm
I would like to extract a value or its inverse from database. I would
I would like to extract only tar.gz from the following strings. /root/abc/xzy/file_tar_src-5.2.8.23.tar.gz or /root/abc/xyz/file_tar_src-5.2.tar.gz
I am using Parsename in SQL and would like to extract the last element
I have this xml data format. I would like to extract the properties name
I would like to extract elements from a deeply embedded list into an array.
I would like to use XPath to extract the ImageUID element value (i.e.{7f2535d0-9a41-4997-9694-0a4de569e6d9}) and
I have an HTML page. I would like to extract all elements whose name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.