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 3931438
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:21:06+00:00 2026-05-19T23:21:06+00:00

I am getting the below exception when I’m trying to add security headers to

  • 0

I am getting the below exception when I’m trying to add security headers to a SOAP envelope right before the request is sent out.

The exception is thrown upon trying to retrieve the message (so context.getMessage() is throwing the exception).

When I use SoapUI, everything works as planned. I’m using JAXB2 for marshalling on the client side, as well as the web service side.

I’m out of ideas already…Any help would be appreciated!

Thanks!!

P.S. When I take out the security check on the web service side, the exception is still thrown (and caught), but the request goes through, and the response is received without any issues.

Here is my code:


public class SoapSecurityHandler implements SOAPHandler {

    private static Logger logger = Logger.getLogger(SoapSecurityHandler.class);

    private final String clntUserName = "my_username";
    private final String clntPassword = "my_password";

    public boolean handleMessage(SOAPMessageContext context) {
        logger.info("Enter handleMessage()");
        Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        if (outboundProperty.booleanValue()) {
            try {

                logger.info("Getting the message");
                SOAPMessage message = context.getMessage();

                logger.info("Getting the soappart");
                SOAPPart soapPart = message.getSOAPPart();

                logger.info("Getting the envelope");
                SOAPEnvelope envelope = soapPart.getEnvelope();

                logger.info("Getting the factory");
                SOAPFactory factory = SOAPFactory.newInstance();

                logger.info("Got the factory");
                QName name = new QName(
                        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
                        "Security", "wsse");

                SOAPElement securityHeader = factory.createElement(name);
                SOAPElement usernameTokenElement = securityHeader.addChildElement("UsernameToken");

                SOAPElement usernameElement = usernameTokenElement.addChildElement("Username");
                usernameElement.addTextNode(clntUserName);

                SOAPElement pwdElement = usernameTokenElement.addChildElement("Password");
                pwdElement.addTextNode(clntPassword);
                logger.info("Added the username and password to the usernameToken element");

                SOAPHeader header = envelope.addHeader();
                logger.info("Added the header to the envelope");

                header.addChildElement(securityHeader);
                logger.info("Added the security header to the header");

            } catch (Exception e) {
                logger.error("Exception in handler: " + e);
                e.printStackTrace();
            }
        } else {
            logger.info("This is an inbound message");
        }
        logger.info("Exit handleMessage()");
        return true;
    }

    public boolean handleFault(SOAPMessageContext context) {
        return false;
    }

    public void close(MessageContext context) {
        //
    }

    public Set getHeaders() {
        return new HashSet();
    }
}

org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. 
    at org.apache.axiom.om.impl.dom.ParentNode.insertBefore(ParentNode.java:228)
    at org.apache.axiom.om.impl.dom.NodeImpl.appendChild(NodeImpl.java:240)
    at org.apache.axis2.saaj.SOAPPartImpl.appendChild(SOAPPartImpl.java:948)
    at com.sun.xml.bind.marshaller.SAX2DOMEx.startElement(SAX2DOMEx.java:176)
    at com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:158)
    at com.sun.xml.ws.message.AbstractMessageImpl.readAsSOAPMessage(AbstractMessageImpl.java:193)
    at com.sun.xml.ws.handler.SOAPMessageContextImpl.getMessage(SOAPMessageContextImpl.java:84)
    at com.sun.xml.ws.handler.SOAPMessageContextImpl.getMessage(SOAPMessageContextImpl.java:77)
    at com.comcast.cet.web.service.routing.lb.f5.impl.SoapSecurityHandler.handleMessage(SoapSecurityHandler.java:40)
    at com.comcast.cet.web.service.routing.lb.f5.impl.SoapSecurityHandler.handleMessage(SoapSecurityHandler.java:1)
    at com.sun.xml.ws.handler.HandlerProcessor.callHandleMessage(HandlerProcessor.java:292)
    at com.sun.xml.ws.handler.HandlerProcessor.callHandlersRequest(HandlerProcessor.java:133)
    at com.sun.xml.ws.handler.ClientSOAPHandlerTube.callHandlersOnRequest(ClientSOAPHandlerTube.java:138)
    at com.sun.xml.ws.handler.HandlerTube.processRequest(HandlerTube.java:116)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542)
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439)
    at com.sun.xml.ws.client.Stub.process(Stub.java:248)
    at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:109)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
    at $Proxy257.getWipInfoForSpecificPoolMember(Unknown Source)
    at com.comcast.cet.web.service.routing.lb.LoadBalancerMain.getWipInfo(LoadBalancerMain.java:74)
    at com.comcast.cet.web.service.routing.lb.LoadBalancerMain.getFarmStatus(LoadBalancerMain.java:42)
    at com.comcast.cet.web.controllers.rpc.RoutingServiceImpl.getFarmStatus(RoutingServiceImpl.java:95)
    at sun.reflect.GeneratedMethodAccessor130.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:544)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:504)
    at com.comcast.cet.web.controllers.rpc.RoutingServiceRpcController.processCall(RoutingServiceRpcController.java:64)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at com.comcast.cet.web.controllers.rpc.RoutingServiceRpcController.handleRequest(RoutingServiceRpcController.java:41)
    at sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:42
6)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
  • 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-05-19T23:21:07+00:00Added an answer on May 19, 2026 at 11:21 pm

    Ok, after a lot of trial and error, this is what I added to the pom.xml to fix the issue:

        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-jaxws</artifactId>
            <version>1.5.4</version>
        </dependency>
    

    Weblogic was using its own impl jars, and they are, as always, outdated.

    here are all of the axis2 declarations in my pom.xml file:

        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.5.4</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
            <version>1.5.4</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-local</artifactId>
            <version>1.5.4</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-http</artifactId>
            <version>1.5.4</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-jaxws</artifactId>
            <version>1.5.4</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-api</artifactId>
            <version>1.2.10</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-impl</artifactId>
            <version>1.2.10</version>
        </dependency>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use TransactionScope , but keep getting the exception below. The
I am getting below exception when i am going to enter record in a
I am getting the below exception when I run my ASP.NET/C#/SQL project on an
I am getting below EAccessViolation Exception in C++ Builder 2010 project. StackTrace is not
I'm trying to serialize a type using the DataContractSerializer and am getting the exception
Right now I'm getting this exception from a simple JMS client I wrote to
I'm getting the Potentially dangerous Request.Form request value was detected from the client exception
I am learning WCF and right now I am getting one exception while running
I was changing the vc++ include directory with new paths suddenly getting below error
I'm getting the following error on the line of code below: Syntax error (missing

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.