You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Merritt, Norris" <no...@hp.com> on 2008/07/24 00:50:07 UTC

Axis2: Still has problems with setting SOAPAction and Authorization headers via SAAJ api ?!?

Why does a trivial SAAJ client which imports only javax.xml.soap.* work correctly with Sun's JAX-WS 2.1 libraries in the classpath, but fail when I substitute either the Axis2 1.3 or Axis2 1.4 libraries?  The client app is constructing the SOAPAction and Authorization mime headers itself, then using SOAPConnection.call to send the message:

        SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
        SOAPBody body = soapEnvelope.getBody();
        SOAPBodyElement operation = body.addBodyElement
                (soapEnvelope.createName( requestName, nsPrefix, nsURI ));

        // Basic Authorization header
        String authorization = new sun.misc.BASE64Encoder().encode((userId+":"+pwd).getBytes());
        MimeHeaders hd = soapMessage.getMimeHeaders();
        hd.addHeader( "Authorization", "Basic " + authorization);

        // SOAPAction header
        hd.addHeader( "SOAPAction", soapAction );

        SOAPMessage response = null;

        try
        {
           response = conn.call( request, endpointURL );
        }
        catch( Exception e )
        {
           System.out.println( "Got exception " + e.toString() );
        }

With Sun JAX-WS 2.1, the application works fine.

With Axis2 1.3, I get exception javax.xml.soap.SOAPException: org.apache.axis2.deployment.DeploymentException: org/apache/commons/httpclient/HttpException
With Axis2 1.4, I get exception javax.xml.soap.SOAPException: Transport error: 401 Error: Unauthorized

Searching the Axis user archives reveals that Axis has had issues in this area since Axis 1.0 rc1.  I found bug 14636 for that release "SOAPAction MimeHeader set via SAAJ not passed on".  I found another bug against Axis 1.2, number 1545. This time Axis was generating TWO soapaction headers!  Now Axis is back to generating zero headers.