axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils WSDLUtils.java
Date Tue, 21 Aug 2001 05:15:35 GMT
gdaniels    01/08/20 22:15:35

  Modified:    java/src/org/apache/axis Handler.java SimpleChain.java
                        SimpleTargetedChain.java
               java/src/org/apache/axis/handlers BasicHandler.java
                        JWSHandler.java JWSProcessor.java
               java/src/org/apache/axis/handlers/http URLMapper.java
               java/src/org/apache/axis/providers/java JavaProvider.java
               java/src/org/apache/axis/server AxisServer.java
               java/src/org/apache/axis/transport/http AxisServlet.java
                        SimpleAxisServer.java
               java/src/org/apache/axis/utils WSDLUtils.java
  Log:
  Change for better WSDL-generation architecture.
  
  Handler now has a generateWSDL() signature, which gets delegated
  to chains just like invoke() does.  This allows arbitrary chains of
  handlers to collaborate in building up information which ends up
  expressed as WSDL.
  
  This stuff is somewhat experimental at the moment, so I labelled the
  source immediately prior to the change to make it easy to roll back
  just in case.  It does work, and also now generates WSDL inside
  the SimpleAxisServer as well.  Check it out, and please comment
  on the approach.
  
  Right now all the WSDL is getting created by the JavaProvider.
  
  Revision  Changes    Path
  1.13      +9 -0      xml-axis/java/src/org/apache/axis/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Handler.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Handler.java	2001/07/12 15:02:53	1.12
  +++ Handler.java	2001/08/21 05:15:35	1.13
  @@ -139,4 +139,13 @@
        * 'list' Admin function.
        */
       public Element getDeploymentData(Document doc);
  +
  +    /**
  +     * Obtain WSDL information.  Some Handlers will implement this by
  +     * merely setting properties in the MessageContext, others (providers)
  +     * will take responsibility for doing the "real work" of generating
  +     * WSDL for a given service.
  +     *
  +     */
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault;
   };
  
  
  
  1.19      +14 -0     xml-axis/java/src/org/apache/axis/SimpleChain.java
  
  Index: SimpleChain.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SimpleChain.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SimpleChain.java	2001/07/12 15:02:58	1.18
  +++ SimpleChain.java	2001/08/21 05:15:35	1.19
  @@ -184,4 +184,18 @@
           Debug.Print( 1, "Exit: SimpleChain::getDeploymentData" );
           return( root );
       }
  +
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  +        Debug.Print( 1, "Enter: SimpleChain::editWSDL" );
  +        try {
  +            for ( int i = 0 ; handlers!= null && i<handlers.size() ; i++ )
  +                ((Handler) handlers.elementAt( i )).generateWSDL( msgContext );
  +        } catch( Exception e ) {
  +            Debug.Print( 1, e );
  +            if( !(e instanceof AxisFault ) )
  +                e = new AxisFault( e );
  +            throw (AxisFault) e ;
  +        }
  +        Debug.Print( 1, "Exit: SimpleChain::editWSDL" );
  +    }
   };
  
  
  
  1.18      +28 -0     xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java
  
  Index: SimpleTargetedChain.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SimpleTargetedChain.java	2001/08/03 19:12:59	1.17
  +++ SimpleTargetedChain.java	2001/08/21 05:15:35	1.18
  @@ -120,6 +120,34 @@
           Debug.Print( 1, "Exit: SimpleTargetedChain::invoke" );
       }
   
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  +        Debug.Print( 1, "Enter: SimpleTargetedChain::editWSDL" );
  +        if ( requestHandler != null ) requestHandler.generateWSDL( msgContext );
  +        try {
  +            if ( pivotHandler != null ) pivotHandler.generateWSDL( msgContext );
  +        }
  +        catch( Exception e ) {
  +            Debug.Print( 1, e );
  +            if ( !(e instanceof AxisFault ) )
  +                e = new AxisFault( e );
  +            if ( requestHandler != null )
  +                requestHandler.undo( msgContext );
  +            throw (AxisFault) e ;
  +        }
  +        msgContext.setPastPivot(true);
  +        try {
  +            if ( responseHandler != null )
  +                responseHandler.generateWSDL( msgContext );
  +        }
  +        catch( Exception e ) {
  +            Debug.Print( 1, e );
  +            if ( !(e instanceof AxisFault ) )
  +                e = new AxisFault( e );
  +            throw (AxisFault) e ;
  +        }
  +        Debug.Print( 1, "Exit: SimpleTargetedChain::editWSDL" );
  +    }
  +
       /**
        * Undo all of the work - in reverse order.
        */
  
  
  
  1.9       +4 -0      xml-axis/java/src/org/apache/axis/handlers/BasicHandler.java
  
  Index: BasicHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/BasicHandler.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BasicHandler.java	2001/07/12 15:03:44	1.8
  +++ BasicHandler.java	2001/08/21 05:15:35	1.9
  @@ -164,4 +164,8 @@
           Debug.Print( 1, "Exit: BasicHandler::getDeploymentData" );
           return( root );
       }
  +
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault
  +    {
  +    }
   }
  
  
  
  1.3       +4 -0      xml-axis/java/src/org/apache/axis/handlers/JWSHandler.java
  
  Index: JWSHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JWSHandler.java	2001/06/21 02:45:43	1.2
  +++ JWSHandler.java	2001/08/21 05:15:35	1.3
  @@ -83,6 +83,10 @@
           Debug.Print( 1, "Exit : JWSHandler::invoke" );
       }
   
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  +        invoke(msgContext);
  +    }
  +
       public void undo(MessageContext msgContext)
       {
           Debug.Print( 1, "Enter: JWSHandler::undo" );
  
  
  
  1.15      +15 -8     xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
  
  Index: JWSProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JWSProcessor.java	2001/08/17 20:44:00	1.14
  +++ JWSProcessor.java	2001/08/21 05:15:35	1.15
  @@ -83,6 +83,12 @@
   
       public void invoke(MessageContext msgContext) throws AxisFault
       {
  +        invokeImpl(msgContext, false);
  +    }
  +
  +    public void invokeImpl(MessageContext msgContext, boolean doWsdl)
  +            throws AxisFault
  +    {
           Debug.Print( 1, "Enter: JWSProcessor::invoke" );
           try {
               /* Grab the *.jws filename from the context - should have been */
  @@ -132,7 +138,7 @@
                   Main              compiler = new Main( out, "javac" );
                   String            outdir   = f1.getParent();
                   String[]          args     = null ;
  -                
  +
                   if (outdir == null) outdir=".";
   
                   args = new String[] { "-d", outdir,
  @@ -178,12 +184,6 @@
                   cl.registerClass( clsName, cFile );
               msgContext.setClassLoader( cl );
   
  -            if (msgContext.getProperty("is-http-get") != null) {
  -                Class c = cl.loadClass(clsName);
  -                msgContext.setProperty("JWSClass", c);
  -                return;
  -            }
  -
               /* Create a new RPCProvider - this will be the "service"   */
               /* that we invoke.                                                */
               /******************************************************************/
  @@ -198,7 +198,10 @@
               rpc.addOption( "methodName", "*");
   
               rpc.init();   // ??
  -            rpc.invoke( msgContext );
  +            if (doWsdl)
  +                rpc.generateWSDL(msgContext);
  +            else
  +                rpc.invoke( msgContext );
               rpc.cleanup();  // ??
           }
           catch( Exception e ) {
  @@ -208,6 +211,10 @@
           }
   
           Debug.Print( 1, "Exit : JWSProcessor::invoke" );
  +    }
  +
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  +        invokeImpl(msgContext, true);
       }
   
       public void undo(MessageContext msgContext)
  
  
  
  1.4       +5 -1      xml-axis/java/src/org/apache/axis/handlers/http/URLMapper.java
  
  Index: URLMapper.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/http/URLMapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- URLMapper.java	2001/08/03 17:12:49	1.3
  +++ URLMapper.java	2001/08/21 05:15:35	1.4
  @@ -90,7 +90,11 @@
           Debug.Print( 1, "Exit : URLMapper::invoke" );
       }
   
  -    public void undo(MessageContext msgContext) 
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  +        invoke(msgContext);
  +    }
  +
  +    public void undo(MessageContext msgContext)
       {
           Debug.Print( 1, "Enter: URLMapper::undo" );
           Debug.Print( 1, "Exit: URLMapper::undo" );
  
  
  
  1.7       +58 -3     xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java
  
  Index: JavaProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JavaProvider.java	2001/07/10 22:52:58	1.6
  +++ JavaProvider.java	2001/08/21 05:15:35	1.7
  @@ -62,6 +62,7 @@
   import org.apache.axis.utils.cache.* ;
   import org.apache.axis.message.* ;
   import org.apache.axis.providers.BasicProvider;
  +import org.w3c.dom.Document;
   
   /**
    * Base class for Java dispatching.  Fetches various fields out of envelope,
  @@ -243,11 +244,65 @@
           }
           Debug.Print( 1, "Exit: JavaProvider::invoke (for provider "+this+")" );
       }
  -    
  -    
  +
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  +        Debug.Print( 1, "Enter: JavaProvider::editWSDL (for provider "+this+")" );
  +
  +        /* Find the service we're invoking so we can grab it's options */
  +        /***************************************************************/
  +        String serviceName = msgContext.getTargetService();
  +        Handler service = msgContext.getServiceHandler();
  +
  +        /* Now get the service (RPC) specific info  */
  +        /********************************************/
  +        String  clsName    = (String) service.getOption( "className" );
  +        String  methodName = (String) service.getOption( "methodName" );
  +
  +        if ((clsName == null) || clsName.equals(""))
  +          throw new AxisFault("Server.NoClassForService",
  +            "No 'className' option was configured for the service '" +
  +               serviceName + "'",
  +            null, null);
  +
  +        /** ??? Should we enforce setting methodName?  As it was,
  +         * if it's null, we allowed any method.  This seems like it might
  +         * be considered somewhat insecure (it's an easy mistake to
  +         * make).  Tossing an Exception if it's not set, and using "*"
  +         * to explicitly indicate "any method" is probably better.
  +         */
  +        if ((methodName == null) || methodName.equals(""))
  +          throw new AxisFault("Server.NoMethodConfig",
  +            "No 'methodName' option was configured for the service '" +
  +               serviceName + "'",
  +            null, null);
  +
  +        if (methodName.equals("*"))
  +          methodName = null;
  +
  +        try {
  +            /* We know we're doing a Java/RPC call so we can ask for the */
  +            /* SOAPBody as an RPCBody and process it accordingly.        */
  +            /*************************************************************/
  +            int             i ;
  +            AxisClassLoader cl     = msgContext.getClassLoader();
  +            JavaClass       jc     = cl.lookup(clsName);
  +            Class           cls    = jc.getJavaClass();
  +            String url = msgContext.getStrProp(MessageContext.TRANS_URL);
  +            String urn = (String)msgContext.getTargetService();
  +            String description = "Some service or other";
  +            Document doc = WSDLUtils.writeWSDLDoc(cls,
  +                    url, urn, description, msgContext);
  +
  +            msgContext.setProperty("WSDL", doc);
  +        } catch (Exception e) {
  +            throw new AxisFault(e);
  +        }
  +
  +    }
  +
       public void undo(MessageContext msgContext) {
           Debug.Print( 1, "Enter: RPCDispatchHandler::undo" );
           Debug.Print( 1, "Exit: RPCDispatchHandler::undo" );
       }
  -    
  +
   };
  
  
  
  1.35      +159 -10   xml-axis/java/src/org/apache/axis/server/AxisServer.java
  
  Index: AxisServer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- AxisServer.java	2001/08/15 21:30:17	1.34
  +++ AxisServer.java	2001/08/21 05:15:35	1.35
  @@ -134,7 +134,7 @@
        */
       public void invoke(MessageContext msgContext) throws AxisFault {
           Debug.Print( 1, "Enter: AxisServer::invoke" );
  -        
  +
           if (!isRunning()) {
               throw new AxisFault("Server.disabled",
                                   "This Axis server is not currently accepting requests.",
  @@ -185,12 +185,12 @@
                   /*   Global Response Handler/Chain                              */
                   /*   Transport Specific Response Handler/Chain                  */
                   /**************************************************************/
  -                
  +
                   // When do we call init/cleanup??
                   Debug.Print(1, "Calling default logic in AxisServer" );
   
                   /*  This is what the entirety of this logic might evolve to:
  -                
  +
                   hName = msgContext.getStrProp(MessageContext.TRANSPORT);
                   if ( hName != null ) {
                   if ((h = hr.find( hName )) != null ) {
  @@ -205,13 +205,13 @@
                   }
   
                   */
  -                
  +
                   /* Process the Transport Specific Request Chain */
                   /**********************************************/
                   hName = msgContext.getTransportName();
                   HandlerRegistry tr = getTransportRegistry();
                   SimpleTargetedChain transportChain = null;
  -                
  +
                   Debug.Print(3, "AxisServer.invoke: Transport = '" + hName +"'");
                   if ( hName != null && (h = tr.find( hName )) != null ) {
                       if (h instanceof SimpleTargetedChain) {
  @@ -221,13 +221,13 @@
                               h.invoke(msgContext);
                       }
                   }
  -                
  +
                   /* Process the Global Request Chain */
                   /**********************************/
                   hName = Constants.GLOBAL_REQUEST ;
                   if ( hName != null  && (h = hr.find( hName )) != null )
                       h.invoke(msgContext);
  -                
  +
                   /**
                   * At this point, the service should have been set by someone
                   * (either the originator of the MessageContext, or one of the
  @@ -252,13 +252,13 @@
                   }
   
                   h.invoke(msgContext);
  -                
  +
                   /* Process the Global Response Chain */
                   /***********************************/
                   hName = Constants.GLOBAL_RECEIVE ;
                   if ( hName != null && (h = hr.find( hName )) != null )
                       h.invoke(msgContext);
  -                
  +
                   /* Process the Transport Specific Response Chain */
                   /***********************************************/
                   if (transportChain != null) {
  @@ -274,7 +274,156 @@
               throw (AxisFault) e ;
           }
           Debug.Print( 1, "Exit: AxisServer::invoke" );
  -    };
  +    }
  +
  +    /**
  +     *
  +     */
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault {
  +        Debug.Print( 1, "Enter: AxisServer::editWSDL" );
  +
  +        if (!isRunning()) {
  +            throw new AxisFault("Server.disabled",
  +                                "This Axis server is not currently accepting requests.",
  +                                null, null);
  +        }
  +
  +        String  hName = null ;
  +        Handler h     = null ;
  +
  +        /* Do some prep-work.  Get the registries and put them in the */
  +        /* msgContext so they can be used by later handlers.          */
  +        /**************************************************************/
  +        HandlerRegistry hr = getHandlerRegistry();
  +        HandlerRegistry sr = getServiceRegistry();
  +
  +        try {
  +            hName = msgContext.getStrProp( MessageContext.ENGINE_HANDLER );
  +            if ( hName != null ) {
  +                if ( hr == null || (h = hr.find(hName)) == null ) {
  +                    AxisClassLoader cl = msgContext.getClassLoader();
  +                    try {
  +                        Debug.Print( 2, "Trying to load class: " + hName );
  +                        Class cls = cl.loadClass( hName );
  +                        h = (Handler) cls.newInstance();
  +                    }
  +                    catch( Exception e ) {
  +                        h = null ;
  +                    }
  +                }
  +                if ( h != null )
  +                    h.generateWSDL(msgContext);
  +                else
  +                    throw new AxisFault( "Server.error",
  +                        "Can't locate handler: " + 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:         */
  +                /*   Transport Specific Request Handler/Chain                   */
  +                /*   Global Request Handler/Chain                               */
  +                /*   Protocol Specific-Handler(ie. SOAP, XP)                  */
  +                /*     ie. For SOAP Handler:                                  */
  +                /*           - Service Specific Request Handler/Chain           */
  +                /*           - SOAP Semantic Checks                           */
  +                /*           - Service Specific Response Handler/Chain          */
  +                /*   Global Response Handler/Chain                              */
  +                /*   Transport Specific Response Handler/Chain                  */
  +                /**************************************************************/
  +
  +                // When do we call init/cleanup??
  +                Debug.Print(1, "Calling default logic in AxisServer" );
  +
  +                /*  This is what the entirety of this logic might evolve to:
  +
  +                hName = msgContext.getStrProp(MessageContext.TRANSPORT);
  +                if ( hName != null ) {
  +                if ((h = hr.find( hName )) != null ) {
  +                h.editWSDL(msgContext);
  +                } else {
  +                System.err.println("Couldn't find transport " + hName);
  +                }
  +                } else {
  +                // No transport set, so use the default (probably just
  +                // calls the global->service handlers)
  +                defaultTransport.editWSDL(msgContext);
  +                }
  +
  +                */
  +
  +                /* Process the Transport Specific Request Chain */
  +                /**********************************************/
  +                hName = msgContext.getTransportName();
  +                HandlerRegistry tr = getTransportRegistry();
  +                SimpleTargetedChain transportChain = null;
  +
  +                Debug.Print(3, "AxisServer.editWSDL: Transport = '" + hName +"'");
  +                if ( hName != null && (h = tr.find( hName )) != null ) {
  +                    if (h instanceof SimpleTargetedChain) {
  +                        transportChain = (SimpleTargetedChain)h;
  +                        h = transportChain.getRequestHandler();
  +                        if (h != null)
  +                            h.generateWSDL(msgContext);
  +                    }
  +                }
  +
  +                /* Process the Global Request Chain */
  +                /**********************************/
  +                hName = Constants.GLOBAL_REQUEST ;
  +                if ( hName != null  && (h = hr.find( hName )) != null )
  +                    h.generateWSDL(msgContext);
  +
  +                /**
  +                * At this point, the service should have been set by someone
  +                * (either the originator of the MessageContext, or one of the
  +                * transport or global Handlers).  If it hasn't been set, we
  +                * fault.
  +                */
  +                h = msgContext.getServiceHandler();
  +                if (h == null) {
  +                    // It's possible that we haven't yet parsed the
  +                    // message at this point.  This is a kludge to
  +                    // make sure we have.  There probably wants to be
  +                    // some kind of declarative "parse point" on the handler
  +                    // chain instead....
  +                    Message rm = msgContext.getRequestMessage();
  +                    if (rm != null) {
  +                        rm.getAsSOAPEnvelope().getFirstBody();
  +                        h = msgContext.getServiceHandler();
  +                    }
  +                    if (h == null)
  +                        throw new AxisFault("Server.NoService",
  +                            "The Axis engine couldn't find a " +
  +                            "target service to generate WSDL for! targetService is "+msgContext.getTargetService(),
  +                            null, null );
  +                }
  +
  +                h.generateWSDL(msgContext);
  +
  +                /* Process the Global Response Chain */
  +                /***********************************/
  +                hName = Constants.GLOBAL_RECEIVE ;
  +                if ( hName != null && (h = hr.find( hName )) != null )
  +                    h.generateWSDL(msgContext);
  +
  +                /* Process the Transport Specific Response Chain */
  +                /***********************************************/
  +                if (transportChain != null) {
  +                    h = transportChain.getResponseHandler();
  +                    if (h != null)
  +                        h.generateWSDL(msgContext);
  +                }
  +            }
  +        }
  +        catch( Exception e ) {
  +            // Should we even bother catching it ?
  +            if ( !(e instanceof AxisFault) ) e = new AxisFault( e );
  +            throw (AxisFault) e ;
  +        }
  +        Debug.Print( 1, "Exit: AxisServer::editWSDL" );
  +    }
   
       public void undo(MessageContext msgContext) {
           Debug.Print( 1, "Enter: AxisServer::undo" );
  
  
  
  1.37      +22 -41    xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
  
  Index: AxisServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- AxisServlet.java	2001/08/19 22:50:12	1.36
  +++ AxisServlet.java	2001/08/21 05:15:35	1.37
  @@ -96,53 +96,34 @@
           HandlerRegistry hr = engine.getHandlerRegistry();
   
           String realpath = context.getRealPath(req.getServletPath());
  -        if (realpath != null) 
  +        if (realpath != null) {
               msgContext.setProperty(Constants.MC_REALPATH, realpath);
           
  -        if ((realpath!=null) && (realpath.endsWith(".jws"))) {
               try {
  -                // !!! Kludge for right now to allow the JWSProcessor to
  -                //     get the class without actually invoking it.
  -                msgContext.setProperty("is-http-get", "yes");
  -        
  -                Handler handler = hr.find("JWSProcessor");
  -                if (handler != null) {
  -                    handler.invoke(msgContext);
  -                    Handler serviceHandler = msgContext.getServiceHandler();
  -                    if (serviceHandler != null) {
  -                        res.getWriter().println("Got service " +
  -                                                serviceHandler);
  -                    }
  -                    Class cls = (Class)msgContext.getProperty("JWSClass");
  -                    
  -                    // !!! Need to make this an absolute URI
  -                    String url = req.getScheme() + "://" +
  -                                 req.getServerName() + ":" +
  -                                 req.getServerPort() + req.getRequestURI();
  -                    
  -                    // !!! This should be something reasonable
  -                    String urn = "urn:service";
  -                    
  -                    // !!! This should come from the service itself
  -                    String description = "Some service";
  -                    
  -                    if (req.getParameter("WSDL") != null) {
  +                String url = req.getScheme() + "://" +
  +                        req.getServerName() + ":" +
  +                        req.getServerPort() + req.getRequestURI();
  +
  +                msgContext.setProperty(MessageContext.TRANS_URL, url);
  +
  +                if (req.getParameter("WSDL") != null) {
  +                    engine.generateWSDL(msgContext);
  +                    Document doc = (Document) msgContext.getProperty("WSDL");
  +                    if (doc != null) {
                           res.setContentType("text/xml");
  -                        WSDLUtils.writeWSDLDoc(cls, url, urn, description,
  -                                          msgContext.getTypeMappingRegistry(),
  -                                          res.getWriter());
  -                        return;
  -                    } else {
  -                        res.setContentType("text/html");
  -                        res.getWriter().println("<h1>" + cls.getName() +
  -                                                "</h1>");
  -                        res.getWriter().println(
  -                               "<p>Hi there, this is an Axis service!</p>");
  -                        res.getWriter().println(
  -       "<i>Perhaps there'll be a form for invoking the service here...</i>");
  +                        XMLUtils.DocumentToWriter(doc, res.getWriter());
                           res.getWriter().close();
  -                        return;
                       }
  +                } else {
  +                    res.setContentType("text/html");
  +                    res.getWriter().println("<h1>" + req.getRequestURI() +
  +                            "</h1>");
  +                    res.getWriter().println(
  +                            "<p>Hi there, this is an Axis service!</p>");
  +                    res.getWriter().println(
  +                            "<i>Perhaps there'll be a form for invoking the service
here...</i>");
  +                    res.getWriter().close();
  +                    return;
                   }
               } catch (AxisFault fault) {
                   res.getWriter().println("<pre>Fault - " + fault + " </pre>");
  
  
  
  1.23      +55 -20    xml-axis/java/src/org/apache/axis/transport/http/SimpleAxisServer.java
  
  Index: SimpleAxisServer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/SimpleAxisServer.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- SimpleAxisServer.java	2001/08/15 21:30:17	1.22
  +++ SimpleAxisServer.java	2001/08/21 05:15:35	1.23
  @@ -67,6 +67,8 @@
   import org.apache.axis.session.Session;
   import org.apache.axis.session.SimpleSession;
   
  +import org.w3c.dom.Document;
  +
   /**
    * This is a single threaded implementation of an HTTP server for processing
    * SOAP requests via Apache's xml-axis.  This is not intended for production
  @@ -210,19 +212,43 @@
                           fileName, cookie, cookie2);
                       is.setContentLength(contentLength);
   
  +                    msgContext.setProperty(Constants.MC_REALPATH,
  +                                           fileName.toString());
  +
  +                    // !!! Fix string concatenation
  +                    String url = "http://localhost:" +
  +                            this.getServerSocket().getLocalPort() + "/" +
  +                            fileName.toString();
  +                    msgContext.setProperty(MessageContext.TRANS_URL, url);
  +
                       // if get, then return simpleton document as response
                       if (httpRequest.toString().equals("GET")) {
  +                        engine.generateWSDL(msgContext);
  +
  +                        Document doc = (Document)msgContext.getProperty("WSDL");
  +
                           OutputStream out = socket.getOutputStream();
                           out.write(HTTP);
                           out.write(status);
                           out.write(MIME_STUFF);
  -                        putInt(out, cannedResponse.length);
  -                        out.write(SEPARATOR);
  -                        out.write(cannedResponse);
  +
  +                        if (doc != null) {
  +                            String response = XMLUtils.DocumentToString(doc);
  +                            byte [] respBytes = response.getBytes();
  +
  +                            putInt(out, respBytes.length);
  +                            out.write(SEPARATOR);
  +                            out.write(respBytes);
  +                        } else {
  +                            putInt(out, cannedResponse.length);
  +                            out.write(SEPARATOR);
  +                            out.write(cannedResponse);
  +                        }
  +
                           out.flush();
                           continue;
                       }
  -                        
  +
                       // this may be "" if either SOAPAction: "" or if no SOAPAction at all.
                       // for now, do not complain if no SOAPAction at all
                       String soapActionString = soapAction.toString();
  @@ -230,9 +256,7 @@
                                              soapActionString);
                       requestMsg = new Message(is);
                       msgContext.setRequestMessage(requestMsg);
  -                    msgContext.setProperty(Constants.MC_REALPATH,
  -                                           fileName.toString());
  -                    
  +
                       // set up session, if any
                       if (doSessions) {
                           // did we get a cookie?
  @@ -241,7 +265,7 @@
                           } else if (cookie2.length() > 0) {
                               cooky = cookie2.toString().trim();
                           }
  -                        
  +
                           // if cooky is null, cook up a cooky
                           if (cooky == null) {
                               // fake one up!
  @@ -250,7 +274,7 @@
                               int i = sessionIndex++;
                               cooky = "" + i;
                           }
  -                            
  +
                           // is there a session already?
                           Session session = null;
                           if (sessions.containsKey(cooky)) {
  @@ -258,11 +282,11 @@
                           } else {
                               // no session for this cooky, bummer
                               session = new SimpleSession();
  -                            
  +
                               // ADD CLEANUP LOGIC HERE if needed
                               sessions.put(cooky, session);
                           }
  -                        
  +
                           msgContext.setSession(session);
                       }
   
  @@ -294,7 +318,7 @@
                   out.write(status);
                   out.write(MIME_STUFF);
                   putInt(out, response.length);
  -                
  +
                   if (doSessions) {
                       // write cookie headers, if any
                       // don't sweat efficiency *too* badly
  @@ -307,11 +331,11 @@
                       // OH, THE HUMANITY!  yes this is inefficient.
                       out.write(cookieOut.toString().getBytes());
                   }
  -                
  +
                   out.write(SEPARATOR);
                   out.write(response);
                   out.flush();
  -            
  +
                   if (msgContext.getProperty(msgContext.QUIT_REQUESTED) != null) {
                       // why then, quit!
                       this.stop();
  @@ -338,7 +362,7 @@
           for (int i = 0; i < 256; i++) {
               toLower[i] = (byte)i;
           }
  -    
  +
           for (int lc = 'a'; lc <= 'z'; lc++) {
               toLower[lc + 'A' - 'a']=(byte)lc;
           }
  @@ -351,21 +375,21 @@
       // mime header for soap action
       private static final byte actionHeader[] = "soapaction: ".getBytes();
       private static final int actionLen = actionHeader.length;
  -    
  +
       // mime header for cookie
       private static final byte cookieHeader[] = "cookie: ".getBytes();
       private static final int cookieLen = cookieHeader.length;
  -    
  +
       // mime header for cookie2
       private static final byte cookie2Header[] = "cookie2: ".getBytes();
       private static final int cookie2Len = cookie2Header.length;
  -    
  +
       // mime header for GET
       private static final byte getHeader[] = "GET".getBytes();
   
       // mime header for POST
       private static final byte postHeader[] = "POST".getBytes();
  -    
  +
       // header ender
       private static final byte headerEnder[] = ": ".getBytes();
   
  @@ -427,7 +451,18 @@
           
           if (buf[0] == getHeader[0]) {
               httpRequest.append("GET");
  -            // return immediately, don't look for more headers
  +            for (int i = 0; i < n - 5; i++) {
  +                char c = (char)(buf[i + 5] & 0x7f);
  +                if (c == ' ')
  +                    break;
  +                if (c == '?') {
  +                    // !!! eventually process args, for now always assume
  +                    // WSDL....
  +                    break;
  +                }
  +                fileName.append(c);
  +            }
  +            Debug.Print(2, "SimpleAxisServer: req filename='" + fileName.toString() + "'");
               return 0;
           } else if (buf[0] == postHeader[0]) {
               httpRequest.append("POST");
  
  
  
  1.3       +25 -20    xml-axis/java/src/org/apache/axis/utils/WSDLUtils.java
  
  Index: WSDLUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/WSDLUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSDLUtils.java	2001/08/19 22:50:12	1.2
  +++ WSDLUtils.java	2001/08/21 05:15:35	1.3
  @@ -62,6 +62,7 @@
   import javax.wsdl.*;
   import javax.wsdl.factory.DefinitionFactory;
   import org.apache.axis.Constants;
  +import org.apache.axis.MessageContext;
   import org.apache.axis.encoding.TypeMappingRegistry;
   import org.w3c.dom.*;
   import com.ibm.wsdl.extensions.soap.*;
  @@ -74,17 +75,13 @@
    * @author Glen Daniels (gdaniels@macromedia.com)
    */
   public class WSDLUtils {
  -    public static TypeMappingRegistry reg;
  -    
  -    public static void writeWSDLDoc(Class cls,
  +    public static Document writeWSDLDoc(Class cls,
                                       String url, 
                                       String urn, 
                                       String description,
  -                                    TypeMappingRegistry typeMap,
  -                                    Writer writer) throws Exception
  +                                    MessageContext msgContext) throws Exception
       {
  -        reg = typeMap;
  -        
  +        TypeMappingRegistry reg = msgContext.getTypeMappingRegistry();
           String name = cls.getName();
           
           DefinitionFactory factory = DefinitionFactory.newInstance("com.ibm.wsdl.factory.DefinitionFactoryImpl");
  @@ -117,13 +114,13 @@
               
               Input input = def.createInput();
               
  -            msg = getRequestMessage(def, methods[i]);
  +            msg = getRequestMessage(def, methods[i], reg);
               input.setMessage(msg);
               oper.setInput(input);
               
               def.addMessage(msg);
               
  -            msg = getResponseMessage(def, methods[i]);
  +            msg = getResponseMessage(def, methods[i], reg);
               Output output = def.createOutput();
               output.setMessage(msg);
               oper.setOutput(output);
  @@ -181,11 +178,13 @@
           port.addExtensibilityElement(addr);
           
           service.addPort(port);
  -        
  -        com.ibm.wsdl.xml.WSDLWriter.writeWSDL(def, writer);
  +
  +        return com.ibm.wsdl.xml.WSDLWriter.getDocument(def);
       }
   
  -    public static Message getRequestMessage(Definition def, Method method)
  +    public static Message getRequestMessage(Definition def,
  +                                            Method method,
  +                                            TypeMappingRegistry reg)
       {
           Message msg = def.createMessage();
           
  @@ -196,13 +195,15 @@
           
           Class[] parameters = method.getParameterTypes();
           for(int i = 0, j = parameters.length; i < j; i++) {
  -            addPartToMessage(def, msg, "arg" + i, parameters[i]);
  +            addPartToMessage(def, msg, "arg" + i, parameters[i], reg);
           }
           
           return msg;
       }
       
  -    public static Message getResponseMessage(Definition def, Method method)
  +    public static Message getResponseMessage(Definition def,
  +                                             Method method,
  +                                             TypeMappingRegistry reg)
       {
           Message msg = def.createMessage();
           
  @@ -212,14 +213,18 @@
           msg.setUndefined(false);
           
           Class type = method.getReturnType();
  -        addPartToMessage(def, msg, "result", type);
  +        addPartToMessage(def, msg, "result", type, reg);
           
           return msg;
       }
       
       public static int n = 1;
  -    
  -    public static void addPartToMessage(Definition def, Message msg, String name, Class
param)
  +
  +    public static void addPartToMessage(Definition def,
  +                                        Message msg,
  +                                        String name,
  +                                        Class param,
  +                                        TypeMappingRegistry reg)
       {
           Part part = def.createPart();
           org.apache.axis.utils.QName qName = reg.getTypeQName(param);
  @@ -227,13 +232,13 @@
           if (pref == null) {
               def.addNamespace("ns" + n++, qName.getNamespaceURI());
           }
  -        
  +
           javax.wsdl.QName typeQName = new javax.wsdl.QName(qName.getNamespaceURI(),
                                                             qName.getLocalPart());
  -        
  +
           part.setTypeName(typeQName);
           part.setName(name);
  -        
  +
           msg.addPart(part);
       }
   }
  
  
  

Mime
View raw message