Axis
  1. Axis
  2. AXIS-2624

SOAP header element attributes "mustUnderstand" and "actor" added twice

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.4
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      OS: Windows XP Professional SP2
      Application Server: Apache Tomcat 5.5.17

      Description

      Hello,

      the described issue occurs in the following environment: web service A is called from a client. During processing, it calls in turn a web service B, running on the same engine. During the call, a handler is used on the client side, which adds a new SOAP header block. The resulting message:

      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Header>
      <wssb:wssbUUID mustUnderstand="0" actor="http://schemas.xmlsoap.org/soap/actor/next" mustUnderstand="0" actor="" xmlns:wssb="http://www.sap.com/wssb">0dd3c106-1028-4ef2-b71e-15f6076383b4</wssb:wssbUUID>
      </soapenv:Header>
      <soapenv:Body>
      <ns1:getAllAvailCardiologists soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="HPIndex"/>
      </soapenv:Body>
      </soapenv:Envelope>

      As you can see, the attributes "mustUnderstand" and "actor" of the "wssb:wssbUUID" header element appear twice. Debugging has led me to the conclusion that these attribute duplicates are added during serialization at the client side. I have confirmed that immediately before serialization both attributes appear only once each.

      This is the code in the handler to add the header:

      Name uuidNodeName = currentMessage.getSOAPEnvelope().createName("wssbUUID", "wssb", NAMESPACE);
      uuidNode = currentMessage.getSOAPHeader().addHeaderElement(uuidNodeName);
      uuidNode.setMustUnderstand(false);
      uuidNode.setActor(Constants.URI_SOAP11_NEXT_ACTOR);
      uuidNode.addTextNode(uuid.toString());

      All web services run perfectly well if adding the header is omitted (i.e. the above lines are commented out). This issue occurs on Axis, release 1.4 as well as on the current SVN checkout. It also appears on the latest released Xalan and Xerces versions as well as on their latest SVN checkouts.

      The above issue leads to a SAXParseException on the server. The message text reads "Attribute "mustUnderstand" was already specified for element "wssb:wssbUUID"". The stack trace of this exception:

      Thread [http-8080-Processor21] (Suspended (exception SAXParseException))
      DeserializationContext(DefaultHandler).fatalError(SAXParseException) line: not available
      ErrorHandlerWrapper.fatalError(String, String, XMLParseException) line: not available
      XMLErrorReporter.reportError(XMLLocator, String, String, Object[], short) line: not available
      XMLErrorReporter.reportError(String, String, Object[], short) line: not available
      XMLNSDocumentScannerImpl.scanStartElement() line: not available
      XMLNSDocumentScannerImpl$NSContentDispatcher(XMLDocumentFragmentScannerImpl$FragmentContentDispatcher).dispatch(boolean) line: not available
      XMLNSDocumentScannerImpl(XMLDocumentFragmentScannerImpl).scanDocument(boolean) line: not available
      XIncludeAwareParserConfiguration(XML11Configuration).parse(boolean) line: not available
      XIncludeAwareParserConfiguration(XML11Configuration).parse(XMLInputSource) line: not available
      SAXParserImpl$JAXPSAXParser(XMLParser).parse(XMLInputSource) line: not available
      SAXParserImpl$JAXPSAXParser(AbstractSAXParser).parse(InputSource) line: not available
      SAXParserImpl$JAXPSAXParser.parse(InputSource) line: not available
      SAXParserImpl(SAXParser).parse(InputSource, DefaultHandler) line: not available
      DeserializationContext.parse() line: 227
      SOAPPart.getAsSOAPEnvelope() line: 695
      Message.getSOAPEnvelope() line: 435
      MustUnderstandChecker.invoke(MessageContext) line: 62
      InvocationStrategy.visit(Handler, MessageContext) line: 32
      SOAPService(SimpleChain).doVisiting(MessageContext, HandlerIterationStrategy) line: 118
      SOAPService(SimpleChain).invoke(MessageContext) line: 83
      SOAPService.invoke(MessageContext) line: 454
      AxisServer.invokeService(MessageContext) line: 234
      AxisServer.invoke(MessageContext) line: 375
      AxisServlet.doPost(HttpServletRequest, HttpServletResponse) line: 689
      AxisServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 709
      AxisServlet(AxisServletBase).service(HttpServletRequest, HttpServletResponse) line: 327
      AxisServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 802
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 252
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 173
      StandardWrapperValve.invoke(Request, Response) line: 213
      StandardContextValve.invoke(Request, Response) line: 178
      StandardHostValve.invoke(Request, Response) line: 126
      ErrorReportValve.invoke(Request, Response) line: 105
      StandardEngineValve.invoke(Request, Response) line: 107
      CoyoteAdapter.service(Request, Response) line: 148
      Http11Processor.process(InputStream, OutputStream) line: 869
      Http11Protocol$JmxHttp11ConnectionHandler(Http11BaseProtocol$Http11ConnectionHandler).processConnection(TcpConnection, Object[]) line: 664
      PoolTcpEndpoint.processSocket(Socket, TcpConnection, Object[]) line: 527
      LeaderFollowerWorkerThread.runIt(Object[]) line: 80
      ThreadPool$ControlRunnable.run() line: 684
      ThreadWithAttributes(Thread).run() line: 595

      This exception is also printed out to the console (stdout), however with a different stack trace. The console transcript is attached to this message.

      I also found a bug report with a similar issue. However, I do not know if the two are related: https://issues.apache.org/jira/browse/AXIS-1466.

      Best regards,
      Martin Dreier

        Activity

        Hide
        Martin Dreier added a comment -

        This is the Axis fault as it is printed out to the console.

        Show
        Martin Dreier added a comment - This is the Axis fault as it is printed out to the console.
        Hide
        Jimmy Shah added a comment -

        I am facing the same issue. I am getting a response back as

        Caused by: java.lang.RuntimeException: Exception in preInvoke : javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end of file.
        at org.apache.axis.handlers.HandlerChainImpl.preInvoke(HandlerChainImpl.java:188)
        at org.apache.axis.handlers.HandlerChainImpl.handleResponse(HandlerChainImpl.java:160)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)

        Is there any update on this issue?

        Show
        Jimmy Shah added a comment - I am facing the same issue. I am getting a response back as Caused by: java.lang.RuntimeException: Exception in preInvoke : javax.xml.soap.SOAPException: org.xml.sax.SAXParseException: Premature end of file. at org.apache.axis.handlers.HandlerChainImpl.preInvoke(HandlerChainImpl.java:188) at org.apache.axis.handlers.HandlerChainImpl.handleResponse(HandlerChainImpl.java:160) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180) Is there any update on this issue?
        Hide
        Andreas Veithen added a comment -

        @Jimmy: what makes you believe that it's the same issue as the one reported by Martin?

        Show
        Andreas Veithen added a comment - @Jimmy: what makes you believe that it's the same issue as the one reported by Martin?
        Hide
        Jimmy Shah added a comment -

        here is the soap request that caused the above exception for me. In my code I am adding the userid/password elements in the header and the attribute soapenv:actor is duplicate:

        <?xml version="1.0" encoding="UTF-8"?>\
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soapenv:Header>
        <ns1:gw_auth_user_prop soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string"
        xmlns:ns1="http://www.abc.com/soap" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">username</ns1:gw_auth_user_prop>
        <ns2:gw_auth_password_prop soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string" xmlns:ns2="http://www.abc.com/soap" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">password
        </ns2:gw_auth_password_prop>
        </soapenv:Header>
        <soapenv:Body>
        ...............
        ................
        </soapenv:Body></soapenv:Envelope>

        Show
        Jimmy Shah added a comment - here is the soap request that caused the above exception for me. In my code I am adding the userid/password elements in the header and the attribute soapenv:actor is duplicate: <?xml version="1.0" encoding="UTF-8"?>\ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <ns1:gw_auth_user_prop soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string" xmlns:ns1="http://www.abc.com/soap" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">username</ns1:gw_auth_user_prop> <ns2:gw_auth_password_prop soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string" xmlns:ns2="http://www.abc.com/soap" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">password </ns2:gw_auth_password_prop> </soapenv:Header> <soapenv:Body> ............... ................ </soapenv:Body></soapenv:Envelope>
        Hide
        Andreas Veithen added a comment -

        I'm unable to reproduce this. Can you send us some code that would allow to reproduce the issue?

        Show
        Andreas Veithen added a comment - I'm unable to reproduce this. Can you send us some code that would allow to reproduce the issue?
        Hide
        Jimmy Shah added a comment -

        I have created the SoapHeaderHandler to add the user credentials in the header.

        The header elements are defined in spring configuration file as:

        <bean id="UserHeaderElement1" class="org.apache.axis.message.SOAPHeaderElement" singleton="true">
        <constructor-arg type="java.lang.String" value="http://www.abc.com/soap"/>
        <constructor-arg type="java.lang.String" value="gw_auth_user_prop"/>
        <constructor-arg type="java.lang.Object" value="username"/>
        </bean>

        <bean id="PasswordHeaderElement1" class="org.apache.axis.message.SOAPHeaderElement" singleton="true">
        <constructor-arg type="java.lang.String" value="http://www.abc.com/soap"/>
        <constructor-arg type="java.lang.String" value="gw_auth_password_prop"/>
        <constructor-arg type="java.lang.Object" value="password"/>
        </bean>

        And in the SoapHeaderHandler I have a code:

        public boolean handleRequest(MessageContext msgCtx)
        {
        if (msgCtx instanceof SOAPMessageContext)
        {
        SOAPMessageContext mc = (SOAPMessageContext)msgCtx;
        try
        {
        SOAPMessage msg = mc.getMessage();
        SOAPPart part = msg.getSOAPPart();
        SOAPEnvelope envelope = part.getEnvelope();
        SOAPHeader header = envelope.getHeader();

        if (soapHeaderList != null && !soapHeaderList.isEmpty())
        {
        Iterator<SOAPHeaderElement> it = soapHeaderList.iterator();

        while (it.hasNext())

        { SOAPHeaderElement headerElement = it.next(); header.addChildElement(headerElement); }

        }
        }
        catch (SOAPException x)

        { throw new TransportException("SoapHeaderHandler SOAPException occured", x); }

        }

        return true;
        }

        Again this issue doesn't occur everytime.. But once it happens, the webservice is corrupted and then every request is has the duplicate attributes.

        Show
        Jimmy Shah added a comment - I have created the SoapHeaderHandler to add the user credentials in the header. The header elements are defined in spring configuration file as: <bean id="UserHeaderElement1" class="org.apache.axis.message.SOAPHeaderElement" singleton="true"> <constructor-arg type="java.lang.String" value="http://www.abc.com/soap"/> <constructor-arg type="java.lang.String" value="gw_auth_user_prop"/> <constructor-arg type="java.lang.Object" value="username"/> </bean> <bean id="PasswordHeaderElement1" class="org.apache.axis.message.SOAPHeaderElement" singleton="true"> <constructor-arg type="java.lang.String" value="http://www.abc.com/soap"/> <constructor-arg type="java.lang.String" value="gw_auth_password_prop"/> <constructor-arg type="java.lang.Object" value="password"/> </bean> And in the SoapHeaderHandler I have a code: public boolean handleRequest(MessageContext msgCtx) { if (msgCtx instanceof SOAPMessageContext) { SOAPMessageContext mc = (SOAPMessageContext)msgCtx; try { SOAPMessage msg = mc.getMessage(); SOAPPart part = msg.getSOAPPart(); SOAPEnvelope envelope = part.getEnvelope(); SOAPHeader header = envelope.getHeader(); if (soapHeaderList != null && !soapHeaderList.isEmpty()) { Iterator<SOAPHeaderElement> it = soapHeaderList.iterator(); while (it.hasNext()) { SOAPHeaderElement headerElement = it.next(); header.addChildElement(headerElement); } } } catch (SOAPException x) { throw new TransportException("SoapHeaderHandler SOAPException occured", x); } } return true; } Again this issue doesn't occur everytime.. But once it happens, the webservice is corrupted and then every request is has the duplicate attributes.

          People

          • Assignee:
            Unassigned
            Reporter:
            Martin Dreier
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development