Index: xml-axis/java/src/org/apache/axis/client/Stub.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/client/Stub.java,v
retrieving revision 1.12
diff -r1.12 Stub.java
66a67,68
> import org.apache.axis.serviceContext.*;
> import org.apache.axis.message.SOAPHeaderElement;
92a95,97
>     // Support for Header
>     private ServiceContext serviceContext = new ServiceContext();
> 
258a264,378
> 
> 
>     /**
>      * This method returns the ServiceContext object for this binding.
>      * @return ServiceContext
>      */
>     public ServiceContext getServiceContext() {
>         return serviceContext;
>     }
>     
>     /**
>      * This method allow the user to substitute the ServiceContext instance of this with binding 
>      * for another one.
>      * @return void
>      */
>     public void setServiceContext(ServiceContext sc) {
>         serviceContext = sc;
>     }
> 
>     /**
>      * This method allows a service consumer to set a SOAP Header object defined by
>      * <b>soap:header</b> operation element.  Every operation refering to this soap:header 
>      * part in their binding will send this object as a SOAP Header.  
>      * @param partName a String that identify the soap:header part
>      * @param header an Object that will be sent as a SOAPHeader
>      * @param lifeCycle a HeaderLifeCycle that defines the header life cycle. 
>      * @return void
>      * @see org.apache.axis.serviceContext.HeaderLifeCycle
>      */
>     public void setHeader(String partName, Object header, HeaderLifeCycle lifeCycle) {                    
>         serviceContext.setHeader(partName, header, lifeCycle);      
>     }
> 
>     /**
>      * This method is meant to be used by the service consumer to retreive a service's 
>      * ServiceContext header object.  It returns the object for the given part 
>      * name from the response hash of headers.  It is the one returned by the service 
>      * provider.
>      * @param partName a String that identify the soap:header part		
>      * @return Object, null when the header does not exists, which means that it 
>      * has not been returned by the service provider.
>      */    
>     public Object getHeader(String partName) {		
>         return serviceContext.getHeader(partName);
>     }
> 
>     /**
>      * This method is meant to be used by the BindingStub to set the requested request header onto 
>      * the Call object just before the call gets invoked. 
>      * @param namespace String
>      * @param partName String
>      * @return SOAPHeaderElement
>      */    
>     protected SOAPHeaderElement getHeader(String namespace, String partName) {		
>         return new SOAPHeaderElement(
>       		namespace, 
>       		partName, 
>       		serviceContext.getRequestHeader( partName ) );
>     }
>     
>     /**
>      * This method is provided with the soap:header part name and the namespace so it can update the 
>      * Header object stored in the Service's ServiceContext using the one retreived in the response
>      * @param call Call object in which to retreive the header object
>      * @param namespace String as defined in the WSDL
>      * @param partName String as defined in the WSDL
>      * @return void
>      */
>     protected void updateHeader(org.apache.axis.client.Call call, String namespace, String partName) {		
> 
>         try {      
>             org.apache.axis.Message              response = call.getMessageContext().getResponseMessage();      
>             org.apache.axis.message.SOAPEnvelope env      = response.getSOAPEnvelope();
>             
>             if ( env != null )	{		
>                 SOAPHeaderElement header = env.getHeaderByName(namespace, partName, true);
>             
>             	if ( header != null )	{						
>                     // Retrieve the object from the response
>                     Object theHeader = header.getObjectValue();
>                     
>                     if ( theHeader == null )
>                      	// We cannot retreive the object just return for now.
>                     	return;
>                     
>                     // Retrieve this header object LifeCycle in the hash of request headers.
>                     String          currentHeaderKey = serviceContext.getRequestHeaderKey(partName);
>                     HeaderLifeCycle lifeCycle        = serviceContext.getHeaderLifeCycle(partName);
>             
>                     if ( currentHeaderKey != null ) {
>                     
>                     	if ( lifeCycle.equals(HeaderLifeCycle.REPLACE) ) {
>                     		// If the header lifeCycle is set to HeaderLifeCycle.REPLACE we replace the 
>                     		// header object found for that part in the ServiceContext requestHeader Hashtable.
>                     		serviceContext.setRequestHeader(currentHeaderKey, theHeader);
>                     		
> 						} else if ( lifeCycle.equals(HeaderLifeCycle.DISCARD) ) {
>                     		// If the header lifeCycle is set to HeaderLifeCycle.DISCARD we remove the 
>                     		// header object found for that part in the ServiceContext requestHeader Hashtable.
>                     		serviceContext.removeRequestHeader(currentHeaderKey);
>                     
>                    		} else if ( lifeCycle.equals(HeaderLifeCycle.PERSIST) ) {
>                     		// If the header lifeCycle is set to HeaderLifeCycle.PERSIST we keep the the 
>                     		// header object therefore we do nothing.
>                     	}
>                     
>                         // In all case the received header object is stored in the ServiceContext's 
>                         // responseHeader Hashtable.  This could be change to a lazyer approach where
>                         // we would store the object on demand only....
>                         serviceContext.setResponseHeader(currentHeaderKey, theHeader);
>                     }
>                 }					
>             }				
>         } catch ( Exception e ) { /* Not really sure what to do with this... */ }
>     }    
Index: xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
retrieving revision 1.73
diff -r1.73 JavaStubWriter.java
65a66
> import java.util.Enumeration;
78a80
> import javax.wsdl.extensions.soap.SOAPHeader;
90a93,94
> import org.apache.axis.wsdl.symbolTable.Header;
> import org.apache.axis.wsdl.symbolTable.Headers;
267a272,276
> 
>             // Take care of this operation's header management stuff.
>             Headers headers = new Headers();
>             headers.prepareHeaders( operation );
> 
277c286
<                         operation, parameters, soapAction, isRPC);
---
>                         operation, headers, parameters, soapAction, isRPC);
291a301,303
>         
>         // THIS IS PATCH THAT ALLOWS -A TO GENERATE ALL TYPE MAPPING
>         // THIS IS NOT PART OF AXIS.
292a305
> 		/* This is replaced 
296a310,321
>         */
> 
> 		// NEW - BEGIN 
>         Iterator symbolTableTypesIterator = symbolTable.getTypes().iterator();
>         TypeEntry typeEntry;
>         while (symbolTableTypesIterator.hasNext()) {
>             typeEntry = (TypeEntry) symbolTableTypesIterator.next();
>             if (typeEntry.isReferenced()) {
>                 firstPassTypes.add(typeEntry);
>             }
>         }
> 		// NEW - END 
459a485
>             Headers headers,
581a608,616
>         // Set the headers
>         pw.println();
>         Enumeration headersEnum = headers.getRequestHeaders().elements();
>         while ( headersEnum.hasMoreElements() ) {
>             Header h = (Header)headersEnum.nextElement();                    
>             // Namespace stuff UNTESTED
>         	pw.println("        call.addHeader( getHeader( \"" + h.getMessageQName().getNamespaceURI() + "\", \"" + h.getPartName() + "\"));");
>         }                
>         
612a648,657
>         
>         // Update the headers
>         headersEnum = headers.getResponseHeaders().elements();
>         while ( headersEnum.hasMoreElements() ) {
>             Header h = (Header)headersEnum.nextElement();          
>             // Namespace stuff UNTESTED
>         	pw.println("        updateHeader( call, \"" + h.getMessageQName().getNamespaceURI() + "\", \"" + h.getPartName() + "\");");
>         }       
>         
>         pw.println();       
