Hello,

I hope this is the correct way to propose a patch.

I needed to add a SOAPAction header field to the request
generated by the SOAP/XML-RPC Request Sampler.  I also
split the URL text entry field into protocol, server, port,
and path components in the Soap Sampler Gui so that the Soap
Sampler can take advantage of URL Defaults (enhancement request 16163).

If these changes are useful to the project, can someone please
check this code into CVS?

Many thanks!

--- SoapSamplerGui.java.orig    2003-06-03 10:39:00.000000000 -0700
+++ SoapSamplerGui.java 2003-06-03 15:04:18.000000000 -0700
@@ -7,6 +7,7 @@

 import javax.swing.JPanel;

+import org.apache.jmeter.gui.util.VerticalPanel;
 import org.apache.jmeter.protocol.http.sampler.SoapSampler;
 import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
 import org.apache.jmeter.testelement.TestElement;
@@ -20,7 +21,11 @@
 public class SoapSamplerGui extends AbstractSamplerGui
 {
     private static final String label =
JMeterUtils.getResString("soap_sampler_title");
-    private JLabeledTextField urlField;
+    private JLabeledTextField protocolField;
+    private JLabeledTextField domainField;
+    private JLabeledTextField portField;
+    private JLabeledTextField pathField;
+    private JLabeledTextField soapAction;
     private JLabeledTextArea soapXml;

     public SoapSamplerGui()
@@ -56,18 +61,14 @@
         if (s instanceof SoapSampler)
         {
             SoapSampler sampler = (SoapSampler) s;
-            try
-            {
-                URL url = new URL(urlField.getText());
-                sampler.setDomain(url.getHost());
-                sampler.setPort(url.getPort());
-                sampler.setProtocol(url.getProtocol());
-                sampler.setMethod(SoapSampler.POST);
-                sampler.setPath(url.getPath());
-                sampler.setXmlData(soapXml.getText());
-            }
-            catch (MalformedURLException e)
-            {}
+            sampler.setProtocol(protocolField.getText());
+            sampler.setDomain(domainField.getText());
+            if (portField.getText().length() > 0)
+                sampler.setPort(Integer.parseInt(portField.getText()));
+            sampler.setMethod(SoapSampler.POST);
+            sampler.setPath(pathField.getText());
+            sampler.setSoapAction(soapAction.getText());
+            sampler.setXmlData(soapXml.getText());
         }
     }

@@ -78,11 +79,22 @@

         add(makeTitlePanel(), BorderLayout.NORTH);

-        urlField = new
JLabeledTextField(JMeterUtils.getResString("url"), 10);
+        VerticalPanel soapPanel = new VerticalPanel();
+        protocolField = new
JLabeledTextField(JMeterUtils.getResString("protocol"));
+        soapPanel.add(protocolField);
+        domainField = new
JLabeledTextField(JMeterUtils.getResString("web_server_domain"));
+        soapPanel.add(domainField);
+        portField = new
JLabeledTextField(JMeterUtils.getResString("web_server_port"));
+        soapPanel.add(portField);
+        pathField = new
JLabeledTextField(JMeterUtils.getResString("path"));
+        soapPanel.add(pathField);
+        soapAction = new JLabeledTextField("SOAP Action:");
+        soapPanel.add(soapAction);
+
         soapXml = new
JLabeledTextArea(JMeterUtils.getResString("soap_data_title"), null);

         JPanel mainPanel = new JPanel(new BorderLayout());
-        mainPanel.add(urlField, BorderLayout.NORTH);
+        mainPanel.add(soapPanel, BorderLayout.NORTH);
         mainPanel.add(soapXml, BorderLayout.CENTER);

         add(mainPanel, BorderLayout.CENTER);
@@ -92,12 +104,12 @@
     {
         super.configure(el);
         SoapSampler sampler = (SoapSampler) el;
-        try
-        {
-            urlField.setText(sampler.getUrl().toString());
-        }
-        catch (MalformedURLException e)
-        {}
+        protocolField.setText(sampler.getProtocol());
+        domainField.setText(sampler.getDomain());
+        if ((sampler.getPort() > 0) && (sampler.getPort() != 80))
+            portField.setText(String.valueOf(sampler.getPort()));
+        pathField.setText(sampler.getPath());
+        soapAction.setText(sampler.getSoapAction());
         soapXml.setText(sampler.getXmlData());
     }

--- SoapSampler.java.orig       2003-06-03 10:53:12.000000000 -0700
+++ SoapSampler.java    2003-06-03 10:59:50.000000000 -0700
@@ -16,6 +16,7 @@
 public class SoapSampler extends HTTPSampler
 {
        public static final String XML_DATA = "HTTPSamper.xml_data";
+       public static final String SOAP_ACTION =
"HTTPSamper.soap_action";

        public void setXmlData(String data)
        {
@@ -27,6 +28,16 @@
                return getPropertyAsString(XML_DATA);
        }

+       public void setSoapAction(String soapAction)
+       {
+               setProperty(SOAP_ACTION,soapAction);
+       }
+
+       public String getSoapAction()
+       {
+               return getPropertyAsString(SOAP_ACTION);
+       }
+
        /****************************************
         * Set the HTTP request headers in preparation to open the
connection
         * and sending the POST data:
@@ -37,10 +48,12 @@
        public void setPostHeaders(URLConnection connection)
                        throws IOException
        {
-
((HttpURLConnection)connection).setRequestMethod("POST");
                connection.setRequestProperty("Content-length", "" +
getXmlData().length());
                connection.setRequestProperty("Content-type",
"text/xml");
+               connection.setRequestProperty("SOAPAction",
getSoapAction());
+
((HttpURLConnection)connection).setRequestMethod("POST");
                connection.setDoOutput(true);
+               connection.setDoInput(true);
        }

        /****************************************



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to