You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by du...@apache.org on 2006/01/24 03:52:37 UTC

svn commit: r371781 - in /webservices/axis/trunk/java/src/org/apache/axis: ./ client/ persistence/ server/ wsa/

Author: dug
Date: Mon Jan 23 18:52:30 2006
New Revision: 371781

URL: http://svn.apache.org/viewcvs?rev=371781&view=rev
Log:
First pass at adding WS-Addr to base axis
Split client so request and response sides of chains are invoked independently.
Server will come next (along with tests, docs... :-)

Added:
    webservices/axis/trunk/java/src/org/apache/axis/persistence/
    webservices/axis/trunk/java/src/org/apache/axis/persistence/JVMPersistence.java
    webservices/axis/trunk/java/src/org/apache/axis/persistence/Persistence.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/
    webservices/axis/trunk/java/src/org/apache/axis/wsa/AsyncService.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/AxisEndpointReference.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/EndpointReference.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/MIHeader.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/RelatesToProperty.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/UUIDGenerator.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/Util.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAConstants.java
    webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAHandler.java
Modified:
    webservices/axis/trunk/java/src/org/apache/axis/MessageContext.java
    webservices/axis/trunk/java/src/org/apache/axis/client/AxisClient.java
    webservices/axis/trunk/java/src/org/apache/axis/client/Call.java
    webservices/axis/trunk/java/src/org/apache/axis/server/server-config.wsdd

Modified: webservices/axis/trunk/java/src/org/apache/axis/MessageContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/MessageContext.java?rev=371781&r1=371780&r2=371781&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/MessageContext.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/MessageContext.java Mon Jan 23 18:52:30 2006
@@ -228,7 +228,7 @@
 
         OperationDesc [] possibleOperations = null;
 
-        /* DUG - how can you possibly just guess like this???
+        /* DUG - how can you possibly just guess like this??? */
         if (serviceHandler == null) {
             try {
                 if (log.isDebugEnabled()) {
@@ -243,7 +243,7 @@
                 // Didn't find one...
             }
         }
-        */
+        /* */
 
         if (serviceHandler != null) {
             ServiceDesc desc = serviceHandler.getInitializedServiceDesc(this);
@@ -459,16 +459,16 @@
       try {
         out.writeObject( table );
       } catch(Exception exp) {
-        System.err.println("Can't serialize MessageContext("+exp+")\n" +
-                           "Current list of entries that were attempted:\n" );
+        String tmp = "\nCan't serialize MessageContext("+exp+")\n" +
+                           "Current list of entries that were attempted:\n" ;
 
         Iterator ii = table.keySet().iterator();
         while ( ii.hasNext() ) {
           String key = (String) ii.next();
           Object val = table.get(key);
-          System.err.println("  " + key + " : " + val.getClass() );
+          tmp += "  " + key + " : " + val.getClass() + "\n" ;
         }
-        throw exp ;
+        throw new Exception( exp.toString() + tmp );
       }
     }
 

Modified: webservices/axis/trunk/java/src/org/apache/axis/client/AxisClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/client/AxisClient.java?rev=371781&r1=371780&r2=371781&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/client/AxisClient.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/client/AxisClient.java Mon Jan 23 18:52:30 2006
@@ -16,22 +16,31 @@
 
 package org.apache.axis.client ;
 
-import javax.xml.namespace.QName;
-import javax.xml.rpc.handler.HandlerChain;
-
 import org.apache.axis.AxisEngine;
 import org.apache.axis.AxisFault;
 import org.apache.axis.Constants;
 import org.apache.axis.EngineConfiguration;
 import org.apache.axis.Handler;
+import org.apache.axis.Message;
 import org.apache.axis.MessageContext;
 import org.apache.axis.components.logger.LogFactory;
 import org.apache.axis.configuration.EngineConfigurationFactoryFinder;
+import org.apache.axis.handlers.HandlerChainImpl;
 import org.apache.axis.handlers.HandlerInfoChainFactory;
 import org.apache.axis.handlers.soap.MustUnderstandChecker;
 import org.apache.axis.handlers.soap.SOAPService;
 import org.apache.axis.utils.Messages;
 import org.apache.commons.logging.Log;
+import org.apache.axis.message.* ;
+import org.apache.axis.wsa.* ;
+import org.apache.axis.security.WSSecurity;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.HandlerChain;
+import java.util.Iterator;
+import java.lang.reflect.Method ;
+import java.io.* ;
+import java.util.* ;
 
 /**
  * Provides the equivalent of an "Axis engine" on the client side.
@@ -44,14 +53,15 @@
  */
 public class AxisClient extends AxisEngine {
     protected static Log log =
-            LogFactory.getLog(AxisClient.class.getName());
+        LogFactory.getLog(AxisClient.class.getName());
 
-    MustUnderstandChecker checker = new MustUnderstandChecker(null);
+    MustUnderstandChecker checker     = new MustUnderstandChecker(null);
+    HandlerChain          handlerImpl = null ;
 
     public AxisClient(EngineConfiguration config) {
         super(config);
     }
-
+    
     public AxisClient() {
         this(EngineConfigurationFactoryFinder.newFactory().
                 getClientEngineConfig());
@@ -64,6 +74,150 @@
         return this;
     }
 
+    public void invokeOutbound(MessageContext msgContext) throws Exception {
+        Handler h = null ;
+
+        /* Process the Service Specific Request Chain */
+        /**********************************************/
+        SOAPService service = msgContext.getService();
+        if ( service != null ) {
+            h = service.getRequestHandler();
+            if ( h != null )
+                h.invoke( msgContext );
+        }
+
+        /* Process the Global Request Chain */
+        /**********************************/
+        if ((h = getGlobalRequest()) != null )
+            h.invoke(msgContext);
+
+        /* Process the JAX-RPC Handlers - handleRequest */
+        /* Make sure to set the pastPivot to true if this returns a
+         * false. In that case we do not invoke the transport request
+         * chain. Also note that if a a false was returned from the
+         * JAX-RPC handler chain, then the chain still holds the index
+
+         * of the handler that returned false. So when we invoke the
+         * handleResponse method of the chain, it will correctly call
+         * the handleResponse from that specific handler instance. So
+         * do not destroy the chain at this point - the chain will be
+         * destroyed in the finally block.
+         */
+        // invokeJAXRPCHandlers(msgContext);
+        if ( handlerImpl == null )
+          handlerImpl = getJAXRPChandlerChain(msgContext);
+        if (handlerImpl != null ) {
+          try {
+            if (!handlerImpl.handleRequest(msgContext)) {
+              msgContext.setPastPivot(true);
+            }
+          } catch( RuntimeException re ) {
+            handlerImpl.destroy(); // WS4EE 1.1 6.2.2.1 Handler Life Cycle. "RuntimeException" --> destroy handler
+            throw re ;
+          }
+        }
+
+        // Run the security code - Init security sessions if needed
+        String secCls = msgContext.getStrProp( "WSSecurity" );
+        if ( secCls == null ) 
+          secCls = (String) msgContext.getAxisEngine().getOption("WSSecurity");
+        // Add code here... Dug
+        // securityCode.init();
+    }
+
+    public void invokeTransport(MessageContext msgContext) throws Exception {
+        /** Process the Transport Specific stuff
+         *
+         * NOTE: Somewhere in here there is a handler which actually
+         * sends the message and receives a response.  Generally
+         * this is the pivot point in the Transport chain. But invoke
+         * this only if pivot point has not been set to false. This
+         * can be set to false if any of the JAX-RPC handler's
+         * handleRequest returned false.
+         */
+        String  hName = msgContext.getTransportName();
+        Handler h     = null ;
+
+        if ( hName != null && (h = getTransport( hName )) != null )  {
+          // Piggy-back any RM headers (like ACKs)
+          // add code here... Dug
+          // rmcode.addRMHeaders();
+
+          // Run security - Protect
+          // add code here... Dug
+          // securityCode.protect();
+
+          // Invoke the actual transport chain
+          h.invoke(msgContext);
+
+          // Make sure the first thing we do on the response side is
+          // run WSA processing
+          WSAHandler.invoke( msgContext );
+
+          // Run security - Verify
+          // add code here... Dug
+          // securityCode.verify();
+        }
+        else 
+            throw new AxisFault(Messages.getMessage("noTransport00", hName));
+    }
+
+    public void invokeTransportOneWay(final MessageContext msgContext) 
+      throws Exception
+    {
+      Runnable runnable = new Runnable() {
+        public void run() {
+          try {
+            msgContext.getAxisEngine().setCurrentMessageContext( msgContext );
+            invokeTransport( msgContext );
+          }
+          catch( Exception exp ) {
+            exp.printStackTrace();
+            log.debug( Messages.getMessage( "exceptionPrinting" ) , exp );
+          }
+        }
+      };
+      (new Thread(runnable)).start();
+    }
+
+    public void invokeInbound(MessageContext msgContext) throws Exception {
+        Handler h = null ;
+
+        /* Process the JAXRPC Handlers */
+        // invokeJAXRPCHandlers(msgContext);
+        if ( handlerImpl == null )
+          handlerImpl = getJAXRPChandlerChain(msgContext);
+        if (handlerImpl != null ) {
+          try {
+            if (!handlerImpl.handleResponse(msgContext)) {
+              msgContext.setPastPivot(true);
+            }
+          } catch( RuntimeException re ) {
+            handlerImpl.destroy(); // WS4EE 1.1 6.2.2.1 Handler Life Cycle. "RuntimeException" --> destroy handler
+            throw re ;
+          }
+        }
+
+        /* Process the Global Response Chain */
+        /*************************************/
+        SOAPService service = msgContext.getService();
+        if ((h = getGlobalResponse()) != null) 
+            h.invoke(msgContext);
+
+        if ( service != null ) {
+            h = service.getResponseHandler();
+            if ( h != null ) {
+                h.invoke(msgContext);
+            }
+        }
+        // Do SOAP Semantics checks here - this needs to be a call
+        // to a pluggable object/handler/something
+        if (msgContext.isPropertyTrue(Call.CHECK_MUST_UNDERSTAND,
+                true)) {
+            checker.invoke(msgContext);
+        }
+    }
+
     /**
      * Main routine of the AXIS engine.  In short we locate the appropriate
      * handler for the desired service and invoke() it.
@@ -76,29 +230,39 @@
         if (log.isDebugEnabled()) {
             log.debug("Enter: AxisClient::invoke");
         }
-        String hName = null;
-        Handler h = null;
-        HandlerChain handlerImpl = null;
-        
+
+        String  hName = null ;
+        Handler h     = null ;
+
         // save previous context
         MessageContext previousContext = getCurrentMessageContext();
+
         try {
             // set active context
             setCurrentMessageContext(msgContext);
-            hName = msgContext.getStrProp(MessageContext.ENGINE_HANDLER);
+
+            // Do WSA processing first
+            WSAHandler.invoke( msgContext );
+
+            hName = msgContext.getStrProp( MessageContext.ENGINE_HANDLER );
             if (log.isDebugEnabled()) {
-                log.debug("EngineHandler: " + hName);
+                log.debug( "EngineHandler: " + hName );
             }
-            if (hName != null) {
-                h = getHandler(hName);
-                if (h != null)
+
+            if ( hName != null ) {
+                h = getHandler( hName );
+                if ( h != null )
                     h.invoke(msgContext);
                 else
-                    throw new AxisFault("Client.error",
-                            Messages.getMessage("noHandler00",
-                                    hName),
-                            null, null);
-            } else {
+                    throw new AxisFault( "Client.error",
+                                        Messages.getMessage("noHandler00", 
+                                                hName),
+                                        null, null );
+            }
+            else {
+                // This really should be in a handler - but we need to discuss 
+                // it first - to make sure that's what we want.
+
                 /* Now we do the 'real' work.  The flow is basically:         */
                 /*                                                            */
                 /*   Service Specific Request Chain                           */
@@ -109,133 +273,100 @@
                 /*   Service Specific Response Chain                          */
                 /*   Protocol Specific-Handler/Checker                        */
                 /**************************************************************/
-                SOAPService service = null;
+
+                // When do we call init/cleanup??
+
                 msgContext.setPastPivot(false);
+                invokeOutbound(msgContext);
 
-                /* Process the Service Specific Request Chain */
-                /**********************************************/
-                service = msgContext.getService();
-                if (service != null) {
-                    h = service.getRequestHandler();
-                    if (h != null)
-                        h.invoke(msgContext);
-                }
-
-                /* Process the Global Request Chain */
-                /**********************************/
-                if ((h = getGlobalRequest()) != null)
-                    h.invoke(msgContext);
+                // Add check for RM here - for now just do normal stuff... Dug
+                // Normal transport flow
+                if ( msgContext.getIsOneWay() )
+                  invokeTransportOneWay( msgContext );
+                else
+                  invokeTransport( msgContext );
+
+                // If there was no response message and we didn't call
+                // invokeOneWay() then wait for an async response
+                if ( msgContext.getResponseMessage() == null &&
+                     msgContext.getIsOneWay() == false )
+                  waitForResponse( msgContext );
+
+                if ( !msgContext.getIsOneWay() )
+                  invokeInbound( msgContext );
 
-                /* Process the JAX-RPC Handlers  - handleRequest.
-                 * Make sure to set the pastPivot to true if this returns a
-                 * false. In that case we do not invoke the transport request
-                 * chain. Also note that if a a false was returned from the
-                 * JAX-RPC handler chain, then the chain still holds the index
-                 * of the handler that returned false. So when we invoke the
-                 * handleResponse method of the chain, it will correctly call
-                 * the handleResponse from that specific handler instance. So
-                 * do not destroy the chain at this point - the chain will be
-                 * destroyed in the finally block.
-                 */
-                handlerImpl = getJAXRPChandlerChain(msgContext);
-                if (handlerImpl != null) {
-                    try {
-                        if (!handlerImpl.handleRequest(msgContext)) {
-                            msgContext.setPastPivot(true);
-                        }
-                    } catch (RuntimeException re) {
-                        handlerImpl.destroy();  // WS4EE 1.1 6.2.2.1 Handler Life Cycle. "RuntimeException" --> destroy handler
-                        throw re;
-                    }
-                }
-
-                /** Process the Transport Specific stuff
-                 *
-                 * NOTE: Somewhere in here there is a handler which actually
-                 * sends the message and receives a response.  Generally
-                 * this is the pivot point in the Transport chain. But invoke
-                 * this only if pivot point has not been set to false. This
-                 * can be set to false if any of the JAX-RPC handler's
-                 * handleRequest returned false.
-                 */
-                if (!msgContext.getPastPivot()) {
-                    hName = msgContext.getTransportName();
-                    if (hName != null && (h = getTransport(hName)) != null) {
-                        try {
-                            h.invoke(msgContext);
-                        } catch (AxisFault e) {
-                            throw e;
-                        }
-                    } else {
-                        throw new AxisFault(Messages.getMessage("noTransport00",
-                                hName));
-                    }
-                }
-                
-                msgContext.setPastPivot(true);
-                if ( !msgContext.getIsOneWay() ) {
-                    if (handlerImpl != null) {
-                        try {
-                            handlerImpl.handleResponse(msgContext);                            
-                        } catch (RuntimeException ex) {
-                            handlerImpl.destroy();  // WS4EE 1.1 6.2.2.1 Handler Life Cycle. "RuntimeException" --> destroy handler
-                            throw ex;    
-                        }                        
-                    }
-
-                    /* Process the Global Response Chain */
-                    /***********************************/
-                    if ((h = getGlobalResponse()) != null) {
-                        h.invoke(msgContext);
-                    }
-                    
-                    /* Process the Service-Specific Response Chain */
-                    /***********************************************/
-                    if (service != null) {
-                        h = service.getResponseHandler();
-                        if (h != null) {
-                            h.invoke(msgContext);
-                        }
-                    }
-
-                    // Do SOAP Semantics checks here - this needs to be a call
-                    // to a pluggable object/handler/something
-                    if (msgContext.isPropertyTrue(Call.CHECK_MUST_UNDERSTAND,
-                            true)) {
-                        checker.invoke(msgContext);
-                    }
-                }
+                // Do SOAP Semantics checks here - this needs to be a call to
+                // a pluggable object/handler/something
             }
-        } catch (Exception e) {
+
+        } catch ( Exception e ) {
             // Should we even bother catching it ?
-            if (e instanceof AxisFault) {
-                throw (AxisFault) e;
-            } else {
-                log.debug(Messages.getMessage("exception00"), e);
-                throw AxisFault.makeFault(e);
-            }
+            if (e instanceof AxisFault)  throw (AxisFault) e ;
+            log.debug(Messages.getMessage("exception00"), e);
+            throw AxisFault.makeFault(e);
+
         } finally {
-            if (handlerImpl != null) {
+            if (handlerImpl != null) 
                 handlerImpl.destroy();
-            }
             // restore previous state
             setCurrentMessageContext(previousContext);
         }
+
         if (log.isDebugEnabled()) {
             log.debug("Exit: AxisClient::invoke");
         }
     }
 
+    private void waitForResponse(MessageContext msgContext) throws Exception {
+      MIHeader reqMIH = MIHeader.fromRequest();
+      if ( reqMIH == null || reqMIH.getMessageID() == null ) return ;
+
+      // If this is a response msg then we shouldn't wait
+      if ( reqMIH.getRelatesTo() != null ) return ;
+
+      // Just wait for the message to appear in the persistence
+      long       startTime    = System.currentTimeMillis();
+      String     msgID        = reqMIH.getMessageID();
+      long       maxWait      = 1000*60 ;
+      String     maxWaitStr   = null ;
+      
+      maxWaitStr = (String) msgContext.getAxisEngine()
+                                      .getOption("asyncWaitTimeout");
+      if ( maxWaitStr != null && !"".equals(maxWaitStr) )
+        maxWait = Long.parseLong(maxWaitStr);
+
+      for ( ;; Thread.sleep(200) ) {
+        // Check to see if we've waiting too long, if so stop 
+        // ****************************************************
+        long currentTime = System.currentTimeMillis();
+        if ( maxWait != 0 && startTime + maxWait < currentTime )
+               throw new Exception( Messages.getMessage("noResponse01") );
+
+        // First check to see if the message magically appeared in our 
+        // persistence.  This could be as a result of an async delivery
+        // or because we polled for any generic message.               
+        // *************************************************************
+        MessageContext mc = AsyncService.getResponseContext(msgID);
+        if ( mc == null ) continue ;
+
+        msgContext.setResponseMessage( mc.getCurrentMessage() );
+        if ( "true".equals(mc.getProperty("ASYNCRESPONSE")) )
+          msgContext.setProperty( "ASYNCRESPONSE", "true" );
+        break ;
+      }
+    }
+
     /**
      * @param context Stores the Service, port QName and optionnaly a HandlerInfoChainFactory
      * @return Returns a HandlerChain if one has been specified
      */
     protected HandlerChain getJAXRPChandlerChain(MessageContext context) {
-        java.util.List chain = null;
-        HandlerInfoChainFactory hiChainFactory = null;
-        boolean clientSpecified = false;
+    java.util.List chain = null;
+    HandlerInfoChainFactory hiChainFactory = null;
+    boolean clientSpecified = false;
 
-        Service service = (Service) context.getProperty(Call.WSDL_SERVICE);
+        Service service
+            = (Service)context.getProperty(Call.WSDL_SERVICE);
         if(service == null) {
             return null;
         }
@@ -248,29 +379,28 @@
         javax.xml.rpc.handler.HandlerRegistry registry;
         registry = service.getHandlerRegistry();
         if(registry != null) {
-            chain = registry.getHandlerChain(portName);
-            if ((chain != null) && (!chain.isEmpty())) {
-                hiChainFactory = new HandlerInfoChainFactory(chain);
-                clientSpecified = true;
-            }
+        chain = registry.getHandlerChain(portName);
+        if ((chain != null) && (!chain.isEmpty())) {
+        hiChainFactory = new HandlerInfoChainFactory(chain);
+        clientSpecified = true;
         }
-
-        // Otherwise, use the container support
-        if (!clientSpecified) {
-            SOAPService soapService = context.getService();
-            if (soapService != null) {
-                // A client configuration exists for this service.  Check
-                // to see if there is a HandlerInfoChain configured on it.
-                hiChainFactory = (HandlerInfoChainFactory)
-                        soapService.getOption(Constants.ATTR_HANDLERINFOCHAIN);
-            }
         }
 
-        if (hiChainFactory == null) {
-            return null;
+    // Otherwise, use the container support
+    if (!clientSpecified) {
+        SOAPService soapService = context.getService();
+        if (soapService != null) {
+        // A client configuration exists for this service.  Check
+        // to see if there is a HandlerInfoChain configured on it.
+        hiChainFactory = (HandlerInfoChainFactory) 
+                soapService.getOption(Constants.ATTR_HANDLERINFOCHAIN);
         }
-
-        return hiChainFactory.createHandlerChain();
     }
 
+    if (hiChainFactory == null) {
+        return null ;
+    }
+    return hiChainFactory.createHandlerChain();
+  }
 }
+

Modified: webservices/axis/trunk/java/src/org/apache/axis/client/Call.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/client/Call.java?rev=371781&r1=371780&r2=371781&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/client/Call.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/client/Call.java Mon Jan 23 18:52:30 2006
@@ -93,6 +93,10 @@
 import java.util.Vector;
 import java.rmi.RemoteException;
 
+import org.apache.axis.wsa.WSAConstants ;
+import org.apache.axis.wsa.MIHeader ;
+import org.apache.axis.wsa.EndpointReference ;
+
 /**
  * Axis' JAXRPC Dynamic Invocation Interface implementation of the Call
  * interface.  This class should be used to actually invoke the Web Service.
@@ -1842,24 +1846,24 @@
      */
     public void invokeOneWay(Object[] params) {
         try {
-            msgContext.setIsOneWay(true);
+            msgContext.setIsOneWay( true );
             invoke( params );
         } catch( Exception exp ) {
             throw new JAXRPCException( exp.toString() );
         } finally {
-            msgContext.setIsOneWay(false);
+            msgContext.setIsOneWay( false );
         }
     }
 
     public void invokeOneWay() {
-      try {
-        msgContext.setIsOneWay( true );
-        invoke();
-      } catch( Exception exp ) {
-        throw new JAXRPCException( exp.toString() );
-      } finally {
-        msgContext.setIsOneWay( false );
-      }
+        try {
+            msgContext.setIsOneWay( true );
+            invoke();
+        } catch( Exception exp ) {
+            throw new JAXRPCException( exp.toString() );
+        } finally {
+            msgContext.setIsOneWay( false );
+        }
     }
 
     public boolean isInvokeOneWay() {
@@ -2778,11 +2782,13 @@
             }
         }
 
-        if ( !msgContext.getIsOneWay() ) {
+        // if(!msgContext.getIsOneWay()) {
             invokeEngine(msgContext);
+        /*
         } else {
             invokeEngineOneWay(msgContext);
         }
+        */
 
         if (log.isDebugEnabled()) {
             log.debug("Exit: Call::invoke()");
@@ -2843,14 +2849,14 @@
         //create a new class
         Runnable runnable = new Runnable(){
             public void run() {
-                msgContext.setIsOneWay(true);
+                msgContext.setIsOneWay( true );
                 try {
                     service.getEngine().invoke( msgContext );
                 } catch (AxisFault af){
                     //TODO: handle errors properly
                     log.debug(Messages.getMessage("exceptionPrinting"), af);
                 }
-                msgContext.setIsOneWay(false);
+                msgContext.setIsOneWay( false );
             }
         };
         //create a thread to run it
@@ -3003,5 +3009,78 @@
     public void clearOperation() {
         operation = null;
         operationSetManually = false;
+    }
+
+    public String getMessageID() {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      return mih == null ? null : mih.getMessageID();
+    }
+
+    public void setTo(EndpointReference epr) throws Exception {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setTo( epr );
+    }
+
+    public void setTo(String url) throws Exception {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setTo( EndpointReference.fromLocation( url ) );
+    }
+
+    public EndpointReference getTo() {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      return mih == null ? null : mih.getTo();
+    }
+
+    public void setFrom(EndpointReference epr) throws Exception {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setFrom( epr );
+    }
+
+    public void setFrom(String url) throws Exception {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setFrom( EndpointReference.fromLocation( url ) );
+    }
+
+    public EndpointReference getFrom() {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      return mih == null ? null : mih.getFrom();
+    }
+
+    public void setReplyTo(EndpointReference epr) throws Exception {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setReplyTo( epr );
+    }
+
+    public void setReplyTo(String url) throws Exception {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setReplyTo( EndpointReference.fromLocation( url ) );
+    }
+
+    public EndpointReference getReplyTo() {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      return mih == null ? null : mih.getReplyTo();
+    }
+
+    public void setFaultTo(EndpointReference epr) throws Exception {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setFaultTo( epr );
+    }
+
+    public void setFaultTo(String url) throws Exception {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      if ( mih == null ) mih = new MIHeader( this );
+      mih.setFaultTo( EndpointReference.fromLocation( url ) );
+    }
+
+    public EndpointReference getFaultTo() {
+      MIHeader mih = (MIHeader) getProperty(WSAConstants.REQ_MIH);
+      return mih == null ? null : mih.getFaultTo();
     }
 }

Added: webservices/axis/trunk/java/src/org/apache/axis/persistence/JVMPersistence.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/persistence/JVMPersistence.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/persistence/JVMPersistence.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/persistence/JVMPersistence.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,27 @@
+package org.apache.axis.persistence ;
+
+import java.util.Hashtable ;
+
+public class JVMPersistence implements Persistence {
+  private Hashtable queues = new Hashtable();
+
+  public Object get(String queue, String id) throws Exception {
+    Hashtable q = (Hashtable) queues.get( queue );
+    if ( q == null ) return null ;
+    return q.get( id );
+  }
+
+  public Object remove(String queue, String id) throws Exception {
+    Hashtable q = (Hashtable) queues.get( queue );
+    if ( q == null ) return null ;
+    Object obj = q.remove( id );
+    return obj ;
+  }
+
+  public void put(String queue, String id, Object obj) throws Exception {
+    Hashtable q = (Hashtable) queues.get( queue );
+    if ( q == null ) queues.put( queue, q = new Hashtable());
+    q.put( id, obj );
+  }
+
+}

Added: webservices/axis/trunk/java/src/org/apache/axis/persistence/Persistence.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/persistence/Persistence.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/persistence/Persistence.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/persistence/Persistence.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,7 @@
+package org.apache.axis.persistence ;
+
+public interface Persistence {
+  public Object get(String queue, String id) throws Exception;
+  public Object remove(String queue, String id) throws Exception;
+  public void   put(String queue, String id, Object obj) throws Exception;
+}

Modified: webservices/axis/trunk/java/src/org/apache/axis/server/server-config.wsdd
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/server/server-config.wsdd?rev=371781&r1=371780&r2=371781&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/server/server-config.wsdd (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/server/server-config.wsdd Mon Jan 23 18:52:30 2006
@@ -40,6 +40,12 @@
   <parameter name="className" value="org.apache.axis.utils.Admin"/>
  </service>
 
+ <!-- AdminService is for async responses -->
+ <service name="asyncService" provider="java:MSG">
+  <parameter name="allowedMethods" value="process"/>
+  <parameter name="className" value="org.apache.axis.wsa.AsyncService"/>
+ </service>
+
  <service name="Version" provider="java:RPC">
   <parameter name="allowedMethods" value="getVersion"/>
   <parameter name="className" value="org.apache.axis.Version"/>

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/AsyncService.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/AsyncService.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/AsyncService.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/AsyncService.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,69 @@
+package org.apache.axis.wsa ;
+
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.util.Vector;
+import org.w3c.dom.Element ;
+import org.apache.axis.MessageContext ;
+import org.apache.axis.persistence.Persistence ;
+import org.apache.axis.wsa.MIHeader ;
+import org.apache.axis.wsa.RelatesToProperty ;
+import org.apache.axis.Message ;
+
+public class AsyncService {
+  static private Persistence store = null ;
+
+  public Element[] process(Element[] bodies) throws Exception {
+    // Just stick the msg in the persistence
+    MessageContext msgContext = MessageContext.getCurrentContext();
+    msgContext.setProperty( "ASYNCRESPONSE", "true" );
+    msgContext.setIsOneWay(true);
+
+    if ( store == null ) {
+      String cls = (String) msgContext.getAxisEngine()
+                                      .getOption("asyncPersistence");
+      if ( cls == null || "".equals(cls) )
+        cls = "org.apache.axis.persistence.JVMPersistence" ;
+      store = (Persistence) Class.forName( cls ).newInstance();
+    }
+
+    String msgID = null ;
+    Vector rv = MIHeader.fromRequest().getRelatesTo();
+    if ( rv == null ) return null ;
+    for ( int i = 0 ; i < rv.size(); i ++ ) {
+      RelatesToProperty rtp = (RelatesToProperty) rv.get(i);
+      msgID = rtp.getURI();
+      break ;
+    }
+    if ( msgID == null ) return null ;
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ObjectOutputStream    oos  = new ObjectOutputStream(baos);
+    msgContext.toStream( oos );
+
+    store.put( "asyncMsg", msgID, baos.toByteArray() );
+
+    oos.close();
+    baos.close();
+    return null ;
+  }
+
+  static public MessageContext getResponseContext(String reqMsgID) 
+      throws Exception {
+    if ( store == null ) return null ;
+
+    Object obj = store.remove( "asyncMsg", reqMsgID );
+    if ( obj == null ) return null ;
+
+    MessageContext msgContext = MessageContext.getCurrentContext();
+    MessageContext newMC = new MessageContext( msgContext.getAxisEngine() );
+    ByteArrayInputStream bais = new ByteArrayInputStream( (byte[]) obj );
+    ObjectInputStream    ois  = new ObjectInputStream( bais );
+    newMC.fromStream( ois );
+    ois.close();
+    bais.close();
+    return newMC ;
+  }
+}

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/AxisEndpointReference.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/AxisEndpointReference.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/AxisEndpointReference.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/AxisEndpointReference.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,48 @@
+package org.apache.axis.wsa ;
+
+import javax.xml.namespace.QName;
+import java.util.List;
+import java.net.URL;
+import org.w3c.dom.Element;
+import org.apache.axis.message.SOAPHeaderElement;
+import java.util.Iterator;
+
+public class AxisEndpointReference extends EndpointReference {
+
+  AxisEndpointReference() {;
+  } 
+
+  public AxisEndpointReference(final String endpoint) {
+    setAddress(endpoint);
+  }
+
+  public AxisEndpointReference(final URL wsdlLocation,
+    final String serviceName, final String portName) {
+    this.portType = portType;
+    this.serviceName = serviceName;
+    this.portName = portName;
+  }
+
+  public AxisEndpointReference(AxisEndpointReference epr ){
+    super(epr);
+  }
+
+/*
+  public javax.xml.rpc.Call createCall() throws  java.net.MalformedURLException, javax.xml.parsers.ParserConfigurationException {
+    org.apache.axis.client.Call ret = new org.apache.axis.client.Call(address); 
+
+    addSOAPHeaders(ret);
+    return ret;
+  }
+
+  public void addSOAPHeaders(org.apache.axis.client.Call c) throws javax.xml.parsers.ParserConfigurationException { 
+    
+    for (Iterator i = createWsaHeaderElements().iterator(); i.hasNext();) {
+      Element refNode = (Element) i.next(); 
+
+      c.addHeader(new SOAPHeaderElement(refNode));
+    }
+  }
+  */
+
+}

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/EndpointReference.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/EndpointReference.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/EndpointReference.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/EndpointReference.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,413 @@
+package org.apache.axis.wsa ;
+
+import java.io.Serializable;
+import javax.xml.namespace.QName;
+import java.util.List;
+import java.util.Iterator;
+import java.util.LinkedList;
+import org.w3c.dom.Document;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.apache.axis.utils.XMLUtils ;
+
+import org.xml.sax.SAXException;
+
+import java.util.Stack;
+import org.xml.sax.Attributes;
+
+
+abstract public class EndpointReference implements Serializable {
+
+  protected String  address = null;
+  protected String  portType = null; // QName
+  protected String  serviceName = null; // QName
+  protected String  portName = null;
+  protected List    referenceProperties = new java.util.LinkedList();
+  protected List    referenceParameters = new java.util.LinkedList();
+
+  private static EndpointReference AnonymousEPR = 
+    EndpointReference.fromLocation( WSAConstants.Anonymous_Address );
+
+  EndpointReference( final EndpointReference epr){
+    this.address = epr.address;
+    this.portType = epr.portType; //rrfoo still missing from serializers!
+    this.serviceName = epr.serviceName;
+    this.portName = epr.portName;
+    this.referenceProperties = new java.util.LinkedList(epr.referenceProperties);
+    this.referenceParameters = new java.util.LinkedList(epr.referenceParameters);
+  }
+
+  protected EndpointReference() {}
+
+  public EndpointReference dup() throws Exception {
+    EndpointReference newObj = (EndpointReference)this.getClass().newInstance();
+    newObj.setAddress( this.getAddress() );
+    newObj.setPortType( this.getPortType() );
+    newObj.setServiceName( this.getServiceName() );
+    newObj.setPortName( this.getPortName() );
+    if ( this.referenceProperties != null ) {
+      for ( int i = 0 ; i < this.referenceProperties.size() ; i++ ) {
+        String prop = (String) this.referenceProperties.get(i);
+        newObj.addReferenceProperty( new String(prop) );
+      }
+    }
+    if ( this.referenceParameters != null ) {
+      for ( int i = 0 ; i < this.referenceParameters.size() ; i++ ) {
+        String prop = (String) this.referenceParameters.get(i);
+        newObj.addReferenceProperty( new String(prop) );
+      }
+    }
+    return newObj ;
+  }
+
+  public String toString() {
+    return "" + getClass() +"@"+ hashCode() + " address: '" +address + 
+           "' refProps: '" + referenceProperties + "' refParams: '" + 
+           referenceParameters + "'"; 
+  }
+
+
+  /*-- Methods to create an instance ---*/
+
+  public static EndpointReference newInstance() {
+     return new AxisEndpointReference();
+  }
+
+  public static EndpointReference Anonymous() throws Exception { 
+    return AnonymousEPR.dup() ; 
+  }
+
+  public boolean isAnonymous() {
+    return WSAConstants.Anonymous_Address.equals( this.address );
+  }
+
+  /**
+   * Method to return a new EndpointReference object from
+   * a DOM element.
+   * 
+   * @param el
+   * 
+   * @return EndpointReference
+   */
+  public static EndpointReference fromDOM(Element el) throws Exception {
+     EndpointReference er = new AxisEndpointReference();
+     NodeList nl = el.getElementsByTagNameNS(WSAConstants.NS_WSA, "Address");
+     if ( nl.getLength() == 0 ) {
+       String tmp = "Missing Address in EPR: " + XMLUtils.ElementToString(el);
+       throw new Exception( tmp );
+     }
+     if (nl.item(0)!=null) {
+       er.setAddress(Util.getText((Element)nl.item(0)));
+     }
+     nl = el.getElementsByTagNameNS(WSAConstants.NS_WSA, "PortType");
+     if (nl.item(0)!=null) {
+       er.setPortType(Util.getText((Element)nl.item(0)));
+     }
+     nl = el.getElementsByTagNameNS(WSAConstants.NS_WSA, "ServiceName");
+     if (nl.item(0)!=null) {
+       Element child = (Element)nl.item(0);
+       er.setServiceName(Util.getText(child));
+       er.setPortName(child.getAttributeNS(WSAConstants.NS_WSA, "PortName"));
+     }
+     nl = el.getElementsByTagNameNS(WSAConstants.NS_WSA, "ReferenceProperties");
+     if (nl.item(0)!=null) {
+       nl = nl.item(0).getChildNodes();
+  
+       for ( int i = 0 ; nl != null && i < nl.getLength() ; i++ ) {
+         Node n = nl.item(i);
+         if ( n.getNodeType() != Node.ELEMENT_NODE ) continue ;
+         n = n.cloneNode(true);
+         er.addReferenceProperty( XMLUtils.ElementToString((Element) n) );
+       }
+     }
+     nl = el.getElementsByTagNameNS(WSAConstants.NS_WSA, "ReferenceParameters");
+     if (nl.item(0)!=null) {
+       nl = nl.item(0).getChildNodes();
+  
+       for ( int i = 0 ; nl != null && i < nl.getLength() ; i++ ) {
+         Node n = nl.item(i);
+         if ( n.getNodeType() != Node.ELEMENT_NODE ) continue ;
+         n = n.cloneNode(true);
+         er.addReferenceParameter( XMLUtils.ElementToString((Element) n) );
+       }
+     }
+     return er ;
+  }
+
+/**
+ * Method fromLocation. Obtain an endpoint reference from a String that contains in a URL
+ *  format the location of the service.
+ * @param location The location of the service.
+ * @return EndpointReference
+ */
+  public static EndpointReference fromLocation( final String location){
+    return new AxisEndpointReference(location);
+  }
+
+/**
+ * Method getAddress returns the address of the Service Endpoint..
+ * @return String
+ */
+  public String getAddress() {
+    return address;
+  }
+
+  public void setAddress(final String address) {
+    this.address = address;
+  }
+
+/**
+ * Method getServiceName return QName of the service if available.
+ * @return QName the QName of the service.
+ */
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String sn) {
+     serviceName = sn;
+  }
+
+/**
+ * Method getPortName return the PortName in the service if available.
+ * @return String the portname in the service.
+ */
+  public String getPortName() {
+    return portName;
+  }
+
+  public void setPortName(String portName) {
+     this.portName = portName;
+  }
+
+/**
+ * Method getPortType the WSDL PortType if available..
+ * @return String
+ */
+  public String getPortType() {
+    return portType;
+  }
+
+  public void setPortType(String pt) {
+     portType = pt;
+  }
+
+  protected java.util.List headers = null; 
+
+  protected synchronized List createWsaHeaderElements() throws javax.xml.parsers.ParserConfigurationException {
+    if (headers != null) return headers;
+    headers = new java.util.LinkedList();
+    DocumentBuilderFactory  dbf = DocumentBuilderFactory.newInstance();
+
+    dbf.setNamespaceAware(true);
+    dbf.setValidating(false);
+
+    DocumentBuilder db = dbf.newDocumentBuilder();
+
+    Document ehrDoc = db.newDocument();
+    Element child = ehrDoc.createElementNS(WSAConstants.NS_WSA, "To"); 
+
+    child.appendChild(ehrDoc.createTextNode(address));
+    headers.add(child);
+    if (null != referenceProperties && !referenceProperties.isEmpty()) {
+      for (Iterator i = referenceProperties.iterator(); i.hasNext();) {
+        Node refNode = (Node) i.next(); 
+
+        headers.add(ehrDoc.importNode(refNode, true));
+      }
+    }  
+    if (null != referenceParameters && !referenceParameters.isEmpty()) {
+      for (Iterator i = referenceParameters.iterator(); i.hasNext();) {
+        Node refNode = (Node) i.next(); 
+
+        headers.add(ehrDoc.importNode(refNode, true));
+      }
+    }  
+    return headers;
+  }
+
+  public Element toDOM() throws javax.xml.parsers.ParserConfigurationException {
+     return toDOM(null, null);
+  }
+/**
+ * Method toDOM.
+ * @return Element The element that represents the Endpoint reference.
+ * @throws ParserConfigurationException
+ */
+   public Element toDOM(String ns, String name) throws javax.xml.parsers.ParserConfigurationException {
+     return toDOM( "ns99", ns, name );
+   }
+
+   public Element toDOM(String prefix, String ns, String name) throws javax.xml.parsers.ParserConfigurationException {
+    headers = new java.util.LinkedList();
+    DocumentBuilderFactory  dbf = DocumentBuilderFactory.newInstance();
+
+    dbf.setNamespaceAware(true);
+    dbf.setValidating(false);
+
+    DocumentBuilder db = dbf.newDocumentBuilder();
+
+    Document ehrDoc = db.newDocument();
+    Element rootChild = null;
+    if (ns == null) {
+       rootChild = ehrDoc.createElementNS(WSAConstants.NS_WSA, "EndpointReference"); 
+       rootChild.setPrefix("wsa");
+    } else {
+       rootChild = ehrDoc.createElementNS(ns, name); 
+       rootChild.setPrefix( prefix );
+    }
+    ehrDoc.appendChild( rootChild);
+
+    // Address
+    Element child = ehrDoc.createElementNS(WSAConstants.NS_WSA, "Address"); 
+    child.setPrefix("wsa");
+    child.appendChild(ehrDoc.createTextNode(address));
+    rootChild.appendChild(child);
+
+    // PortType
+    if (portType!=null) {
+       Element pt = ehrDoc.createElementNS(WSAConstants.NS_WSA, "PortType"); 
+       pt.setPrefix("wsa");
+       pt.appendChild(ehrDoc.createTextNode(portType));
+       rootChild.appendChild(pt);
+    }
+    
+    // ServiceName
+    if (serviceName!=null) {
+       Element sn = ehrDoc.createElementNS(WSAConstants.NS_WSA, "ServiceName"); 
+       sn.setPrefix("wsa");
+       if (portName!=null) {
+	  Attr attr = ehrDoc.createAttributeNS(WSAConstants.NS_WSA, "PortName");
+	  attr.setValue(this.portName);
+          sn.setAttributeNodeNS(attr); 
+       }
+       sn.appendChild(ehrDoc.createTextNode(serviceName));
+       rootChild.appendChild(sn);
+    }
+
+    // Reference properties
+    if (null != referenceProperties && !referenceProperties.isEmpty()) {
+      Element refProp= ehrDoc.createElementNS(WSAConstants.NS_WSA, WSAConstants.EN_ReferenceProperties); 
+      refProp.setPrefix("wsa");
+      for (Iterator i = referenceProperties.iterator(); i.hasNext();) {
+        String  refStr  = (String) i.next();
+        Element refNode = XMLUtils.StringToElement( refStr );
+
+        refProp.appendChild(ehrDoc.importNode(refNode, true));
+      }
+      rootChild.appendChild(refProp);
+    }  
+
+    // Reference parameters
+    if (null != referenceParameters && !referenceParameters.isEmpty()) {
+      Element refProp= ehrDoc.createElementNS(WSAConstants.NS_WSA, WSAConstants.EN_ReferenceParameters); 
+      refProp.setPrefix("wsa");
+      for (Iterator i = referenceParameters.iterator(); i.hasNext();) {
+        String refStr  = (String) i.next();
+        Node   refNode = XMLUtils.StringToElement( refStr );
+
+        refProp.appendChild(ehrDoc.importNode(refNode, true));
+      }
+      rootChild.appendChild(refProp);
+    }  
+    return rootChild;
+  }
+
+  public void addReferenceProperty(String str) {
+    referenceProperties.add( str );
+  }
+
+  public void addReferenceProperty(Element elem) {
+    addReferenceProperty( XMLUtils.ElementToString(elem) );
+  }
+
+  public void addReferenceProperty(String ns, String elemName, String value) 
+    throws Exception {
+    newReferenceProperty(ns, elemName, value);
+  }
+
+  // Util
+  public Element newReferenceProperty(String ns, String name) throws Exception {
+    return newReferenceProperty(null, ns, name, null );
+  }
+
+  public Element newReferenceProperty(String ns, String name, String value) 
+      throws Exception {
+    return newReferenceProperty(null, ns, name, value );
+  }
+
+  public Element newReferenceProperty(String prefix, String ns, String name, 
+                                      String value)
+       throws Exception {
+    DocumentBuilderFactory  dbf = DocumentBuilderFactory.newInstance();
+    dbf.setNamespaceAware(true);
+    dbf.setValidating(false);
+
+    DocumentBuilder db  = dbf.newDocumentBuilder();
+    Document        doc = db.newDocument();
+    Element         elem = doc.createElementNS( ns, name );
+    if ( prefix == null ) prefix = "t" ;
+    // if ( prefix != null ) 
+    elem.setPrefix( prefix );
+
+    if ( value != null )
+      elem.appendChild( doc.createTextNode( value ) );
+
+    referenceProperties.add( XMLUtils.ElementToString(elem) );
+
+    return elem ;
+  }
+
+  public List getReferenceProperties() {
+    return referenceProperties;
+  }
+
+
+  public void addReferenceParameter(String str) {
+    referenceParameters.add(str);
+  }
+
+  public void addReferenceParameter(Element element) {
+    addReferenceParameter( XMLUtils.ElementToString(element) );
+  }
+
+  // Util
+  public Element newReferenceParameter(String ns, String name) throws Exception {
+    return newReferenceParameter(null, ns, name, null );
+  }
+
+  public Element newReferenceParameter(String ns, String name, String value) 
+      throws Exception {
+    return newReferenceParameter(null, ns, name, null );
+  }
+
+  public Element newReferenceParameter(String prefix, String ns, String name, 
+                                      String value)
+       throws Exception {
+    DocumentBuilderFactory  dbf = DocumentBuilderFactory.newInstance();
+    dbf.setNamespaceAware(true);
+    dbf.setValidating(false);
+
+    DocumentBuilder db  = dbf.newDocumentBuilder();
+    Document        doc = db.newDocument();
+    Element         elem = doc.createElementNS( ns, name );
+    if ( prefix != null ) 
+      elem.setPrefix( prefix );
+
+    if ( value != null )
+      elem.appendChild( doc.createTextNode( value ) );
+
+    addReferenceParameter( XMLUtils.ElementToString(elem) );
+
+    return elem ;
+  }
+
+  public List getReferenceParameters() {
+    return referenceParameters;
+  }
+
+}

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/MIHeader.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/MIHeader.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/MIHeader.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/MIHeader.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,385 @@
+package org.apache.axis.wsa ;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Enumeration;
+import java.util.Vector;
+import javax.xml.soap.SOAPException;
+import javax.xml.namespace.QName;
+import org.w3c.dom.Document;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+import org.apache.axis.AxisFault;
+import org.apache.axis.message.*;
+import org.apache.axis.MessageContext;
+import org.apache.axis.Message;
+import org.apache.axis.utils.XMLUtils;
+
+import java.util.Stack;
+import org.xml.sax.Attributes;
+import org.apache.axis.message.SOAPHeaderElement;
+import javax.xml.rpc.Call;
+
+
+/**
+ * MIHeader class represents the Message Information Headers
+ * described in the WS-Addressing specification.
+ * This is not a data class.
+ * This class consists of a set of utility functions to
+ * create and read these headers to/from a message.
+ */
+public class MIHeader {
+  boolean           requestMessage = false;
+
+  String            messageID           = null ;
+  Vector            relatesTo           = null ;
+  EndpointReference replyTo             = null ;
+  EndpointReference from                = null ;
+  EndpointReference faultTo             = null ;
+  EndpointReference toFault             = null ;  // See below
+  EndpointReference to                  = null ;
+  String            action              = null ;
+  boolean           processedOnGet      = true ;
+  boolean           removeOnGet         = false ;
+  boolean           mustUnderstand      = false;
+
+  // 'faultTo' is the value that will appear in the SOAP envelope.
+  // 'toFault' is a special case field.  When the server receives a message
+  // it generates the response MIHeader right away so that people can override
+  // values as needed.  When 'To' field is set based on either the ReplyTo
+  // or the anonymous URI.  However, if a Fault is generated on the server
+  // the the request message's FaulTo field should be used instead of the To
+  // field.  Now, we alow the user (service/handlers...) to override any of
+  // the fields in the response MIHeader - we need to allow them to override
+  // the To field in the Fault case as well - hence the need for two different
+  // "To" fields - one for normal messages and one for faults.  Lousy name
+  // but it works.
+
+  public String toString() {
+    return "{id:" + getMessageID()+ " to:" + getTo() + " from:" + getFrom() +
+           " replyTo:" + getReplyTo() + " faultTo:" + getFaultTo() +
+           " action:" + getAction() + " toFault:" + getToFault() + "}" ;
+  }
+
+  // Potentially problem causing. Would rather remove this constructor
+  public MIHeader() {
+    processedOnGet = true ;
+    removeOnGet = false ;
+    setMessageID( "uuid:" + UUIDGenerator.getInstance().getUUID());
+  }
+
+  /**
+   * Constructor intended for client use to create an
+   * MIHeader instance that will interact with a Call
+   * object.
+   * 
+   * @param call
+   * 
+   * @exception AxisFault
+   */
+  public MIHeader(javax.xml.rpc.Call call) throws AxisFault {
+    processedOnGet = true ;
+    removeOnGet = false ;
+    call.setProperty( WSAConstants.REQ_MIH, this );
+    setMessageID( "uuid:" + UUIDGenerator.getInstance().getUUID());
+  }
+
+  public MIHeader(javax.xml.rpc.Call call, boolean _mustUnderstand) throws AxisFault {
+    mustUnderstand = _mustUnderstand ;
+    processedOnGet = true ;
+    removeOnGet = false ;
+    call.setProperty( WSAConstants.REQ_MIH, this );
+    setMessageID( "uuid:" + UUIDGenerator.getInstance().getUUID());
+  }
+
+  public static MIHeader fromCurrentMessage() throws Exception {
+     if ( MessageContext.getCurrentContext().getPastPivot() ) 
+       return fromResponse();
+     else
+       return fromRequest();
+  }
+
+  /**
+   * Instantiate a MIHeader object from the current
+   * request message. This is intended for receiving
+   * service use. It may also be used by client or server
+   * side handlers.
+   * 
+   * @return 
+   */
+  public static MIHeader fromRequest() throws Exception {
+     MessageContext msgContext = MessageContext.getCurrentContext();
+     MIHeader mih = (MIHeader)msgContext.getProperty(WSAConstants.REQ_MIH);
+     if (mih == null) {
+       Message msg = msgContext.getRequestMessage();
+       if ( msg == null ) return null ;
+       mih = new MIHeader();
+       mih.removeOnGet = false ;
+       mih.fromEnvelope( (SOAPEnvelope) msg.getSOAPPart().getEnvelope() );
+       if ( mih.getTo() == null && mih.getFrom() == null) return null ;
+       msgContext.setProperty( WSAConstants.REQ_MIH, mih );
+     }
+     return mih;
+  }
+  
+  /**
+   * Instantiate an MIHeader object from the current
+   * response message.
+   * 
+   * @return 
+   */
+  public static MIHeader fromResponse() throws Exception {
+     MessageContext msgContext = MessageContext.getCurrentContext();
+     MIHeader mih = (MIHeader) msgContext.getProperty(WSAConstants.RES_MIH);
+     if (mih==null) {
+       Message msg = msgContext.getResponseMessage();
+       if ( msg == null ) return null ;
+       mih = new MIHeader();
+       mih.removeOnGet = false ;
+       mih.fromEnvelope( (SOAPEnvelope) msg.getSOAPPart().getEnvelope() );
+       if ( mih.getTo() == null && mih.getFrom() == null ) return null ;
+       msgContext.setProperty(WSAConstants.RES_MIH, mih );
+     }
+     return mih;
+  }
+
+  public MIHeader generateReplyMI() throws Exception {
+    MIHeader newMIH = new MIHeader();
+
+    EndpointReference toEPR = getEffectiveReplyTo();
+    newMIH.setFrom( to );
+    newMIH.setTo( toEPR );
+    newMIH.setToFault( faultTo );
+    newMIH.setAction( action + "Response" );
+    newMIH.setMessageID( "uuid:" + UUIDGenerator.getInstance().getUUID());
+    newMIH.addRelatesTo(messageID, "wsa:Reply" );
+    return newMIH ;
+  }
+
+  public void fromEnvelope(SOAPEnvelope env) throws Exception {
+    SOAPHeaderElement header = null ;
+
+    header = env.getHeaderByName(WSAConstants.NS_WSA, "MessageID");
+    if ( header != null ) {
+      messageID = Util.getText( header.getAsDOM() );
+      if ( processedOnGet ) header.setProcessed(true);
+      if ( removeOnGet ) env.removeHeader( header );
+    }
+    else messageID = null ;
+
+    header = env.getHeaderByName(WSAConstants.NS_WSA, "To");
+    if ( header != null ) {
+      to = EndpointReference.fromLocation( Util.getText( header.getAsDOM() ) );
+      if ( processedOnGet ) header.setProcessed(true);
+      if ( removeOnGet ) env.removeHeader( header );
+    }
+    else to = null ;
+
+    header = env.getHeaderByName(WSAConstants.NS_WSA, "Action");
+    if ( header != null ) {
+      action = Util.getText( header.getAsDOM() );
+      if ( processedOnGet ) header.setProcessed(true);
+      if ( removeOnGet ) env.removeHeader( header );
+    }
+    else action = null ;
+
+    header = env.getHeaderByName(WSAConstants.NS_WSA, "From");
+    if ( header != null ) {
+      from = EndpointReference.fromDOM( header.getAsDOM() );
+      if ( processedOnGet ) header.setProcessed(true);
+      if ( removeOnGet ) env.removeHeader( header );
+    }
+    else from = null ;
+
+    header = env.getHeaderByName(WSAConstants.NS_WSA, "ReplyTo");
+    if ( header != null ) {
+      replyTo = EndpointReference.fromDOM( header.getAsDOM() );
+      if ( processedOnGet ) header.setProcessed(true);
+      if ( removeOnGet ) env.removeHeader( header );
+    }
+    else replyTo = null ;
+
+    Enumeration enum = env.getHeadersByName(WSAConstants.NS_WSA, "RelatesTo");
+    if ( enum.hasMoreElements() ) {
+      relatesTo = new Vector();
+      while ( enum.hasMoreElements() ) {
+        header = (SOAPHeaderElement) enum.nextElement();
+        String type = header.getAttributeValue(new org.apache.axis.message.PrefixedQName("","RelationshipType", ""));
+        String uri  = header.getValue();
+        relatesTo.add(new RelatesToProperty(uri, type));
+        if ( processedOnGet ) header.setProcessed(true);
+        if ( removeOnGet ) env.removeHeader( header );
+      }
+    }
+    else relatesTo = null ;
+
+    header = env.getHeaderByName(WSAConstants.NS_WSA, "FaultTo");
+    if ( header != null ) {
+      faultTo = EndpointReference.fromDOM( header.getAsDOM() );
+      if ( processedOnGet ) header.setProcessed(true);
+      if ( removeOnGet ) env.removeHeader( header );
+    }
+    else faultTo = null ;
+  }
+
+  public void toEnvelope(SOAPEnvelope env) throws Exception {
+    SOAPHeaderElement header = null ;
+
+    if ( env.getNamespaceURI("wsa") == null )
+      env.addNamespaceDeclaration("wsa", WSAConstants.NS_WSA );
+
+    if ( messageID != null ) {
+      header = new SOAPHeaderElement( WSAConstants.NS_WSA, "MessageID" );
+      header.setActor( null );
+      header.addTextNode(messageID);
+      header.setMustUnderstand(mustUnderstand);
+      env.addHeader(header);
+    }
+
+    if ( to != null ) {
+      header = new SOAPHeaderElement( WSAConstants.NS_WSA, "To" );
+      header.setActor( null );
+      header.addTextNode( to.getAddress() );
+      header.setMustUnderstand(mustUnderstand);
+      env.addHeader(header);
+      List refProps = to.getReferenceProperties();
+      if ( refProps != null ) {
+        for ( int i = 0 ; i < refProps.size() ; i++ ) {
+          String elem = (String) refProps.get(i);
+          SOAPHeaderElement h1 = 
+            new SOAPHeaderElement(XMLUtils.StringToElement(elem));
+          h1.setActor( null );
+          h1.setMustUnderstand(mustUnderstand);
+          env.addHeader( h1 );
+        }
+      }
+      List refParams = to.getReferenceParameters();
+      if ( refParams != null ) {
+        for ( int i = 0 ; i < refParams.size() ; i++ ) {
+          String elem = (String) refParams.get(i);
+          SOAPHeaderElement h1 = 
+            new SOAPHeaderElement(XMLUtils.StringToElement(elem));
+          h1.setActor( null );
+          h1.setMustUnderstand(mustUnderstand);
+          env.addHeader( h1 );
+        }
+      }
+    }
+
+    if ( action != null ) {
+      header = new SOAPHeaderElement( WSAConstants.NS_WSA, "Action" );
+      header.setActor( null );
+      header.addTextNode( action );
+      header.setMustUnderstand(mustUnderstand);
+      env.addHeader(header);
+    }
+
+    if ( from != null ) {
+      header = new SOAPHeaderElement(from.toDOM("wsa",WSAConstants.NS_WSA, "From"));
+      header.setActor( null );
+      header.setMustUnderstand(mustUnderstand);
+      env.addHeader(header);
+    }
+
+    if ( replyTo != null ) {
+      header = new SOAPHeaderElement(replyTo.toDOM("wsa", WSAConstants.NS_WSA,
+                                                   "ReplyTo"));
+      header.setActor( null );
+      header.setMustUnderstand(mustUnderstand);
+      env.addHeader(header);
+    }
+
+    if ( relatesTo != null ) {
+      for ( int i = 0 ; i < relatesTo.size() ; i++ ) {
+        RelatesToProperty rtp = (RelatesToProperty) relatesTo.get(i);
+        header = new SOAPHeaderElement( WSAConstants.NS_WSA, "RelatesTo" );
+        header.setActor( null );
+        if ( rtp.getType() != null && !"wsa:Reply".equals(rtp.getType()) ) {
+          header.setAttribute("", "RelationshipType", rtp.getType() );
+        }
+        header.addTextNode( rtp.getURI() );
+        header.setMustUnderstand(mustUnderstand);
+        env.addHeader(header);
+      }
+    }
+
+    if ( faultTo != null ) {
+      header = new SOAPHeaderElement(faultTo.toDOM("wsa", WSAConstants.NS_WSA, 
+                                                   "FaultTo"));
+      header.setActor( null );
+      header.setMustUnderstand(mustUnderstand);
+      env.addHeader(header);
+    }
+  }
+
+  public void setProcessedOnGet(boolean processedOnGet) {
+     this.processedOnGet = processedOnGet;
+
+  }
+  public void setRemoveOnGet(boolean removeOnGet) {
+     this.removeOnGet = removeOnGet;
+  }
+
+  //------------------------------------------------------
+  // Getters and setters
+  //------------------------------------------------------
+
+  public String getMessageID() { return messageID ; }
+  public void   setMessageID(String id) { messageID = id ; }
+
+  public Vector getRelatesTo() { return relatesTo ; }
+  /**
+   * Set the collection of RelatesToProperties. Not additive,
+   * this replaces the current collection.
+   * 
+   * @param v      Vector of RelatesToProperties
+   */
+  public void   setRelatesTo(Vector v) {
+    int i = 0 ;
+    for ( ; v != null && i < v.size() ; i++ ) {
+      if ( i == 0 ) relatesTo = new Vector();
+      RelatesToProperty rtp = (RelatesToProperty) v.get(i);
+      addRelatesTo( rtp.getURI(), rtp.getType() );
+    }
+    if ( i == 0 ) relatesTo = null ;
+  }
+
+  public void addRelatesTo(String uri, String type) {
+    if ( relatesTo == null ) relatesTo = new Vector();
+    relatesTo.add( new RelatesToProperty(uri, type) );
+  }
+
+  /*public void addRelatesToProperty(RelatesToProperty rtp) {
+     relatesTo.add(rtp);
+  } */
+
+  public EndpointReference getTo() { return to ; }
+  public void   setTo(String _to) { to = EndpointReference.fromLocation(_to) ; }
+  public void   setTo(EndpointReference epr) { to = epr ; }
+
+  public String getAction() { return action ; }
+  public void   setAction(String _action) { action = _action ; }
+
+  public EndpointReference getFrom(){ return from ; }
+  public void              setFrom(EndpointReference epr) { from = epr ; }
+  
+  public EndpointReference getReplyTo(){ return replyTo ; }
+  public void              setReplyTo(EndpointReference epr) { replyTo = epr ; }
+  
+  public EndpointReference getFaultTo(){ return faultTo ; }
+  public void              setFaultTo(EndpointReference epr) {this.faultTo=epr;}
+
+  public EndpointReference getToFault(){ return toFault ; }
+  public void              setToFault(EndpointReference epr) {this.toFault=epr;}
+
+  public EndpointReference getEffectiveReplyTo() {
+    if ( replyTo != null ) return getReplyTo();
+    if ( from    != null ) return getFrom();
+    return EndpointReference.fromLocation(WSAConstants.Anonymous_Address);
+  }
+
+}

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/RelatesToProperty.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/RelatesToProperty.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/RelatesToProperty.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/RelatesToProperty.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,31 @@
+package org.apache.axis.wsa;
+
+import org.w3c.dom.Element;
+
+  public class RelatesToProperty {
+     String uri;
+     String type;
+
+     RelatesToProperty() {
+        // default constructor
+     }
+
+     public RelatesToProperty(String uri, String type) {
+        this.uri = uri;
+        this.type = type;
+     }
+
+     static RelatesToProperty newInstance(Element el) {
+        String uri = Util.getText(el);
+        String type = el.getAttributeNS(WSAConstants.NS_WSA, "RelationshipType");
+        RelatesToProperty rp = new RelatesToProperty(uri, type);
+        return rp;
+     }
+
+     public String getURI() { return uri ; }
+     public String getType() { return type ; }
+
+     public String toString() {
+       return "Rel:[" + uri + ":" + type + "]" ;
+     }
+  }

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/UUIDGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/UUIDGenerator.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/UUIDGenerator.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/UUIDGenerator.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,115 @@
+package org.apache.axis.wsa;
+
+import java.net.InetAddress;
+import java.security.SecureRandom;
+import java.util.Random;
+
+public class UUIDGenerator
+{
+  private static UUIDGenerator gen = null;
+  
+  private Random seeder;
+  private String midValue;
+  private String baseURI = "http://axis.apache.org/guid/";
+  
+  protected UUIDGenerator()
+  {
+    try {
+      // get the internet address
+      InetAddress inet = InetAddress.getLocalHost();
+      byte[] bytes = inet.getAddress();
+      String hexInetAddress = hexFormat(getInt(bytes),8);
+      
+      // get the hashcode for this object
+      String thisHashCode = hexFormat(System.identityHashCode(this),8);
+      
+      // set up midvalue string
+      this.midValue = hexInetAddress+thisHashCode;
+      
+      //load up the randomizer
+      seeder = new Random(); // SecureRandom();
+      int node = seeder.nextInt();
+      
+    }
+    catch(Exception e)
+    {
+      e.printStackTrace();
+    }
+    
+  }
+  
+  public static UUIDGenerator getInstance()
+  {
+    if (gen == null)
+    {
+      gen = new UUIDGenerator();
+    }    
+    return gen;
+  }
+
+  public String getUUID()
+  {
+    long timeNow = System.currentTimeMillis();
+    
+    // get int value as unsigned
+    int timeLow = (int) timeNow & 0xFFFFFFFF;
+    
+    // get next random value
+    int node = seeder.nextInt();
+    
+    return (hexFormat(timeLow,8) + midValue + hexFormat(node,8));
+  }
+  
+  public String getUUIDURI()
+  {
+    long timeNow = System.currentTimeMillis();
+    
+    // get int value as unsigned
+    int timeLow = (int) timeNow & 0xFFFFFFFF;
+    
+    // get next random value
+    int node = seeder.nextInt();
+    
+    return baseURI + (hexFormat(timeLow,8) + midValue + hexFormat(node,8));
+    
+  }
+  
+  private int getInt(byte[] byteInput)
+    {
+        int i = 0;
+        int j = 24;
+        for(int k = 0; j >= 0; k++)
+        {
+            int l = byteInput[k] & 0xff;
+            i += l << j;
+            j -= 8;
+        }
+
+        return i;
+    }
+
+    private String hexFormat(int i, int len)
+    {
+        String str = Integer.toHexString(i);
+        StringBuffer stringbuffer = new StringBuffer();
+        int actualLen = str.length();
+        
+        if(actualLen < len)
+        {
+            for(int j = 0; j < len - actualLen; j++)
+                stringbuffer.append("0");
+
+        }
+        stringbuffer.append(str);
+        
+        return stringbuffer.toString();
+        
+    }
+
+    public void setBaseURI(String baseURI)
+    {
+      this.baseURI = baseURI;
+    }
+   
+}
+

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/Util.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/Util.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/Util.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/Util.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,77 @@
+package org.apache.axis.wsa ;
+
+import org.w3c.dom.*;
+
+public class Util{
+  private Util(){};
+
+   /**
+    * Performs a utility function.
+    * Returns text contained in child elements of the
+    * passed in element.
+    *
+    * @param el     Element
+    * @return java.lang.String
+    */
+   static String getText(Node el) {
+      NodeList nl = el.getChildNodes();
+      String result = "";
+      for (int i = 0; i < nl.getLength(); i++) {
+         if (nl.item(i).getNodeType()==Element.TEXT_NODE) {
+            result += nl.item(i).getNodeValue();
+         }
+      }
+      // Trim result, to remove whitespace.
+      return result.trim();
+   }
+
+     /* Is "base" like "cmpStr" - in other words "cmpStr" is the one  */
+  /* that can contain wildcards  *, ? and \ for esc                */
+  static public boolean isLike(String base, String cmpStr) {
+    int     bi = 0 , ci = 0 ;
+    boolean skip = false ;
+    char bChar, cChar ;
+    char nextCChar ;
+
+    if ( base == null ) base = "" ;
+    if ( cmpStr == null ) cmpStr = "" ;
+
+    for ( ; ; ) {
+      bChar = (bi == base.length() ? '\0' : base.charAt(bi));
+      cChar = (ci == cmpStr.length() ? '\0' : cmpStr.charAt(ci));
+
+      if ( cChar == '\\' ) {
+        skip = true ;
+        ci++ ;
+        cChar = (ci == cmpStr.length() ? '\0' : cmpStr.charAt(ci));
+      }
+
+      if ( !skip && cChar == '*' ) {
+        while( cChar == '*' ) {
+          ci++ ;
+          cChar = (ci == cmpStr.length() ? '\0' : cmpStr.charAt(ci));
+        }
+        for ( ; bChar != '\0' ;
+                bi++,bChar = (bi==base.length() ? '\0' : base.charAt(bi)) ) {
+          nextCChar = (ci+1 >= cmpStr.length() ? '\0' : cmpStr.charAt(ci+1));
+          if ( cChar != '?' &&
+               ( ( cChar != '\\' && bChar != cChar) ||
+                 ( cChar == '\\' && bChar != nextCChar) ))
+            continue ;
+            if ( isLike(base.substring(bi), cmpStr.substring(ci)) )
+              return( true );
+        }
+        nextCChar = (ci+1 >= cmpStr.length() ? '\0' : cmpStr.charAt(ci+1));
+        return( cChar == '\0' || (cChar == '\\' && nextCChar != '\0') );
+      }
+      if ( bChar != cChar ) {
+        if ( cChar != '?' || skip ) return( false );
+        if ( bChar == '\0' ) return( false );
+      }
+      if ( bChar == '\0' ) return( true );
+      bi++ ;
+      ci++ ;
+      skip = false ;
+    }
+  }
+}

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAConstants.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAConstants.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAConstants.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,37 @@
+package org.apache.axis.wsa ;
+
+import javax.xml.namespace.QName;
+
+public interface WSAConstants {
+  public final String NS_WSA = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+
+  public final String EN_EndpointReference = "EndpointReference";
+  public final QName  QN_EndpointReference = new QName(NS_WSA, EN_EndpointReference);
+  public final String EN_Address = "Address";
+  public final QName  QN_Address = new QName(NS_WSA, EN_Address);
+
+  public final String EN_ReferenceProperties = "ReferenceProperties";
+  public final QName  QN_ReferenceProperties = new QName(NS_WSA, EN_ReferenceProperties);
+
+  public final String EN_ReferenceParameters = "ReferenceParameters";
+  public final QName  QN_ReferenceParameters = new QName(NS_WSA, EN_ReferenceParameters);
+
+  public final String EN_PortType = "PortType";
+  public final QName  QN_PortType = new QName(NS_WSA, EN_PortType);
+
+  public final String EN_ServiceName = "ServiceName";
+  public final QName  QN_ServiceName = new QName(NS_WSA, EN_ServiceName);
+
+  public final String EN_Policy = "Policy";
+  public final QName  QN_Policy = new QName(NS_WSA, EN_Policy);
+
+  public final String Anonymous_Address = NS_WSA + "/role/anonymous" ;
+  public final String Fault_URI = NS_WSA + "/fault" ;
+
+  public final String OUTBOUND_MIH = "org.apache.axis.wsa.outboundMIH" ;
+  public final String INBOUND_MIH  = "org.apache.axis.wsa.inboundMIH" ;
+
+  public final String REQ_MIH = "org.apache.axis.wsa.reqMIHeader" ;
+  public final String RES_MIH = "org.apache.axis.wsa.resMIHeader" ;
+  public final String WSA_DONT_REROUTE = "org.apache.axis.wsa.dontroute";
+}

Added: webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAHandler.java?rev=371781&view=auto
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAHandler.java (added)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsa/WSAHandler.java Mon Jan 23 18:52:30 2006
@@ -0,0 +1,216 @@
+package org.apache.axis.wsa;
+
+import org.apache.axis.AxisFault;
+import org.apache.axis.client.Call;
+import org.apache.axis.client.Service;
+import org.apache.axis.Message;
+import org.apache.axis.MessageContext;
+import org.apache.axis.handlers.BasicHandler;
+import org.apache.axis.message.*;
+import java.util.Vector;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import org.apache.axis.message.SOAPBodyElement;
+
+public class WSAHandler { // extends BasicHandler {
+
+   public static void invoke(MessageContext msgContext) throws AxisFault {
+      boolean onClient = true;
+      boolean request  = true;
+
+
+      // Request or response?
+      if (msgContext.getCurrentContext().getPastPivot()) {
+         request = false;
+      } else {
+         request = true;
+      }
+
+      // Determine if we're on the client or server
+      if (msgContext.getCurrentContext().isClient()) {
+         onClient = true;
+      } else {
+         onClient = false;
+      }
+
+      try {
+         if (onClient && request ) {
+            // Process client request
+            processClientRequest(msgContext);
+         } else if (onClient && !request) {
+            // Process client response
+            processClientResponse(msgContext);
+         } else if (!onClient && request) {
+            // Process server request
+            processServerRequest(msgContext);
+         } else if (!onClient && !request) {
+            // Process server response
+            processServerResponse(msgContext);
+         }
+      } catch (Exception e) {
+         e.printStackTrace();
+         throw new AxisFault(e.getMessage());
+      }
+
+   }
+
+   static void processClientRequest(MessageContext msgContext) throws Exception {
+     MIHeader mih = (MIHeader)msgContext.getProperty(WSAConstants.REQ_MIH);
+     Message  msg = msgContext.getRequestMessage();
+
+     if ( mih == null ) {
+       if ( msgContext.getAxisEngine().getOption("useWSA") == null &&
+            msgContext.getProperty("useWSA") == null )
+         return ;
+
+       msgContext.setProperty(WSAConstants.REQ_MIH, mih = new MIHeader());
+       mih.setRemoveOnGet(true);
+       mih.fromEnvelope( msg.getSOAPEnvelope() );
+     }
+
+     if ( mih.getMessageID() == null )
+       mih.setMessageID( "uuid:" + UUIDGenerator.getInstance().getUUID() );
+
+     if ( mih.getTo() == null )
+       mih.setTo( msgContext.getStrProp( msgContext.TRANS_URL ) );
+     if ( mih.getAction() == null )
+       mih.setAction( msgContext.getSOAPActionURI() );
+
+     mih.toEnvelope( msg.getSOAPEnvelope() );
+   }
+
+   static void processClientResponse(MessageContext msgContext) throws Exception {
+      Message msg = msgContext.getResponseMessage();
+      if ( msg == null ) return ;
+
+      MIHeader mih = new MIHeader();
+
+      SOAPEnvelope env = msg.getSOAPEnvelope();
+      if ( env == null ) return ;
+
+      mih.fromEnvelope( env );
+      msgContext.setProperty( WSAConstants.RES_MIH, mih );
+   }
+
+   static void processServerRequest(MessageContext msgContext) throws Exception {
+      MIHeader mih = MIHeader.fromRequest();
+
+      // If mih is null then assume there were no headers and just leave
+      if ( mih == null ) return ;
+      String to = null ;
+      if ( mih.getTo() != null )
+        mih.getTo().getAddress();
+
+      if ( to != null ) {
+         // need to parse stuff out
+         int i = to.lastIndexOf("/");
+         to = to.substring(i+1);
+         msgContext.setTargetService( to );
+      }
+
+      if ( mih.getAction() != null )
+         msgContext.setSOAPActionURI( mih.getAction() );
+        
+      // If there's a relates to then assume this is a one-way message
+      // and we should not try to send back a reply
+      if ( mih.getRelatesTo() != null && mih.getRelatesTo().size() != 0 )
+        msgContext.setIsOneWay(true);
+
+      // Setup the response MIHeader now so that people can change it
+      // if they need to w/o us overriding it
+      MIHeader resMIH = mih.generateReplyMI();
+      msgContext.setProperty(WSAConstants.RES_MIH, resMIH);
+   }
+
+   static void processServerResponse(MessageContext msgContext) throws Exception {
+      MIHeader  reqMIH, resMIH ;
+
+      Message msg = msgContext.getResponseMessage();
+      if ( msg == null ) return ;
+
+      reqMIH = (MIHeader) msgContext.getProperty(WSAConstants.REQ_MIH);
+      if ( reqMIH == null ) return ;
+
+      resMIH = (MIHeader) msgContext.getProperty(WSAConstants.RES_MIH);
+      if ( resMIH == null ) {
+        resMIH = reqMIH.generateReplyMI();
+        msgContext.setProperty(WSAConstants.RES_MIH, resMIH );
+      }
+
+      if ( resMIH.getToFault() != null ) {
+        SOAPBodyElement elem = msg.getSOAPEnvelope().getFirstBody();
+        if ( elem != null ) {
+          QName qn = elem.getQName();
+          if ( qn.equals(msgContext.getSOAPConstants().getFaultQName()) ) 
+            resMIH.setTo( resMIH.getToFault() );
+        }
+      }
+
+      resMIH.toEnvelope( msg.getSOAPEnvelope() );
+   }
+
+   // List of properties to copy from one msgcontext to another
+   private static String[]  copyProps = {
+     "SignIt",
+     "SCAnchorID",
+     "RequireSigning" };
+
+   static public void sendResponse( MessageContext msgContext ) 
+       throws Exception {
+    
+     if ( msgContext.getProperty(WSAConstants.WSA_DONT_REROUTE) != null )
+       return ;
+
+     MIHeader resMIH = null ;
+     Message  msg    = null ;
+     String   to     = null ;
+     
+     resMIH = MIHeader.fromResponse();
+     if ( resMIH == null ) return ;
+
+     if ( resMIH.getTo() != null )
+       to = resMIH.getTo().getAddress();
+
+     msg = msgContext.getResponseMessage();
+
+     if ( msg==null || to==null || to.equals(WSAConstants.Anonymous_Address) )
+       return ;
+
+     Vector   relates    = (Vector) resMIH.getRelatesTo();
+
+     for ( int i = 0 ; relates != null && i < relates.size() ; i++ ) {
+       RelatesToProperty rtp = (RelatesToProperty) relates.get(i);
+       if ( rtp.getType() == null || rtp.getType().equals("wsa:Reply") ) {
+         // process replyTo by invoking a service
+         Service service = new Service();
+         Call    call    = (Call) service.createCall();
+
+         for ( int j = 0 ; j < copyProps.length ; j++ ) {
+           Object obj = msgContext.getProperty( copyProps[j] );
+           if ( obj == null ) continue ;
+           call.setProperty( copyProps[j], obj );
+         }
+
+         call.setTargetEndpointAddress(resMIH.getTo().getAddress() );
+         call.setRequestMessage(msg);
+         call.setSOAPActionURI( msgContext.getSOAPActionURI() );
+
+         // need to set the response message to null now, not later like we
+         // used to, so that if the call.invoke() call fails Axis will create a
+         // response message for the fault.  Axis has this interesting
+         // bug/feature where if there's a fault and there's already a
+         // response message then it WILL NOT replace it with the fault.
+         msgContext.setResponseMessage( null );
+
+         call.invoke();
+       }
+     }
+   }
+
+   static public void fixAction(MessageContext msgContext) throws Exception {
+     MIHeader resMI = MIHeader.fromResponse();
+     if ( resMI != null )
+       resMI.setAction( WSAConstants.Fault_URI );
+     msgContext.setSOAPActionURI( WSAConstants.Fault_URI );
+   }
+}



RE: import *

Posted by Tom Jordahl <tj...@adobe.com>.
Get a copy of IDEA - we get licensed copied as Apache developers I
believe.

 

--

Tom Jordahl

Adobe ColdFusion Team

________________________________

From: Doug Davis [mailto:dug@us.ibm.com] 
Sent: Thursday, January 26, 2006 10:47 AM
To: axis-dev@ws.apache.org
Subject: RE: import *

 


Yup - working on that part of the clean-up.  IDE?  Ha!  Long live vi ! 
-Doug 




"Tom Jordahl" <tj...@adobe.com> 

01/26/2006 10:40 AM 

Please respond to
axis-dev

To

<du...@apache.org> 

cc

<ax...@ws.apache.org> 

Subject

RE: import *

 

 

 




+import org.apache.axis.message.* ;
+import org.apache.axis.wsa.* ;
+import org.apache.axis.security.WSSecurity;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.HandlerChain;
+import java.util.Iterator;
+import java.lang.reflect.Method ;
+import java.io.* ;
+import java.util.* ;


Dug,

Please change your IDE to avoid using import * please.  We don't do that
in Axis.


--
Tom Jordahl
Adobe ColdFusion Team




RE: import *

Posted by Doug Davis <du...@us.ibm.com>.
Yup - working on that part of the clean-up.  IDE?  Ha!  Long live vi !
-Doug




"Tom Jordahl" <tj...@adobe.com> 
01/26/2006 10:40 AM
Please respond to
axis-dev


To
<du...@apache.org>
cc
<ax...@ws.apache.org>
Subject
RE: import *






+import org.apache.axis.message.* ;
+import org.apache.axis.wsa.* ;
+import org.apache.axis.security.WSSecurity;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.HandlerChain;
+import java.util.Iterator;
+import java.lang.reflect.Method ;
+import java.io.* ;
+import java.util.* ;


Dug,

Please change your IDE to avoid using import * please.  We don't do that
in Axis.


--
Tom Jordahl
Adobe ColdFusion Team



RE: import *

Posted by Tom Jordahl <tj...@adobe.com>.
+import org.apache.axis.message.* ;
+import org.apache.axis.wsa.* ;
+import org.apache.axis.security.WSSecurity;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.handler.HandlerChain;
+import java.util.Iterator;
+import java.lang.reflect.Method ;
+import java.io.* ;
+import java.util.* ;


Dug,

Please change your IDE to avoid using import * please.  We don't do that
in Axis.


--
Tom Jordahl
Adobe ColdFusion Team