Waiting for engine...
Skip to main content

Protected WSDL retrieval

A WSDL for a SOAP web service may not be publicly accessible. This is often the case if the WSDL is customized for each user of the web service. If the WSDL is protected by an HTTP basic authentication or a simple form-based login authentication mechanism, then the connector can download the WSDL on-the-fly.

The Runtime is configured to handle cookies, so the connector only needs to log in before reading the WSDL.

  1. Extend the WSConnector class, override the createCacheKey() method, and ensure that the key includes all credentials required for login.

  2. Extend the WSCache class and override the readWsdl() method:

Code sample
@Override
protected Definition readWsdl(WSDLReader reader)
throws WSDLException, IOException
{
// ... login to the service using the cached username/password ...
// assuming that login was successful, load the wsdl using the retrieved cookie(s)
return super.readWsdl(reader);
}

HTTP Auth-based access

  1. Follow step 1 in the previous example.

  2. Extend the WSCache class and override the readWsdl() method:

Code sample
@Override
protected Definition readWsdl(WSDLReader reader)
throws WSDLException, IOException
{
String wsdlUrlStr = getWsdlUrl();
HttpURLConnection wsdlUrlConn = (HttpURLConnection)new URL(wsdlUrlStr).openConnection();

// ... configure the url connection with any necessary auth credentials ...
// read the wsdl using the configured connection
InputStream wsdlStream = null;
try {
wsdlStream = wsdlUrlConn.getInputStream();
return reader.readWSDL(wsdlUrlStr, new InputSource(wsdlStream));
} finally {
IOUtil.closeQuietly(wsdlStream);
}
}
On this Page