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/test/wsdl Wsdl2javaTestSuite.xml
Date Wed, 04 Sep 2002 13:25:03 GMT
dims        2002/09/04 06:25:03

  Modified:    java/src/org/apache/axis/client AxisClient.java
               java/src/org/apache/axis/handlers
                        HandlerInfoChainFactory.java
               java/src/org/apache/axis/deployment/wsdd WSDDConstants.java
                        WSDDJAXRPCHandlerInfo.java
                        WSDDJAXRPCHandlerInfoChain.java WSDDService.java
               java/test/wsdl Wsdl2javaTestSuite.xml
  Log:
  Patch from "Greg Truty" <gtruty@us.ibm.com> for JAXRPC Handler testcase + changes.
  
  Notes from Greg:
  I've made a bit of progress w/the Handler code and have testcase plus some
  code changes (along w/some other bugs that I have noticed).  This is on a
  version of todays driver (9/03).
  
  The testcase is included below in test\jaxrpchandler.  It tests the
  addition of a client/server side handler, along w/ client-config and
  programatic API access changes.  It deploys/undeploys the service
  appropriately.  The handler adds a header element at each of the hook
  points, incrementing a counter in the header.  Lastly, on the client
  response, it checks to ensure the counter has been updated appropriate and
  calls a static method to the testcase (it's out-of-band) to confirm that
  the handlers executed appropriately.
  
  The code changes take into account the role/header/parameter options (which
  were wrong/missing in the code orginally checked in).
  
  Revision  Changes    Path
  1.55      +24 -18    xml-axis/java/src/org/apache/axis/client/AxisClient.java
  
  Index: AxisClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/AxisClient.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- AxisClient.java	29 Aug 2002 19:22:44 -0000	1.54
  +++ AxisClient.java	4 Sep 2002 13:25:02 -0000	1.55
  @@ -221,6 +221,10 @@
       }
   
       protected void invokeJAXRPCHandlers(MessageContext context){
  +	java.util.List chain = null;
  +	HandlerInfoChainFactory hiChainFactory = null;
  +	boolean clientSpecified = false;
  +
           Service service
               = (Service)context.getProperty(Call.WSDL_SERVICE);
           if(service == null) {
  @@ -234,27 +238,29 @@
   
           javax.xml.rpc.handler.HandlerRegistry registry;
           registry = service.getHandlerRegistry();
  -        if(registry == null) {
  -            return;
  +        if(registry != null) {
  +	    chain = registry.getHandlerChain(portName);
  +	    if ((chain != null) && (!chain.isEmpty())) {
  +		hiChainFactory = new HandlerInfoChainFactory(chain);
  +		clientSpecified = true;
  +	    }
           }
   
  -        java.util.List chain = registry.getHandlerChain(portName);
  +	// 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(chain == null || chain.isEmpty())
  -            return;
  -
  -        SOAPService    soapService = context.getService();
  -        if (soapService != null) {
  -            // A client configuration exists for this service.  Check to see
  -            //  if there is a HandlerInfoChain configured upon it.
  -            java.util.List cfgChain = (java.util.List) soapService.getOption(Constants.ATTR_HANDLERINFOCHAIN);

  -            // GLT - merge this w/an existing chain  
  -            //  for now... use the container version
  -            chain = cfgChain;
  -        }
  -        
  -        HandlerInfoChainFactory handlerChainFactory = new HandlerInfoChainFactory(chain);
  -        HandlerChainImpl impl =  (HandlerChainImpl) handlerChainFactory.createHandlerChain();
  +	if (hiChainFactory == null) {
  +	    return;
  +	}
  +	HandlerChainImpl impl = (HandlerChainImpl) hiChainFactory.createHandlerChain();
   
           if(!context.getPastPivot()) {
               impl.handleRequest(context);
  
  
  
  1.3       +2 -2      xml-axis/java/src/org/apache/axis/handlers/HandlerInfoChainFactory.java
  
  Index: HandlerInfoChainFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/HandlerInfoChainFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HandlerInfoChainFactory.java	29 Aug 2002 21:02:39 -0000	1.2
  +++ HandlerInfoChainFactory.java	4 Sep 2002 13:25:02 -0000	1.3
  @@ -73,8 +73,8 @@
           this.handlerInfos = handlerInfos;
       }
   
  -    public HandlerInfo getHandlerInfo(int index) {
  -        return (HandlerInfo) handlerInfos.get(index);
  +    public List getHandlerInfos() {
  +        return this.handlerInfos;
       }
   
       public HandlerChain createHandlerChain() {
  
  
  
  1.23      +1 -0      xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java
  
  Index: WSDDConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- WSDDConstants.java	28 Aug 2002 14:51:49 -0000	1.22
  +++ WSDDConstants.java	4 Sep 2002 13:25:03 -0000	1.23
  @@ -155,6 +155,7 @@
       public static final QName QNAME_JAXRPC_HANDLERINFO = new QName(URI_WSDD, ELEM_WSDD_JAXRPC_HANDLERINFO);
       public static final QName QNAME_JAXRPC_HANDLERINFOCHAIN = new QName(URI_WSDD, ELEM_WSDD_JAXRPC_CHAIN);
       public static final QName QNAME_JAXRPC_HEADER = new QName(URI_WSDD, ELEM_WSDD_JAXRPC_HEADER);
  +    public static final QName QNAME_JAXRPC_ROLE = new QName(URI_WSDD,ELEM_WSDD_JAXRPC_ROLE);
   
       public static final String ATTR_LANG_SPEC_TYPE = "languageSpecificType";
       public static final String ATTR_QNAME = "qname";
  
  
  
  1.3       +40 -18    xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDJAXRPCHandlerInfo.java
  
  Index: WSDDJAXRPCHandlerInfo.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDJAXRPCHandlerInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSDDJAXRPCHandlerInfo.java	29 Aug 2002 19:20:20 -0000	1.2
  +++ WSDDJAXRPCHandlerInfo.java	4 Sep 2002 13:25:03 -0000	1.3
  @@ -64,17 +64,20 @@
   import java.io.IOException;
   import java.util.HashMap;
   import java.util.Map;
  +import java.util.Iterator;
  +import java.util.Set;
  +import java.util.Hashtable;
   
   
   /**
    *
    */
   public class WSDDJAXRPCHandlerInfo
  -    extends WSDDDeployableItem
  +    extends WSDDElement
   {
       private String _classname;
  -    private QName[] _headers;
       private Map _map;
  +    private QName[] _headers;
       
       /**
        * Default constructor
  @@ -109,7 +112,7 @@
                   Element param = elements[i];
                   String pname = param.getAttribute(ATTR_NAME);
                   String value = param.getAttribute(ATTR_VALUE);
  -                parameters.put(pname, value); 
  +				_map.put(pname, value);
               }           
           }
           
  @@ -122,8 +125,9 @@
                   if (headerStr == null ||  headerStr.equals("")) 
                       throw new WSDDException(JavaUtils.getMessage("noValidHeader"));   
 
   
  -                QName headerQName = XMLUtils.getQNameFromString(headerStr, e);
  -                headerList.add(headerQName); 
  +                QName headerQName = XMLUtils.getQNameFromString(headerStr, qElem);
  +                if (headerQName != null) 
  +	                headerList.add(headerQName); 
               }
               QName[] headers = new QName[headerList.size()];
               _headers = (QName[]) headerList.toArray(headers);
  @@ -148,7 +152,7 @@
       }
       
       public void setHandlerMap(Map map) {
  -        _map = map;
  +        // Add parameters to Parameters Table here
       }
       
       public QName[] getHeaders() {
  @@ -162,19 +166,37 @@
       public void writeToContext(SerializationContext context)
           throws IOException
       {
  -        // GLT - FIX THIS UP
  -        AttributesImpl attrs = new AttributesImpl();
  -        QName name = getQName();
  -        if (name != null) {
  -            attrs.addAttribute("", ATTR_NAME, ATTR_NAME,
  -                               "CDATA", context.qName2String(name));
  -        }
  +	AttributesImpl attrs = new AttributesImpl();
  +	attrs.addAttribute("", ATTR_CLASSNAME, ATTR_CLASSNAME,
  +				   "CDATA", _classname);
  +	context.startElement(WSDDConstants.QNAME_JAXRPC_HANDLERINFO, attrs);
  +
  +	Map ht =  _map;
  +	if (ht != null) {
  +	    Set keys= ht.keySet();
  +	    Iterator iter = keys.iterator();
  +	    while (iter.hasNext()) {
  +	    	String name = (String) iter.next();
  +	    	String value = (String) ht.get(name);
  +	    	attrs = new AttributesImpl();
  +	    	attrs.addAttribute("",ATTR_NAME, ATTR_NAME, "CDATA", name);
  +	    	attrs.addAttribute("",ATTR_VALUE, ATTR_VALUE, "CDATA", value);
  +	    	context.startElement(WSDDConstants.QNAME_PARAM,attrs);
  +	    	context.endElement();
  +	    }
  +	}
  +
  +	if (_headers != null) {
  +	    for (int i=0 ; i < _headers.length ; i++) {
  +		QName qname = _headers[i];
  +		attrs = new AttributesImpl();
  +		attrs.addAttribute("",ATTR_QNAME,ATTR_QNAME,"CDATA",context.qName2String(qname));
  +		context.startElement(WSDDConstants.QNAME_JAXRPC_HEADER,attrs);
  +		context.endElement();
  +	    }
  +	}
   
  -        attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE,
  -                           "CDATA", context.qName2String(getType()));
  -        context.startElement(WSDDConstants.QNAME_HANDLER, attrs);
  -        writeParamsToContext(context);
  -        context.endElement();
  +	context.endElement();
       }
   
   }
  
  
  
  1.3       +38 -4     xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDJAXRPCHandlerInfoChain.java
  
  Index: WSDDJAXRPCHandlerInfoChain.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDJAXRPCHandlerInfoChain.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSDDJAXRPCHandlerInfoChain.java	29 Aug 2002 19:20:20 -0000	1.2
  +++ WSDDJAXRPCHandlerInfoChain.java	4 Sep 2002 13:25:03 -0000	1.3
  @@ -55,19 +55,25 @@
   package org.apache.axis.deployment.wsdd;
   
   import org.apache.axis.handlers.HandlerInfoChainFactory;
  +import org.apache.axis.encoding.SerializationContext;
   import org.apache.axis.utils.ClassUtils;
   import org.w3c.dom.Element;
  +import org.xml.sax.helpers.AttributesImpl;
   
   import javax.xml.namespace.QName;
   import javax.xml.rpc.handler.HandlerInfo;
   import java.util.ArrayList;
   import java.util.Map;
  +import java.util.List;
  +import java.util.Iterator;
  +import java.io.IOException;
   
   /**
    *
    */
   public class WSDDJAXRPCHandlerInfoChain extends WSDDHandler {
       
  +    private ArrayList _hiList;
       private HandlerInfoChainFactory _hiChainFactory;
       private String[] _roles;
   
  @@ -85,12 +91,14 @@
       public WSDDJAXRPCHandlerInfoChain(Element e) throws WSDDException {
           super(e);
   
  -        ArrayList infoList = new ArrayList();
  +	ArrayList infoList = new ArrayList();
  +	_hiList = new ArrayList();
           Element[] elements = getChildElements(e, ELEM_WSDD_JAXRPC_HANDLERINFO);
           if (elements.length != 0) {
               for (int i = 0; i < elements.length; i++) {
                   WSDDJAXRPCHandlerInfo handlerInfo =
                       new WSDDJAXRPCHandlerInfo(elements[i]);
  +		_hiList.add(handlerInfo);
   
                   String handlerClassName = handlerInfo.getHandlerClassName();
                   Class handlerClass = null;
  @@ -119,9 +127,9 @@
                   String role = elements[i].getAttribute( ATTR_SOAPACTORNAME);
                   roleList.add(role);
               }
  -            String [] roles =new String[roleList.size()]; 
  -            roles = (String[]) roleList.toArray(roles);
  -            _hiChainFactory.setRoles(roles);
  +            _roles =new String[roleList.size()]; 
  +            _roles = (String[]) roleList.toArray(_roles);
  +            _hiChainFactory.setRoles(_roles);
           }
           
       }
  @@ -138,4 +146,30 @@
           return WSDDConstants.QNAME_JAXRPC_HANDLERINFOCHAIN;
       }
       
  +    /**
  +     * Write this element out to a SerializationContext
  +     */
  +    public void writeToContext(SerializationContext context)
  +            throws IOException {
  +			context.startElement(QNAME_JAXRPC_HANDLERINFOCHAIN,null);
  +			
  +			List his = _hiList;
  +			Iterator iter = his.iterator();
  +			while (iter.hasNext()) {
  +				WSDDJAXRPCHandlerInfo hi = (WSDDJAXRPCHandlerInfo) iter.next();
  +				hi.writeToContext(context);
  +			}
  +			
  +			if (_roles != null) {
  +				for (int i=0; i < _roles.length ; i++) {
  +		        	AttributesImpl attrs1 = new AttributesImpl();
  +	            	attrs1.addAttribute("", ATTR_SOAPACTORNAME, ATTR_SOAPACTORNAME,
  +                               "CDATA", _roles[i]);
  +					context.startElement(QNAME_JAXRPC_ROLE,attrs1);
  +					context.endElement();
  +				}
  +			}
  +			
  +			context.endElement();
  +	}
   }
  
  
  
  1.86      +19 -8     xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
  
  Index: WSDDService.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- WSDDService.java	29 Aug 2002 21:02:40 -0000	1.85
  +++ WSDDService.java	4 Sep 2002 13:25:03 -0000	1.86
  @@ -87,6 +87,8 @@
   import java.util.ArrayList;
   import java.util.StringTokenizer;
   import java.util.Vector;
  +import java.util.List;
  +import java.util.Iterator;
   
   /**
    * A service represented in WSDD.
  @@ -119,7 +121,8 @@
        */
       private QName providerQName;
   
  -    private HandlerInfoChainFactory _hiChainFactory;
  +//    private HandlerInfoChainFactory _hiChainFactory;
  +	private WSDDJAXRPCHandlerInfoChain _wsddHIchain;
   
       ServiceDesc desc = new ServiceDesc();
   
  @@ -221,11 +224,10 @@
               }
           }
   
  -        // Add in JAX-RPC support for HandlerInfo chains
  +	// Add in JAX-RPC support for HandlerInfo chains
           Element hcEl = getChildElement(e, ELEM_WSDD_JAXRPC_CHAIN);
           if (hcEl != null) {
  -        WSDDJAXRPCHandlerInfoChain wsddHIChain = new WSDDJAXRPCHandlerInfoChain(hcEl);
  -            _hiChainFactory = wsddHIChain.getHandlerChainFactory();
  +	    	_wsddHIchain = new WSDDJAXRPCHandlerInfoChain(hcEl);
           }
   
           initTMR();
  @@ -423,10 +425,12 @@
               service.setOption(AxisEngine.PROP_SEND_XSI, Boolean.FALSE);
           }
   
  -        // Set handlerInfoChain
  -        if (_hiChainFactory != null) {
  -            service.setOption(Constants.ATTR_HANDLERINFOCHAIN, _hiChainFactory);
  -        }
  +	// Set handlerInfoChain
  +	if (_wsddHIchain != null) {
  +            HandlerInfoChainFactory hiChainFactory = _wsddHIchain.getHandlerChainFactory();
  +
  +	    service.setOption(Constants.ATTR_HANDLERINFOCHAIN, hiChainFactory);
  +	}
   
           AxisEngine.normaliseOptions(service);
   
  @@ -576,7 +580,14 @@
               context.endElement();
           }
   
  +		if (_wsddHIchain != null) {
  +			_wsddHIchain.writeToContext(context);
  +
  +		}
  +		
           context.endElement();
  +
  +
       }
   
       public void setCachedService(SOAPService service)
  
  
  
  1.125     +19 -0     xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml
  
  Index: Wsdl2javaTestSuite.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v
  retrieving revision 1.124
  retrieving revision 1.125
  diff -u -r1.124 -r1.125
  --- Wsdl2javaTestSuite.xml	29 Aug 2002 21:17:58 -0000	1.124
  +++ Wsdl2javaTestSuite.xml	4 Sep 2002 13:25:03 -0000	1.125
  @@ -982,6 +982,25 @@
                  testcase="no">
       </wsdl2java>
   
  +    <wsdl2java url="test/wsdl/jaxrpchandler/jaxrpchandler.wsdl"
  +               output="build/work"
  +               serverSide="no"
  +               testcase="no">
  +    </wsdl2java>
  +    <!-- Copy modified files to work directory -->
  +    <copy todir="${build.dir}/work/test/wsdl/jaxrpchandler" overwrite="yes">
  +      <fileset dir="${test.dir}/wsdl/jaxrpchandler">
  +        <include name="*.java"/>
  +        <include name="*.wsdd"/>
  +      </fileset>
  +    </copy>
  +    <!-- Compile Java -->
  +    <javac srcdir="${build.dir}/work" destdir="${build.dest}" debug="${debug}">
  +      <classpath refid="test-classpath" />
  +      <include name="test/wsdl/jaxprchandler/**.java" />
  +    </javac>
  +
  +
       <!-- The following WSDL are BAD.  We're keeping them here so we can -->
       <!-- check periodically to see whether the owner has fixed them.    -->
   
  
  
  

Mime
View raw message