title: how to extract element from cxf soap message
body: <p>I have below soap message.I want to extract Id and chargeBoxIdentity element.</p>
  
  <pre><code>ID: 2
  Address: http://localhost:8080/ocppserver/services/CentralSystemService
  Encoding: UTF-8
  Http-Method: POST
  Content-Type: application/soap+xml;charset=UTF-8;action="/Authorize"
  Headers: {accept-encoding=[gzip,deflate], connection=[Keep-Alive], Content-Length= [852], content-type=[application/soap+xml;charset=UTF-8;action="/Authorize"], host=[localhost:8080], user-agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
  Payload: &lt;s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"&gt;
  &lt;s:Header&gt;
    &lt;h:chargeBoxIdentity xmlns:h="urn://Ocpp/Cs/2012/06/" xmlns="urn://Ocpp/Cs/2012/06/"&gt;REE001&lt;/h:chargeBoxIdentity&gt;
    &lt;a:From&gt;
       &lt;a:Address&gt;http://127.0.0.1:8081/ChargeBox/Ocpp&lt;/a:Address&gt;
    &lt;/a:From&gt;
    &lt;a:MessageID&gt;urn:uuid:2ae9d933-4f92-4628-84fe-35024a858450&lt;/a:MessageID&gt;
    &lt;a:ReplyTo&gt;
       &lt;a:Address&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/a:Address&gt;
    &lt;/a:ReplyTo&gt;
    &lt;a:Action&gt;/Authorize&lt;/a:Action&gt;&lt;/s:Header&gt;
   &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;authorizeRequest xmlns="urn://Ocpp/Cs/2012/06/"&gt;
       &lt;idTag&gt;EF1234&lt;/idTag&gt;
    &lt;/authorizeRequest&gt;
  &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>I wrote below interceptor .Below interceptor print the Header and payload field.How to extract the Id ? How to extract chargeboxIdentity from the payload ? I am using the log4j framework.</p>
  
  <pre><code>import java.io.InputStream;
  import java.util.List;
  import java.util.Map;
  import java.util.Map.Entry;
  import java.util.Set;
  
  import org.apache.cxf.binding.soap.SoapMessage;
  import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
  import org.apache.cxf.helpers.CastUtils;
  import org.apache.cxf.helpers.IOUtils;
  import org.apache.cxf.interceptor.Fault;
  import org.apache.cxf.io.CachedOutputStream;
  import org.apache.cxf.message.Message;
  import org.apache.cxf.phase.Phase;
  
  public class InBoundMessage extends AbstractSoapInterceptor {
  
      public InBoundMessage() {
          super(Phase.RECEIVE);
      }
  
      public void handleMessage(SoapMessage message) throws Fault {
              Map&lt;String, List&lt;String&gt;&gt; headers = CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS));
              if (headers != null) {
                   Set&lt;Entry&lt;String,List&lt;String&gt;&gt;&gt; hashSet=headers.entrySet();
                   for(Entry&lt;String,List&lt;String&gt;&gt; entry:hashSet ) {
                       System.out.println("Key="+entry.getKey()+", Value="+entry.getValue());
                   }
              }
              System.out.println("Message id = "+message.getId());
              try{
              InputStream is = message.getContent ( InputStream.class );
              CachedOutputStream os = new CachedOutputStream ( );
              IOUtils.copy ( is, os );
              os.flush();
              message.setContent (  InputStream.class, os.getInputStream ( ) );
              is.close();
              String payload=IOUtils.toString ( os.getInputStream ( ) );
              System.out.println ("The request is: " + payload);
  
              }catch(Exception e){
                  e.printStackTrace();
              }
      }
  
  }
  </code></pre>