Apache JMeter

org.apache.jmeter.protocol.http.util
Class WSDLHelper

java.lang.Object
  extended by org.apache.jmeter.protocol.http.util.WSDLHelper

public class WSDLHelper
extends java.lang.Object

For now I use DOM for WSDLHelper, but it would be more efficient to use JAXB to generate an object model for WSDL and use it to perform serialization and deserialization. It also makes it easier to traverse the WSDL to get necessary information.

Created on: Jun 3, 2003


Field Summary
protected  java.util.HashMap ACTIONS
           
protected  AuthManager AUTH
           
protected  java.net.URL bindingURL
           
 java.lang.String BINDNAME
           
protected  java.net.URLConnection CONN
           
protected  java.lang.String SOAPBINDING
           
protected  java.lang.Object[] SOAPOPS
           
protected  org.w3c.dom.Document WSDLDOC
           
protected  java.net.URL WSDLURL
          -------------------------------------------- The members used by the class to do its work --------------------------------------------
 
Constructor Summary
WSDLHelper(java.lang.String url)
          Default constructor takes a string URL
WSDLHelper(java.lang.String url, AuthManager auth)
           
 
Method Summary
protected  void buildDocument()
          Method is used internally to parse the InputStream and build the document using javax.xml.parser API.
protected  void close()
          We try to close the connection to make sure it doesn't hang around.
protected  void connect()
          Method is used internally to connect to the URL.
 java.lang.String getBinding()
          Returns the binding point for the webservice.
 java.lang.String getBindingHost()
          Return the host in the WSDL binding address
 java.lang.String getBindingPath()
          Return the path in the WSDL for the binding address
 int getBindingPort()
          Return the port for the binding address
 java.lang.Object[] getOperations()
          Look at the bindings with soap operations and get the soap operations.
 java.lang.String getProtocol()
          Return the protocol from the URL. this is needed, so that HTTPS works as expected.
 java.lang.String getSoapAction(java.lang.String key)
          Return the soap action matching the operation name.
 java.lang.Object[] getSOAPBindings()
          Method will look at the binding nodes and see if the first child is a soap:binding.
 java.net.URL getURL()
          Returns the URL
 java.lang.String[] getWebMethods()
          Get a list of the web methods as a string array.
 org.w3c.dom.Document getWSDLDocument()
          Get the wsdl document.
static void main(java.lang.String[] args)
          Simple test for the class uses bidbuy.wsdl from Apache's soap driver examples.
 void parse()
          Call this method to retrieve the WSDL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WSDLURL

protected java.net.URL WSDLURL
-------------------------------------------- The members used by the class to do its work --------------------------------------------


CONN

protected java.net.URLConnection CONN

WSDLDOC

protected org.w3c.dom.Document WSDLDOC

SOAPBINDING

protected java.lang.String SOAPBINDING

BINDNAME

public java.lang.String BINDNAME

bindingURL

protected java.net.URL bindingURL

SOAPOPS

protected java.lang.Object[] SOAPOPS

ACTIONS

protected java.util.HashMap ACTIONS

AUTH

protected AuthManager AUTH
Constructor Detail

WSDLHelper

public WSDLHelper(java.lang.String url)
           throws java.net.MalformedURLException
Default constructor takes a string URL

Throws:
java.net.MalformedURLException

WSDLHelper

public WSDLHelper(java.lang.String url,
                  AuthManager auth)
           throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException
Method Detail

getURL

public java.net.URL getURL()
Returns the URL

Returns:
the URL

getProtocol

public java.lang.String getProtocol()
Return the protocol from the URL. this is needed, so that HTTPS works as expected.


getBindingHost

public java.lang.String getBindingHost()
Return the host in the WSDL binding address


getBindingPath

public java.lang.String getBindingPath()
Return the path in the WSDL for the binding address


getBindingPort

public int getBindingPort()
Return the port for the binding address


getBinding

public java.lang.String getBinding()
Returns the binding point for the webservice. Right now it naively assumes there's only one binding point with numerous soap operations.

Returns:
String

connect

protected void connect()
                throws java.io.IOException
Method is used internally to connect to the URL. It's protected; therefore external classes should use parse to get the resource at the given location.

Throws:
java.io.IOException

close

protected void close()
We try to close the connection to make sure it doesn't hang around.


buildDocument

protected void buildDocument()
                      throws javax.xml.parsers.ParserConfigurationException,
                             java.io.IOException,
                             org.xml.sax.SAXException
Method is used internally to parse the InputStream and build the document using javax.xml.parser API.

Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

parse

public void parse()
           throws WSDLException
Call this method to retrieve the WSDL. This method must be called, otherwise a connection to the URL won't be made and the stream won't be parsed.

Throws:
WSDLException

getWebMethods

public java.lang.String[] getWebMethods()
Get a list of the web methods as a string array.


getSoapAction

public java.lang.String getSoapAction(java.lang.String key)
Return the soap action matching the operation name.


getWSDLDocument

public org.w3c.dom.Document getWSDLDocument()
Get the wsdl document.


getSOAPBindings

public java.lang.Object[] getSOAPBindings()
Method will look at the binding nodes and see if the first child is a soap:binding. If it is, it adds it to an array.

Returns:
Node[]

getOperations

public java.lang.Object[] getOperations()
Look at the bindings with soap operations and get the soap operations. Since WSDL may describe multiple bindings and each binding may have multiple soap operations, we iterate through the binding nodes with a first child that is a soap binding. If a WSDL doesn't use the same formatting convention, it is possible we may not get a list of all the soap operations. If that is the case, getSOAPBindings() will need to be changed. I should double check the WSDL spec to see what the official requirement is. Another option is to get all operation nodes and check to see if the first child is a soap:operation. The benefit of not getting all operation nodes is WSDL could contain duplicate operations that are not SOAP methods. If there are a large number of methods and half of them are HTTP operations, getting all operations could slow things down.

Returns:
Node[]

main

public static void main(java.lang.String[] args)
Simple test for the class uses bidbuy.wsdl from Apache's soap driver examples.

Parameters:
args -

Apache JMeter

Copyright © 1998-2010 Apache Software Foundation. All Rights Reserved.