axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/message RPCArg.java SOAPBody.java SOAPEnvelope.java
Date Thu, 15 Mar 2001 01:53:34 GMT
dug         01/03/14 17:53:34

  Modified:    java/src/org/apache/axis/client HTTPCall.java
                        HTTPMessage.java
               java/src/org/apache/axis/handlers JWSProcessor.java
                        MsgDispatchHandler.java RPCDispatchHandler.java
                        SOAPServerHandler.java
               java/src/org/apache/axis/message RPCArg.java SOAPBody.java
                        SOAPEnvelope.java
  Log:
  Add support for encoding style on the soap env.
  make jws processor call javac thru java not thru cmd line
  
  Revision  Changes    Path
  1.15      +19 -4     xml-axis/java/src/org/apache/axis/client/HTTPCall.java
  
  Index: HTTPCall.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/HTTPCall.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- HTTPCall.java	2001/03/13 06:46:18	1.14
  +++ HTTPCall.java	2001/03/15 01:53:32	1.15
  @@ -82,6 +82,7 @@
     private String  action ;
     private String  userID ;
     private String  passwd ;
  +  private String  encodingStyleURI ;
   
     // For testing
     public  boolean doLocal = false ;
  @@ -122,6 +123,14 @@
       return( passwd );
     }
   
  +  public void setEncodingStyleURI( String uri ) {
  +    encodingStyleURI = uri ;
  +  }
  +
  +  public String getEncodingStyleURI() {
  +    return( encodingStyleURI );
  +  }
  +
     public static Object invoke(String url, String act, String m, Object[] args) 
         throws AxisFault
     {
  @@ -132,9 +141,13 @@
     }
   
     public Object invoke( String method, Object[] args ) throws AxisFault {
  +    RPCBody  body  = new RPCBody( method, args );
  +    return( invoke( body ) );
  +  }
  +
  +  public Object invoke( RPCBody body ) throws AxisFault {
       // quote = HTTPCall.invoke( "getQuote", Object[] { "IBM" } );
       Debug.Print( 1, "Enter: HTTPCall.invoke" );
  -    RPCBody              body   = new RPCBody( method, args );
       SOAPEnvelope         reqEnv = new SOAPEnvelope();
       SOAPEnvelope         resEnv = null ;
       HTTPMessage          hMsg   = new HTTPMessage( url, action );
  @@ -148,12 +161,14 @@
   
       hMsg.setUserID( userID );
       hMsg.setPassword( passwd );
  +    if ( encodingStyleURI != null ) 
  +      reqEnv.setEncodingStyleURI( encodingStyleURI );
   
       // for testing - skip HTTP layer
       hMsg.doLocal = this.doLocal ;
   
  -    body.setPrefix( "m" );
  -    body.setNamespaceURI( action );
  +    if ( body.getPrefix() == null )       body.setPrefix( "m" );
  +    if ( body.getNamespaceURI() == null ) body.setNamespaceURI( action );
       reqEnv.addBody( body.getAsSOAPBody() );
   
       try {
  @@ -169,7 +184,7 @@
       Document doc = (Document) resMsg.getAs("Document");
       body = new RPCBody( doc.getRootElement() );
       resArgs = body.getArgs();
  -    if ( args != null && resArgs.size() > 0 )
  +    if ( resArgs != null && resArgs.size() > 0 )
         result = (String) ((RPCArg) resArgs.get(0)).getValue() ;
       Debug.Print( 1, "Exit: HTTPCall.invoke" );
       return( result );
  
  
  
  1.19      +16 -5     xml-axis/java/src/org/apache/axis/client/HTTPMessage.java
  
  Index: HTTPMessage.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/HTTPMessage.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- HTTPMessage.java	2001/03/08 13:44:04	1.18
  +++ HTTPMessage.java	2001/03/15 01:53:32	1.19
  @@ -80,10 +80,11 @@
   // Only supports String
   
   public class HTTPMessage {
  -  private String  url    = null ;
  -  private String  action = null ;
  -  private String  userID = null ;
  -  private String  passwd = null ;
  +  private String  url              = null ;
  +  private String  action           = null ;
  +  private String  userID           = null ;
  +  private String  passwd           = null ;
  +  private String  encodingStyleURI = null ;
   
     // For testing
     public boolean doLocal = false ;
  @@ -124,6 +125,14 @@
       return( passwd );
     }
   
  +  public void setEncodingStyleURI( String uri ) {
  +    encodingStyleURI = uri ;
  +  }
  +
  +  public String getEncodingStyleURI() {
  +    return( encodingStyleURI );
  +  }
  +
     public static void invoke(String url, String act, MessageContext mc ) 
         throws AxisFault
     {
  @@ -143,6 +152,8 @@
         reqEnv = (SOAPEnvelope) inMsg.getAs("SOAPEnvelope");
       else {
         reqEnv = new SOAPEnvelope();
  +      if ( encodingStyleURI != null )
  +        reqEnv.setEncodingStyleURI( encodingStyleURI );
         SOAPBody  body = new SOAPBody( (Document) inMsg.getAs("Document") );
         reqEnv.addBody( body );
       }
  @@ -187,7 +198,7 @@
         msgContext.setProperty(MessageContext.TRANS_OUTPUT, "HTTP.output" );
       }
   
  -    if ( true ) { // Debug.getDebugLevel() > 0  ) {
  +    if ( false ) { // Debug.getDebugLevel() > 0  ) {
         SOAPHeader  header = new SOAPHeader();
         header.setPrefix("d");
         header.setName("Debug");
  
  
  
  1.3       +36 -15    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JWSProcessor.java	2001/02/20 22:51:29	1.2
  +++ JWSProcessor.java	2001/03/15 01:53:32	1.3
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -9,7 +9,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *  notice, this list of conditions and the following disclaimer. 
  + *  notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *  notice, this list of conditions and the following disclaimer in
  @@ -17,7 +17,7 @@
    *  distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *  if any, must include the following acknowledgment:  
  + *  if any, must include the following acknowledgment:
    *     "This product includes software developed by the
    *    Apache Software Foundation (http://www.apache.org/)."
    *  Alternately, this acknowledgment may appear in the software itself,
  @@ -25,7 +25,7 @@
    *
    * 4. The names "Axis" and "Apache Software Foundation" must
    *  not be used to endorse or promote products derived from this
  - *  software without prior written permission. For written 
  + *  software without prior written permission. For written
    *  permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -59,8 +59,10 @@
   import org.apache.axis.* ;
   import org.apache.axis.utils.Debug ;
   import org.apache.axis.utils.AxisClassLoader ;
  +import sun.tools.javac.Main;
  +import org.jdom.* ;
   
  -/** 
  +/**
    * This handler will use the JWSFileName property of the MsgContext to
    * locate a *.jws (JavaWebService) file.  If found it will copy it to a
    * *.java file, compile it and then run it using the RPCDispatchHandler.
  @@ -68,11 +70,13 @@
    * Todo:
    *   support msg instead of just rpc
    *   allow configurable handler (not just RPCDispatchHandler)
  - * 
  + *
    * @author Doug Davis (dug@us.ibm.com)
    */
   public class JWSProcessor extends BasicHandler
   {
  +  static String errFile = "jws.err" ;
  +
     public void invoke(MessageContext msgContext) throws AxisFault
     {
       Debug.Print( 1, "Enter: JWSProcessor::invoke" );
  @@ -87,10 +91,10 @@
         String   cFile   = jwsFile.substring(0, jwsFile.length()-3) + "class" ;
         Debug.Print( 2, "jFile: " + jFile );
         Debug.Print( 2, "cFile: " + cFile );
  -  
  +
         File  f1 = new File( cFile );
         File  f2 = new File( jwsFile );
  -  
  +
         /* Check to see if we need to recompile */
         /****************************************/
         if ( !f1.exists() || f2.lastModified() > f1.lastModified() ) {
  @@ -111,24 +115,41 @@
           /* Now run javac on the *.java file */
           /************************************/
           Debug.Print(2, "javac " + jFile );
  -        Process proc = rt.exec( "javac " + jFile );
  -        proc.waitFor();
  +        // Process proc = rt.exec( "javac " + jFile );
  +        // proc.waitFor();
  +        FileOutputStream  out      = new FileOutputStream( errFile );
  +        Main              compiler = new Main( out, "javac" );
  +        String            outdir   = f1.getParent();
  +        String[]          args     = new String[] { "-d", outdir, jFile };
  +        boolean           result   = compiler.compile( args );
   
           /* Delete the temporary *.java file and check the return code */
           /**************************************************************/
           (new File(jFile)).delete();
   
  -        if ( proc.exitValue() != 0 ) {
  +        // if ( proc.exitValue() != 0 ) {
  +        if ( !result ) {
             /* Delete the *class file - sometimes it gets created even */
             /* when there are errors - so erase it so it doesn't       */
             /* confuse us.                                             */
             /***********************************************************/
             (new File(cFile)).delete();
  +          Element         root = new Element( "Errors" );
  +          StringBuffer    sbuf = new StringBuffer();
  +          FileReader      inp  = new FileReader( errFile );
  +
  +          buf = new char[4096];
  +
  +          while ( (rc = inp.read(buf, 0, 4096)) > 0 )
  +             sbuf.append( buf, 0, rc );
  +          inp.close();
  +          root.addContent( sbuf.toString() );
  +          (new File(errFile)).delete();
             throw new AxisFault( "Server.compileError",
  -                               "Error while compiling: " + jFile + 
  -                               " rc=" + proc.exitValue(),
  -                               null, null );
  +                               "Error while compiling: " + jFile,
  +                               null, new Element[] { root } );
           }
  +        (new File(errFile)).delete();
         }
   
         /* Load the class */
  @@ -142,7 +163,7 @@
         /* Create a new RPCDispatchHandler - this will be the "service"   */
         /* that we invoke.                                                */
         /******************************************************************/
  -      RPCDispatchHandler rpc = new RPCDispatchHandler();
  +      Handler rpc = new RPCDispatchHandler();
         msgContext.setProperty( MessageContext.SVC_HANDLER, rpc );
   
         rpc.addOption( "className", clsName );
  
  
  
  1.11      +13 -2     xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java
  
  Index: MsgDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MsgDispatchHandler.java	2001/03/09 19:25:25	1.10
  +++ MsgDispatchHandler.java	2001/03/15 01:53:32	1.11
  @@ -105,6 +105,15 @@
                                 (SOAPEnvelope)resMsg.getAs("SOAPEnvelope");
   
         Document      doc     = new Document( reqBody.getAsXML() );
  +
  +      /* If no methodName was specified during deployment then get it */
  +      /* from the root of the Body element                            */
  +      /* Hmmm, should we do this????                                  */
  +      /****************************************************************/
  +      if ( methodName == null || methodName.equals("") ) {
  +        Element root = doc.getRootElement();
  +        if ( root != null ) methodName = root.getName();
  +      }
     
         argClasses[0] = cl.loadClass("org.apache.axis.MessageContext");
         argClasses[1] = cl.loadClass("org.jdom.Document");
  @@ -115,8 +124,10 @@
   
         Document retDoc = (Document) method.invoke( obj, argObjects );
     
  -      SOAPBody      resBody = new SOAPBody( retDoc );
  -      resEnv.addBody(resBody);
  +      if ( retDoc != null ) {
  +        SOAPBody resBody = new SOAPBody( retDoc );
  +        resEnv.addBody(resBody);
  +      }
         
         if (resMsg == null) {
           resMsg = new Message(resEnv, "SOAPEnvelope");
  
  
  
  1.21      +1 -1      xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java
  
  Index: RPCDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- RPCDispatchHandler.java	2001/03/13 06:46:19	1.20
  +++ RPCDispatchHandler.java	2001/03/15 01:53:33	1.21
  @@ -111,11 +111,11 @@
                                    "Service name=" + methodName,
                                  null, null );  // Should they??
     
  -        Debug.Print( 2, "There are " + args.size() + " arg(s)" );
           Class[]  argClasses = null ;
           Object[] argValues  =  null ;
   
           if ( args != null && args.size() > 0 ) {
  +          Debug.Print( 2, "There are " + args.size() + " arg(s)" );
             argClasses = new Class[ args.size() ];
             argValues = new Object[ args.size()];
             for ( i = 0 ; i < args.size() ; i++ ) {
  
  
  
  1.2       +12 -3     xml-axis/java/src/org/apache/axis/handlers/SOAPServerHandler.java
  
  Index: SOAPServerHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/SOAPServerHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SOAPServerHandler.java	2001/03/08 01:15:19	1.1
  +++ SOAPServerHandler.java	2001/03/15 01:53:33	1.2
  @@ -100,6 +100,7 @@
           msgContext.setProperty( MessageContext.SVC_HANDLER, service );
           
           if ( service instanceof SimpleTargetedChain ) {
  +          Debug.Print( 2, "Invoking input chain" );
             stc = (SimpleTargetedChain) service ;
             h = stc.getInputChain() ;
             if ( h != null ) h.invoke(msgContext);
  @@ -109,12 +110,20 @@
   
           if ( stc != null ) {
             h = stc.getPivotHandler();
  -          if ( h != null ) h.invoke(msgContext);
  +          if ( h != null ) {
  +            Debug.Print( 2, "Invoking service/pivot" );
  +            h.invoke(msgContext);
  +          }
             h = stc.getOutputChain();
  -          if ( h != null ) h.invoke(msgContext);
  +          if ( h != null ) {
  +            Debug.Print( 2, "Invoking output chain" );
  +            h.invoke(msgContext);
  +          }
           }
  -        else
  +        else {
  +          Debug.Print( 2, "Invoking service" );
             service.invoke(msgContext);
  +        }
   
           Debug.Print( 1, "Exit : SOAPServerHandler::invoke" );
       }
  
  
  
  1.9       +22 -0     xml-axis/java/src/org/apache/axis/message/RPCArg.java
  
  Index: RPCArg.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCArg.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RPCArg.java	2001/03/02 20:03:54	1.8
  +++ RPCArg.java	2001/03/15 01:53:33	1.9
  @@ -60,6 +60,9 @@
   import java.util.* ;
   import org.jdom.* ;
   
  +import org.apache.axis.utils.AxisClassLoader ;
  +import org.apache.axis.utils.Debug ;
  +
   /**
    *
    * @author Doug Davis (dug@us.ibm.com)
  @@ -69,6 +72,7 @@
     protected String   namespaceURI ;
     protected String   name ;
     protected String   value ;         // only support String for now
  +  protected String   type ;
   
     public RPCArg() {} 
   
  @@ -100,6 +104,24 @@
   
     public String getValue() { return( value ); }
     public void   setValue(String val) { value = val ; }
  +
  +  public String getTypeAsString() { 
  +    if ( type == null ) type = "java.lang.String" ;
  +    return( type );
  +  }
  +  public Class  getTypeAsClass() { 
  +    if ( type == null ) type = "java.lang.String" ;
  +    AxisClassLoader cl     = new AxisClassLoader();
  +    Class           cls    = null ;
  +    try {
  +      cl.loadClass(type);
  +    }
  +    catch( Exception e ) {
  +      Debug.Print(0, e);
  +    }
  +    return( cls );
  +  }
  +  public void   setType(String str) { type = str ; }
   
     public Element getAsXML() {
       Element   root ;
  
  
  
  1.11      +4 -1      xml-axis/java/src/org/apache/axis/message/SOAPBody.java
  
  Index: SOAPBody.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPBody.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SOAPBody.java	2001/03/03 01:07:05	1.10
  +++ SOAPBody.java	2001/03/15 01:53:33	1.11
  @@ -73,7 +73,10 @@
     }
   
     public SOAPBody(Document doc) {
  -    root = doc.getRootElement() ;
  +    if ( doc != null )
  +      root = doc.getRootElement() ;
  +    else
  +      root = null ;
     }
   
     public SOAPBody(Element elem) {
  
  
  
  1.13      +29 -7     xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
  
  Index: SOAPEnvelope.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SOAPEnvelope.java	2001/03/03 01:07:05	1.12
  +++ SOAPEnvelope.java	2001/03/15 01:53:33	1.13
  @@ -69,12 +69,22 @@
    */
   public class SOAPEnvelope {
     protected String       prefix ;
  +  protected String       namespaceURI ;
  +  protected String       encodingStyleURI ;
     protected Vector       headers ;
     protected Vector       body ; // Vector of SOAPBody's
   
     public SOAPEnvelope() {
     }
   
  +  public void setEncodingStyleURI( String uri ) {
  +    encodingStyleURI = uri ;
  +  }
  +
  +  public String getEncodingStyleURI() {
  +    return( encodingStyleURI );
  +  }
  +
     public SOAPEnvelope(Document doc) {
       setEnvelope( doc.getRootElement() );
     }
  @@ -95,6 +105,10 @@
         return ;
       }
   
  +    prefix = elem.getNamespacePrefix();
  +    namespaceURI = elem.getNamespace().getURI();
  +    encodingStyleURI = elem.getAttributeValue( Constants.ATTR_ENCODING_STYLE );
  +
       e = elem.getChild( Constants.ELEM_HEADER, elem.getNamespace() );
       if ( e != null ) {
         list = e.getChildren();
  @@ -145,6 +159,10 @@
       headers.add( header );
     }
   
  +  public int getNumBodies() {
  +    return( body == null ? 0 : body.size() );
  +  }
  +
     /**
      * Returns a vector of SOAPBody's - could be more than one
      */
  @@ -167,7 +185,6 @@
      */
     public Vector  getAsRPCBody() {
       if ( body == null ) return( null );
  -    SOAPBody b = (SOAPBody) body.get(0);
       for ( int i = 0 ; i < body.size() ; i++ )
         if ( !(body.get(i) instanceof RPCBody) )
           body.set(i, new RPCBody( (SOAPBody) body.get(i) ) );
  @@ -179,14 +196,20 @@
       Element  root ;
       int      i ;
   
  -    root = new Element( Constants.ELEM_ENVELOPE, Constants.NSPREFIX_SOAP_ENV,
  -                        Constants.URI_SOAP_ENV );
  +    String tmpEnvPre = (prefix != null ? prefix : Constants.NSPREFIX_SOAP_ENV);
  +    String tmpEnvURI = (namespaceURI != null ? namespaceURI :
  +                                               Constants.URI_SOAP_ENV);
  +    String tmpEnc    = (encodingStyleURI != null ? encodingStyleURI :
  +                                                   Constants.URI_SOAP_ENC );
  +
  +    root = new Element( Constants.ELEM_ENVELOPE, tmpEnvPre, tmpEnvURI );
  +    root.addAttribute( new Attribute( Constants.ATTR_ENCODING_STYLE,
  +                                      tmpEnvPre, tmpEnvURI, tmpEnc ) );
       doc = new Document( root );
   
       if ( headers != null && headers.size() > 0 ) {
         Element elem = new Element( Constants.ELEM_HEADER, 
  -                                  Constants.NSPREFIX_SOAP_ENV,
  -                                  Constants.URI_SOAP_ENV );
  +                                  tmpEnvPre, tmpEnvURI );
         root.addContent( elem );
         for ( i = 0 ; i < headers.size() ; i++ ) {
           SOAPHeader h = (SOAPHeader) headers.get(i);
  @@ -195,8 +218,7 @@
       } 
       if ( body != null ) {
         Element elem = new Element( Constants.ELEM_BODY, 
  -                                  Constants.NSPREFIX_SOAP_ENV,
  -                                  Constants.URI_SOAP_ENV );
  +                                  tmpEnvPre, tmpEnvURI );
         root.addContent( elem );
         for ( i = 0 ; i < body.size() ; i++ ) {
           Element  bod = ((SOAPBody)body.get(i)).getAsXML();
  
  
  

Mime
View raw message