Methods Summary |
---|
private java.net.HttpURLConnection | createConnection(java.net.URL url)
return (HttpURLConnection) url.openConnection();
|
public java.io.InputStream | makeGetCall(java.lang.String address)This method is called by ServiceDescriptorImpl when a
metadata response contains a mex location element. The
location element contains an address of a metadata document
that can be retrieved with an HTTP GET call.
final URL url = new URL(address);
final HttpURLConnection conn = createConnection(url);
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded"); // taken from wsimport
try {
return conn.getInputStream();
} catch (IOException ioe) {
outputErrorStream(conn);
// this exception is caught within the mex code and is logged there
throw ioe;
}
|
private void | outputErrorStream(java.net.HttpURLConnection conn)
final InputStream error = conn.getErrorStream();
if (error != null) {
final BufferedReader reader = new BufferedReader(
new InputStreamReader(error));
try {
if (logger.isLoggable(ERROR_LOG_LEVEL)) {
logger.log(ERROR_LOG_LEVEL,
MessagesMessages.MEX_0010_ERROR_FROM_SERVER());
String line = reader.readLine();
while (line != null) {
logger.log(ERROR_LOG_LEVEL, line);
line = reader.readLine();
}
logger.log(ERROR_LOG_LEVEL,
MessagesMessages.MEX_0011_ERROR_FROM_SERVER_END());
}
} catch (IOException ioe) {
// This exception has no more impact.
logger.log(ERROR_LOG_LEVEL,
MessagesMessages.MEX_0012_READING_ERROR_STREAM_FAILURE(),
ioe);
} finally {
try {
reader.close();
} catch (IOException ex) {
// This exception has no more impact.
logger.log(ERROR_LOG_LEVEL,
MessagesMessages.MEX_0013_CLOSING_ERROR_STREAM_FAILURE(),
ex);
}
}
}
|
java.io.InputStream | post(java.lang.String request, java.lang.String address, java.lang.String contentType)Makes the request to the service. It is expected that this
method may throw IOException several times before metadata
is returned successfully.
final URL url = new URL(address);
final HttpURLConnection conn = createConnection(url);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", contentType);
conn.setRequestProperty("SOAPAction", GET_REQUEST);
final Writer writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(request);
writer.flush();
try {
return conn.getInputStream();
} catch (IOException ioe) {
outputErrorStream(conn);
// this exception is caught within the mex code and is logged there
throw ioe;
} finally {
writer.close();
}
|