0

I am a newbie to SOAP and while creating soap client my handler throws

Exception in thread "main" javax.xml.ws.WebServiceException: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.

The code for handler is

 public boolean handleMessage(SOAPMessageContext context)
    {

        if((Boolean)context.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY))
        {

            SOAPMessage message = context.getMessage(); //Error is thrown from here
            PrintStream out = System.out;
            try
            {                
                SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
                SOAPHeader header = envelope.getHeader();
                if (header == null)
                {
                    header = envelope.addHeader();
                }

                // Create Security header               
                header =createUsernameTokenSecurityHeader(header);
                message.writeTo(out);

            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
        return true;
    }

I read somewhere that it might be due to axis2 jar dependency but I am not using axis2 jar in my project. Can anybody help me please?

shruti rawat
  • 241
  • 1
  • 7
  • 19

0 Answers0