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/client Stub.java
Date Fri, 01 Nov 2002 16:40:08 GMT
dims        2002/11/01 08:40:08

  Modified:    java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java
               java/test/wsdl/interop4/groupi Round4XSDTestTestCase.java
               java/src/org/apache/axis/client Stub.java
  Log:
  1. Possible Fix for Bug 13618 - Implicit header support
  2. Update Round4 XSD Test to test the new get/set header in Stub.
  
  Revision  Changes    Path
  1.105     +10 -3     xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.104
  retrieving revision 1.105
  diff -u -r1.104 -r1.105
  --- JavaStubWriter.java	21 Oct 2002 02:13:47 -0000	1.104
  +++ JavaStubWriter.java	1 Nov 2002 16:40:08 -0000	1.105
  @@ -54,9 +54,9 @@
    */
   package org.apache.axis.wsdl.toJava;
   
  -import org.apache.axis.utils.Messages;
   import org.apache.axis.enum.Style;
   import org.apache.axis.enum.Use;
  +import org.apache.axis.utils.Messages;
   import org.apache.axis.wsdl.symbolTable.BindingEntry;
   import org.apache.axis.wsdl.symbolTable.CollectionTE;
   import org.apache.axis.wsdl.symbolTable.Element;
  @@ -723,12 +723,15 @@
           }
           pw.println();
   
  +        // Set the headers
  +        pw.println("        setRequestHeaders(_call);");
  +
           // Invoke the operation
           if (oneway) {
               pw.print("        _call.invokeOneWay(");
           }
           else {
  -            pw.print("        java.lang.Object _resp = _call.invoke(");
  +        	pw.print("        java.lang.Object _resp = _call.invoke(");
           }
           pw.print("new java.lang.Object[] {");
           writeParameters(pw, parms);
  @@ -773,10 +776,12 @@
           pw.println("        if (_resp instanceof java.rmi.RemoteException) {");
           pw.println("            throw (java.rmi.RemoteException)_resp;");
           pw.println("        }");
  -
  + 
           int allOuts = parms.outputs + parms.inouts;
           if (allOuts > 0) {
               pw.println("        else {");
  +            pw.println("            getResponseHeaders(_call);");
  +        
               if (allOuts == 1) {
                   if (parms.returnParam != null) {
                       writeOutputAssign(pw, "return ", parms.returnParam.getType(),
  @@ -821,6 +826,8 @@
   
               }
               pw.println("        }");
  +        } else {
  +            pw.println("        getResponseHeaders(_call);");
           }
       } // writeResponseHandling
   
  
  
  
  1.4       +6 -1      xml-axis/java/test/wsdl/interop4/groupi/Round4XSDTestTestCase.java
  
  Index: Round4XSDTestTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/interop4/groupi/Round4XSDTestTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Round4XSDTestTestCase.java	9 Oct 2002 12:24:27 -0000	1.3
  +++ Round4XSDTestTestCase.java	1 Nov 2002 16:40:08 -0000	1.4
  @@ -600,8 +600,13 @@
           assertTrue("binding is null", binding != null);
   
           try {
  -            //TODO: What do we need to do here?
  +            Round4XSDTestSoapStub stub = (Round4XSDTestSoapStub) binding;
  +            String namespace = url.toString();
  +            stub.setHeader(namespace, "test1", "header1");
  +            stub.setHeader(namespace, "test2", "header2");
               binding.echoVoidSoapHeader();
  +            assertEquals(stub.getHeader(namespace, "test1").getObjectValue(), "header1");
  +            assertEquals(stub.getHeader(namespace, "test2").getObjectValue(), "header2");
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  
  
  
  1.19      +84 -11    xml-axis/java/src/org/apache/axis/client/Stub.java
  
  Index: Stub.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Stub.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Stub.java	18 Sep 2002 16:10:42 -0000	1.18
  +++ Stub.java	1 Nov 2002 16:40:08 -0000	1.19
  @@ -55,21 +55,18 @@
   
   package org.apache.axis.client;
   
  -import java.net.MalformedURLException;
  -import java.net.URL;
  -
  -import java.util.Iterator;
  -import java.util.Properties;
  +import org.apache.axis.AxisFault;
  +import org.apache.axis.message.SOAPHeaderElement;
  +import org.apache.axis.utils.Messages;
   
   import javax.xml.namespace.QName;
  -
   import javax.xml.rpc.JAXRPCException;
   import javax.xml.rpc.Service;
  -
  -import org.apache.axis.AxisFault;
  -
  -import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.utils.Messages;
  +import java.net.MalformedURLException;
  +import java.net.URL;
  +import java.util.Iterator;
  +import java.util.Properties;
  +import java.util.Vector;
   
   /**
   * This class is the base for all generated stubs.
  @@ -95,6 +92,9 @@
       protected Integer    cachedTimeout      = null;
       protected QName      cachedPortName     = null;
   
  +    // Support for Header
  +    private Vector headers = new Vector();
  +
       // Flag to determine whether this is the first call to register type mappings.
       // This need not be synchronized because firstCall is ONLY called from within
       // a synchronized block in the generated stub code.
  @@ -290,4 +290,77 @@
           maintainSession = session;
           cachedProperties.put(Call.SESSION_MAINTAIN_PROPERTY, new Boolean(session));
       } // setmaintainSession
  +
  +
  +    /**
  +     * Set the header
  +     * @namespace namespace
  +     * @param partName that uniquely identify a header object.
  +     * @param headerValue Object that is sent in the request as a SOAPHeader
  +     * @return void
  +     */
  +    public void setHeader(String namespace, String partName, Object headerValue) {
  +        headers.add(new SOAPHeaderElement(namespace, partName, headerValue));
  +    }
  +
  +    /**
  +     * Set the header
  +     */ 
  +    public void setHeader(SOAPHeaderElement header) {
  +        headers.add(header);
  +    }
  +
  +    /**
  +     * Get the header element
  +     */ 
  +    public SOAPHeaderElement getHeader(String namespace, String partName) {
  +        for(int i=0;i<headers.size();i++) {
  +            SOAPHeaderElement header = (SOAPHeaderElement)headers.get(i);
  +            if(header.getNamespaceURI().equals(namespace) &&
  +               header.getName().equals(partName))
  +                return header;
  +        }
  +        return null;
  +    }
  +    
  +    /**
  +     * Get the array of header elements
  +     */ 
  +    public SOAPHeaderElement[] getHeaders() {
  +        SOAPHeaderElement[] array = new SOAPHeaderElement[headers.size()];
  +        headers.copyInto(array);
  +        return array;
  +    }
  +
  +    /**
  +     * This method clears both requestHeaders and responseHeaders hashtables.
  +     * @return void
  +     */
  +    public void clearHeaders() {
  +        headers.clear();
  +    }
  +    
  +    protected void setRequestHeaders(org.apache.axis.client.Call call) throws AxisFault
{		
  +        SOAPHeaderElement[] headers = getHeaders();
  +        for(int i=0;i<headers.length;i++){
  +            call.addHeader(headers[i]);
  +        }
  +    }  
  +
  +    /**
  +     * Helper method for updating headers from the response.
  +     * @return void
  +     */
  +    protected void getResponseHeaders(org.apache.axis.client.Call call) throws AxisFault
{		
  +        org.apache.axis.Message response = call.getMessageContext().getResponseMessage();
     
  +        org.apache.axis.message.SOAPEnvelope env = response.getSOAPEnvelope();
  +            
  +        if ( env != null )	{
  +            Iterator iterator = env.getHeaders().iterator();
  +            while(iterator.hasNext()){
  +                SOAPHeaderElement header = (SOAPHeaderElement) iterator.next();
  +                headers.add(header);
  +            }
  +        }				
  +    }  
   }
  
  
  

Mime
View raw message