Hello,

Here is a patch to enable clients to set up transport headers for sending
envelope.
Patched files are Call & Message, additional methods added with support to
headers param

Best regards,
Pavel

Index: Message.java
===================================================================
RCS file: /home/cvspublic/xml-soap/java/src/org/apache/soap/messaging/Message.java,v
retrieving revision 1.10
diff -u -r1.10 Message.java
--- Message.java        17 May 2001 18:25:42 -0000      1.10
+++ Message.java        18 Oct 2002 11:59:23 -0000
@@ -96,7 +96,7 @@
   public void setSOAPTransport (SOAPTransport st) {
     this.st = st;
   }
-   
+
   public SOAPTransport getSOAPTransport () {
     return st;
   }
@@ -105,7 +105,7 @@
    * Send an envelope to the given URL via the SOAPTransport that has
    * been configured for this instance (or SOAPHTTPConnection by default).
    * The envelope is sent exactly as-is.
-   * 
+   *
    * @param url the url to send to
    * @param actionURI the value of the SOAPAction header
    * @param env envelope to send
@@ -114,13 +114,31 @@
    */
   public void send (URL url, String actionURI, Envelope env)
        throws SOAPException {
+      send(url, actionURI, env, null);
+  }
+
+      /**
+       * Send an envelope to the given URL via the SOAPTransport that has
+       * been configured for this instance (or SOAPHTTPConnection by default).
+       * The envelope is sent exactly as-is.
+       *
+       * @param url the url to send to
+       * @param actionURI the value of the SOAPAction header
+       * @param env envelope to send
+       * @param headers any parameters to be used as protocol headers
+       *
+       * @exception SOAPException if something goes wrong.
+       */
+      public void send (URL url, String actionURI, Envelope env, Hashtable headers)
+           throws SOAPException {
+
     // Construct default HTTP transport if not specified.
     if (st == null) {
       st = new SOAPHTTPConnection ();
     }
 
     // Send request.
-    st.send (url, actionURI, null, env, null, reqCtx);
+    st.send (url, actionURI, headers, env, null, reqCtx);
   }
 
   /**
@@ -143,7 +161,7 @@
       resCtx = st.getResponseSOAPContext ();
       String payloadStr = Call.getEnvelopeString (st);
 
-      Document doc = 
+      Document doc =
           xdb.parse(new InputSource(new StringReader(payloadStr)));
 
       if (doc == null) {
@@ -157,8 +175,8 @@
       throw new SOAPException (Constants.FAULT_CODE_CLIENT, me.getMessage (),
                               me);
     } catch (SAXException ioe) {
-      throw new SOAPException (Constants.FAULT_CODE_CLIENT, 
-                               "Parsing error, response was:\n" + 
+      throw new SOAPException (Constants.FAULT_CODE_CLIENT,
+                               "Parsing error, response was:\n" +
                                ioe.getMessage(), ioe);
     } catch (IOException ioe) {
       throw new SOAPException (Constants.FAULT_CODE_CLIENT, ioe.getMessage (),
Index: Call.java
===================================================================
RCS file: /home/cvspublic/xml-soap/java/src/org/apache/soap/rpc/Call.java,v
retrieving revision 1.17
diff -u -r1.17 Call.java
--- Call.java   30 Aug 2002 21:39:00 -0000      1.17
+++ Call.java   18 Oct 2002 11:59:54 -0000
@@ -148,7 +148,7 @@
   {
     this.st = st;
   }
-   
+
   public SOAPTransport getSOAPTransport()
   {
     return st;
@@ -156,16 +156,16 @@
 
   /**
    * Set timeout in our MessageContext.
-   * 
+   *
    * @param value the maximum amount of time, in milliseconds
    */
   public void setTimeout (int value) {
     to = value;
   }
-    
+
   /**
    * Get timeout from our MessageContext.
-   * 
+   *
    * @return value the maximum amount of time, in milliseconds
    */
   public int getTimeout () {
@@ -187,7 +187,7 @@
   public void setUseDocumentBuilder(boolean useDocumentBuilder) {
     this.useDocumentBuilder = useDocumentBuilder;
   }
-    
+
   /**
    * Add a MIME BodyPart.
    *
@@ -254,12 +254,26 @@
 
   /**
    * Invoke this call at the specified URL. Valid only on the client side.
+   *
+   * @param sendTo the URL to send the envelope to
+   * @param action the SOAPAction header field value
+   */
+  public Response invoke(URL sendTo, String action) throws SOAPException {
+      return invoke(sendTo, action, null);
+  }
+
+  /**
+   * Invoke this call at the specified URL. Valid only on the client side.
+   *
+   * @param sendTo the URL to send the envelope to
+   * @param action the SOAPAction header field value
+   * @param headers any other header fields to go to as protocol headers
    */
-  public Response invoke(URL url, String SOAPActionURI) throws SOAPException
+  public Response invoke(URL sendTo, String action, Hashtable headers) throws 
+SOAPException
   {
-    if (SOAPActionURI == null)
+    if (action == null)
     {
-      SOAPActionURI = "";
+      action = "";
     }
 
     // if the smr hasn't been created yet, do it now
@@ -278,11 +292,11 @@
         st = new SOAPHTTPConnection();
 
       // set the timeout
-      if (to != 0 && st instanceof SOAPHTTPConnection) 
+      if (to != 0 && st instanceof SOAPHTTPConnection)
         ((SOAPHTTPConnection)st).setTimeout(to);
 
       // Post the call envelope.
-      st.send(url, SOAPActionURI, null, callEnv, smr, ctx);
+      st.send(sendTo, action, headers, callEnv, smr, ctx);
 
       // Get the response context.
       SOAPContext respCtx = st.getResponseSOAPContext();
@@ -333,7 +347,7 @@
     {
       throw new SOAPException(Constants.FAULT_CODE_CLIENT,
                               "Parsing error, response was:\n" +e.getMessage(),
-                             e);
+                              e);
     }
     catch (IOException e)
     {
@@ -348,8 +362,8 @@
    * parser plus a transformation.
    */
   private Document parsePayload(String payload) throws IOException, SAXException {
-       InputSource input = new InputSource(new StringReader(payload));
-       if (!useDocumentBuilder) {
+          InputSource input = new InputSource(new StringReader(payload));
+          if (!useDocumentBuilder) {
       try {
         // If classes required for transformation are all present, use that method
         Class domResultClass = Class.forName("javax.xml.transform.dom.DOMResult");
@@ -359,14 +373,14 @@
         Class sourceClass = Class.forName("javax.xml.transform.Source");
         Class resultClass = Class.forName("javax.xml.transform.Result");
 
-           Object output = domResultClass.newInstance();
+            Object output = domResultClass.newInstance();
         Object source = saxSourceClass.newInstance();
 
         // Create factory and use to create transformer
         Method method = transformerFactoryClass.getDeclaredMethod("newInstance", new 
Class[]{});
-           Object xformFactory = method.invoke(null, new Object[]{});
+            Object xformFactory = method.invoke(null, new Object[]{});
         method = transformerFactoryClass.getDeclaredMethod("newTransformer", new 
Class[]{});
-           Object idTransform = method.invoke(xformFactory, new Object[]{});
+            Object idTransform = method.invoke(xformFactory, new Object[]{});
 
         // Set input source for SAX source
         method = saxSourceClass.getDeclaredMethod("setInputSource", new 
Class[]{InputSource.class});
@@ -381,7 +395,7 @@
 
         // If all has worked, we return here; for exceptions,
         // we fall through to the DOM parser.
-           return (Document) method.invoke(output, new Object[]{});
+            return (Document) method.invoke(output, new Object[]{});
       } catch (ClassNotFoundException e) {
       } catch (NoSuchMethodException e) {
       } catch (InvocationTargetException e) {

--
To unsubscribe, e-mail:   <mailto:soap-dev-unsubscribe@;xml.apache.org>
For additional commands, e-mail: <mailto:soap-dev-help@;xml.apache.org>

Reply via email to