axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Edwardson" <bun...@tpg.com.au>
Subject Re: Soap Header headaches
Date Tue, 29 Apr 2003 01:05:04 GMT
Sam, thanks for your reply, I was sure someone else out there was feeling the same frustrations
as I am, this is the last piece in the jigsaw as far as my project is concerned, but it just
doesent fit.  Do you have a custom handler to gain access to the MessageContext, I tried this
but Axis did'nt like it.
package com.viewdu.service.handlers;

import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.message.SOAPEnvelope;


/**
 *
 * Handler class to handle authorisation of viewdu web sevice users
 *
 * @author  Larry Edwardson
 * @version $Revision: 1.4 $
 *
 */
public class VDAuthorizationHandler extends BasicHandler {


    /* ========================================================================
     *
     * Class (static) variables.
     */
   
    /* ========================================================================
     *
     * Instance variables.
     */


    /* ========================================================================
     *
     * Constructors
     */
    public VDAuthorizationHandler (){
        System.out.println("New VDAuthorizationHandler");
    }


    /* ========================================================================
     *
     * Static methods
     */

   
    /* ========================================================================
     *
     * Public methods
     */
    public void invoke(org.apache.axis.MessageContext messageContext) throws org.apache.axis.AxisFault
{
            try {
                //System.out.println("Do we get in here");
                Message reqMessage = messageContext.getRequestMessage();
                SOAPEnvelope env = reqMessage.getSOAPEnvelope();

            }
            catch (Exception e) {
                throw AxisFault.makeFault(e);
            }
        }

    /* ========================================================================
     *
     * Protected / package-private methods
     */

    /* ========================================================================
     *
     * Private methods
     */


}
This is  a section of my server-config.wsdd

<service name="viewduService" provider="java:RPC">
        <parameter name="className" value="com.viewdu.app.VAppHandler"/>
        <parameter name="allowedMethods" value="weAreReadyToRock"/>
        <parameter name="scope" value="application"/>
       <transport name="http">
        <requestFlow>
            <handler type="java:com.viewdu.service.handlers.VDAuthorizationHandler"/>
        </requestFlow>
            <responseFlow>
            <handler type="java:com.viewdu.service.handlers.VDAuthorizationHandler"/>
        </responseFlow>
    </transport>
    </service>

Have you tried setting the username password in the soap header:

//User name Password
            org.apache.axis.message.SOAPHeaderElement user =
                    new org.apache.axis.message.SOAPHeaderElement("", "USER");
            user.setObjectValue("foo");
            call.addHeader(user);
            org.apache.axis.message.SOAPHeaderElement password =
                    new org.apache.axis.message.SOAPHeaderElement("", "PASSWORD");
            password.setObjectValue("bar");
            call.addHeader(password);
  ----- Original Message ----- 
  From: Sam Khan 
  To: axis-user@ws.apache.org 
  Sent: Tuesday, April 29, 2003 10:52 AM
  Subject: RE: Soap Header headaches


  Larry,

  I've been having  almost the same issue. When using Call.setUsername() and Call.setPassword(),
the authorisation header is correctly set in the client ( my understanding is that the two
values are Base64 encoded ). Hopefully you are using TCPMon, in which case you can see all
the headers and SOAP message sent to the server. If you arent seeing a header that begins
with "Authorisation" , after setting the name and password well, you do have issues. I am
at least getting that far. Logically, the axis server should take the authorisation header,
decode it and then stuff the username and password values in the MessageContext object.
  Its not doing that for me and I have no idea why - and no one seems to be able to tell me
why! But I do have access to the authorisation handler itself ( its in the Message Context
'bag' )so theoretically should be able to decode the header and extract the values. But since
you cant even access the MessageContext object itself is beyond me. If it is null ( for whatever
reason ) the server should be throwing a NullPointerException. Is it doing that? If not, well,
I think that it is being set as it should. I've got to the point of changing the axis source
code so that I can see all the values in the MessageContext 'bag'  which is how I knew that
the authorisation header was being received by the server. 
  Its all very frustrating I agree, and I'm sure I'll look back at it all and laugh like a
monkey. But right now the little hair I have left is losing its tenuous grip. 

  Sam 

    -----Original Message-----
    From: Larry Edwardson [mailto:bunnys@tpg.com.au]
    Sent: Monday, April 28, 2003 3:45 PM
    To: Axis-user
    Subject: Soap Header headaches


    Does anyone have an example of using soap headers, I have been trying for a few days now
to access the headers on the service side with no luck, firstly I tried to gain access to
the MessageContext which comes back as null ? I have also tried writing my own handler but
with no success, I am just about to scream, surely it cant be that hard, all I need to do
is send a username and password and authorise the user.

    Any response will be gladely appreciated.

    Cheers Larry
Mime
View raw message