woolfel     2005/05/31 18:28:43

  Modified:    src/protocol/http/org/apache/jmeter/protocol/http/control/gui
                        WebServiceSamplerGui.java
               src/protocol/http/org/apache/jmeter/protocol/http/util
                        WSDLHelper.java
  Log:
  hopefully these changes will allow the webservice sampler to work with the 
functions.
  the gui now has separate input for domain, port and path, just like 
httpsampler. thanks to
  seb for pointing that out. also fixed a bug with the WSDLHelper when the wsdl 
doesn't
  using binding name.
  
  peter
  
  Revision  Changes    Path
  1.16      +61 -103   
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/WebServiceSamplerGui.java
  
  Index: WebServiceSamplerGui.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/gui/WebServiceSamplerGui.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- WebServiceSamplerGui.java 2 Apr 2005 23:21:49 -0000       1.15
  +++ WebServiceSamplerGui.java 1 Jun 2005 01:28:43 -0000       1.16
  @@ -21,8 +21,6 @@
   import java.awt.Dimension;
   import java.awt.Font;
   import java.awt.event.ActionEvent;
  -import java.net.MalformedURLException;
  -import java.net.URL;
   
   import javax.swing.JButton;
   import javax.swing.JCheckBox;
  @@ -62,8 +60,12 @@
       implements java.awt.event.ActionListener
   {
   
  -    JLabeledTextField urlField =
  -        new JLabeledTextField(JMeterUtils.getResString("url"));
  +    JLabeledTextField domain =
  +        new JLabeledTextField(JMeterUtils.getResString("web_server_domain"));
  +    JLabeledTextField port = 
  +        new JLabeledTextField(JMeterUtils.getResString("web_server_port"));
  +    JLabeledTextField path = 
  +        new JLabeledTextField(JMeterUtils.getResString("path"));
       JLabeledTextField soapAction =
           new JLabeledTextField(
               JMeterUtils.getResString("webservice_soap_action"));
  @@ -170,74 +172,54 @@
       {
           WebServiceSampler sampler = new WebServiceSampler();
           this.configureTestElement(sampler);
  -        try
  -        {
  -            URL url = new URL(urlField.getText());
  -            sampler.setDomain(url.getHost());
  -            if (url.getPort() != -1)
  -            {
  -                sampler.setPort(url.getPort());
  -            }
  -            else
  -            {
  -                sampler.setPort(80);
  -            }
  -            sampler.setProtocol(url.getProtocol());
  -            sampler.setMethod(HTTPSamplerBase.POST);
  -            sampler.setPath(url.getPath());
  -            sampler.setSoapAction(soapAction.getText());
  -            sampler.setXmlData(soapXml.getText());
  -            sampler.setXmlFile(soapXmlFile.getFilename());
  -            sampler.setXmlPathLoc(randomXmlFile.getText());
  -            sampler.setMemoryCache(memCache.isSelected());
  -            sampler.setReadResponse(readResponse.isSelected());
  -            sampler.setUseProxy(useProxy.isSelected());
  -            sampler.setProxyHost(proxyHost.getText());
  -            sampler.setProxyPort(proxyPort.getText());
  -        }
  -        catch (MalformedURLException e)
  -        {
  +        sampler.setDomain(domain.getText());
  +        if (port.getText() != null && port.getText().length() > 0){
  +            sampler.setPort(Integer.parseInt(port.getText()));
  +        } else {
  +            sampler.setPort(80);
           }
  -        return sampler;
  +        sampler.setPath(path.getText());
  +        sampler.setMethod(HTTPSamplerBase.POST);
  +        sampler.setSoapAction(soapAction.getText());
  +        sampler.setXmlData(soapXml.getText());
  +        sampler.setXmlFile(soapXmlFile.getFilename());
  +        sampler.setXmlPathLoc(randomXmlFile.getText());
  +        sampler.setMemoryCache(memCache.isSelected());
  +        sampler.setReadResponse(readResponse.isSelected());
  +        sampler.setUseProxy(useProxy.isSelected());
  +        sampler.setProxyHost(proxyHost.getText());
  +        sampler.setProxyPort(proxyPort.getText());
  +
  +             return sampler;
       }
   
       /**
  -     * Modifies a given TestElement to mirror the data in the gui components.
  -     * @see 
org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
  -     */
  +      * Modifies a given TestElement to mirror the data in the gui 
components.
  +      * 
  +      * @see 
org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
  +      */
       public void modifyTestElement(TestElement s)
       {
           WebServiceSampler sampler = (WebServiceSampler) s;
           this.configureTestElement(sampler);
  -        try
  -        {
  -            URL url = new URL(urlField.getText());
  -            sampler.setDomain(url.getHost());
  -            if (url.getPort() != -1)
  -            {
  -                sampler.setPort(url.getPort());
  -            }
  -            else
  -            {
  -                sampler.setPort(80);
  -            }
  -                     sampler.setWsdlURL(wsdlField.getText());
  -            sampler.setProtocol(url.getProtocol());
  -            sampler.setMethod(HTTPSamplerBase.POST);
  -            sampler.setPath(url.getPath());
  -            sampler.setSoapAction(soapAction.getText());
  -            sampler.setXmlData(soapXml.getText());
  -            sampler.setXmlFile(soapXmlFile.getFilename());
  -            sampler.setXmlPathLoc(randomXmlFile.getText());
  -            sampler.setMemoryCache(memCache.isSelected());
  -            sampler.setReadResponse(readResponse.isSelected());
  -                     sampler.setUseProxy(useProxy.isSelected());
  -                     sampler.setProxyHost(proxyHost.getText());
  -                     sampler.setProxyPort(proxyPort.getText());
  -        }
  -        catch (MalformedURLException e)
  -        {
  +        sampler.setDomain(domain.getText());
  +        if (port.getText() != null && port.getText().length() > 0){
  +            sampler.setPort(Integer.parseInt(port.getText()));
  +        } else {
  +            sampler.setPort(80);
           }
  +        sampler.setPath(path.getText());
  +        sampler.setWsdlURL(wsdlField.getText());
  +        sampler.setMethod(HTTPSamplerBase.POST);
  +        sampler.setSoapAction(soapAction.getText());
  +        sampler.setXmlData(soapXml.getText());
  +        sampler.setXmlFile(soapXmlFile.getFilename());
  +        sampler.setXmlPathLoc(randomXmlFile.getText());
  +        sampler.setMemoryCache(memCache.isSelected());
  +        sampler.setReadResponse(readResponse.isSelected());
  +             sampler.setUseProxy(useProxy.isSelected());
  +        sampler.setProxyHost(proxyHost.getText());
  +        sampler.setProxyPort(proxyPort.getText());
       }
   
       /**
  @@ -291,7 +273,9 @@
           listPanel.add(selectButton);
           selectButton.addActionListener(this);
   
  -        mainPanel.add(urlField);
  +        mainPanel.add(domain);
  +        mainPanel.add(port);
  +        mainPanel.add(path);
           mainPanel.add(soapAction);
           // OPTIONAL TASKS
           // we create a preferred size for the soap text area
  @@ -337,27 +321,10 @@
           super.configure(el);
           WebServiceSampler sampler = (WebServiceSampler) el;
           wsdlField.setText(sampler.getWsdlURL());
  -        try
  -        {
  -            // only set the URL if the host is not null
  -            if (sampler.getUrl() != null && sampler.getUrl().getHost() != 
null)
  -            {
  -                urlField.setText(sampler.getUrl().toString());
  -            }
  -            soapAction.setText(sampler.getSoapAction());
  -        }
  -        catch (MalformedURLException e)
  -        {
  -        }
  -        // we build the string URL
  -        int port = sampler.getPort();
  -        String strUrl = sampler.getProtocol() + "://" + sampler.getDomain();
  -        if (port != -1 && port != 80)
  -        {
  -            strUrl += ":" + sampler.getPort();
  -        }
  -        strUrl += sampler.getPath() + "?" + sampler.getQueryString();
  -        urlField.setText(strUrl);
  +        domain.setText(sampler.getDomain());
  +        port.setText(String.valueOf(sampler.getPort()));
  +        path.setText(sampler.getPath());
  +        soapAction.setText(sampler.getSoapAction());
           soapXml.setText(sampler.getXmlData());
           soapXmlFile.setFilename(sampler.getXmlFile());
           randomXmlFile.setText(sampler.getXmlPathLoc());
  @@ -388,22 +355,13 @@
       {
           if (HELPER.getBinding() != null)
           {
  -            this.urlField.setText(HELPER.getBinding());
  -        }
  -        else
  -        {
  -            StringBuffer buf = new StringBuffer();
  -            buf.append("http://"; + HELPER.getURL().getHost());
  -            if (HELPER.getURL().getPort() != -1)
  -            {
  -                buf.append(":" + HELPER.getURL().getPort());
  -            }
  -            else
  -            {
  -                buf.append(":" + 80);
  +            this.domain.setText(HELPER.getURL().getHost());
  +            if (HELPER.getURL().getPort() > 0){
  +                this.port.setText(String.valueOf(HELPER.getURL().getPort()));
  +            } else {
  +                this.port.setText("80");
               }
  -            buf.append(HELPER.getURL().getPath());
  -            this.urlField.setText(buf.toString());
  +            this.path.setText(HELPER.getURL().getPath());
           }
           this.soapAction.setText(
               HELPER.getSoapAction(this.wsdlMethods.getText()));
  @@ -469,7 +427,7 @@
           }
           else
           {
  -            if (this.urlField.getText() != null)
  +            if (this.domain.getText() != null)
               {
                   String[] wsdlData = browseWSDL(wsdlField.getText());
                   if (wsdlData != null)
  
  
  
  1.10      +18 -20    
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/util/WSDLHelper.java
  
  Index: WSDLHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/util/WSDLHelper.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- WSDLHelper.java   14 May 2005 01:33:08 -0000      1.9
  +++ WSDLHelper.java   1 Jun 2005 01:28:43 -0000       1.10
  @@ -121,25 +121,22 @@
               {
                   Element pnode = (Element) ports.item(idx);
                   String portname = pnode.getAttribute("name");
  -                // got the port name. now check it against the
  -                // binding name.
  -                if (this.BINDNAME.indexOf(portname) > -1)
  -                {
  -                    NodeList servlist =
  -                        pnode.getElementsByTagName("soap:address");
  -                    // check wsdlsoap
  -                    if (servlist.getLength() == 0){
  -                                             servlist =
  -                                             
pnode.getElementsByTagName("wsdlsoap:address");
  -                    }
  -                    if (servlist.getLength() == 0){
  -                        servlist =
  +                // used to check binding, but now it doesn't. it was 
  +                // failing when wsdl did not using binding as expected
  +                NodeList servlist =
  +                    pnode.getElementsByTagName("soap:address");
  +                // check wsdlsoap
  +                if (servlist.getLength() == 0){
  +                    servlist =
  +                        pnode.getElementsByTagName("wsdlsoap:address");
  +                }
  +                if (servlist.getLength() == 0){
  +                    servlist =
                           pnode.getElementsByTagName("SOAP:address");
  -                    }
  -                    Element addr = (Element) servlist.item(0);
  -                    this.SOAPBINDING = addr.getAttribute("location");
  -                    return this.SOAPBINDING;
                   }
  +                Element addr = (Element) servlist.item(0);
  +                this.SOAPBINDING = addr.getAttribute("location");
  +                return this.SOAPBINDING;
               }
               return null;
           }
  @@ -406,7 +403,7 @@
                        //      new 
WSDLHelper("http://localhost/WSTest/WSTest.asmx?WSDL";);
                        //      new WSDLHelper("http://localhost/AxisWSDL.xml";);
                        //      new 
WSDLHelper("http://localhost/test-setup.xml";);
  -            new WSDLHelper("http://localhost:8080/gsoap.wsdl";);
  +            new 
WSDLHelper("http://services.bio.ifi.lmu.de:1046/prothesaurus/services/BiologicalNameService?wsdl";);
               long start = System.currentTimeMillis();
               help.parse();
               String[] methods = help.getWebMethods();
  @@ -416,6 +413,7 @@
                   System.out.println("method name: " + methods[idx]);
               }
               System.out.println("service url: " + help.getBinding());
  +            System.out.println("port=" + help.getURL().getPort());
           }
           catch (Exception exception)
           {
  
  
  

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

Reply via email to