title: Is there a guaranteed way to get operation name in a custom soap handler?
body: <p>I have a custom SOAP message handler for incoming messages that will run different code based on which operation is being called. My first try to get the operation name looked something liket this:</p>
  
  <pre><code>public boolean handleMessage(SOAPMessageContext context)
  {
      String op = context.get(MessageContext.WSDL_OPERATION);
      ...
  </code></pre>
  
  <p>This failed because the property <code>MessageContext.WSDL_OPERATION</code> appears to never be set. I then tried using this:</p>
  
  <pre><code>public boolean handleMessage(SOAPMessageContext context)
  {
      Map&lt;?, ?&gt; headers = (Map&lt;?, ?&gt;)context.get(MessageContext.HTTP_REQUEST_HEADERS);    
      ArrayList&lt;String&gt; SOAPAction = ((ArrayList&lt;String&gt;) headers.get("SOAPAction"));
      String opName = SOAPAction.get(0);
      //opName will be formatted like "urn#myOperation", so the prefix must be removed
      opName = ((opName.replace("\"","").split("#"))[1]);
  </code></pre>
  
  <p>This works, but I'm concerned there could be situations where the header property "SOAPAction" isn't set (or doesn't even exist), or does not have the value that I'm expecting it to. I'm also a little concerned because I don't know if this is an "official" way to get the operation name - I figured it out by looking at the contents of <code>context</code> in the debugger.</p>
  
  <p>Is there any better way to get the operation name when handling incoming SOAP messages?</p>