Author: chris.laprun(a)jboss.com
Date: 2007-03-03 14:22:03 -0500 (Sat, 03 Mar 2007)
New Revision: 6504
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
Log:
Work on JBPORTAL-1279 but does not work properly. Committing to keep work for future
reference but will commit new version using openStream for BETA1 scope.
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-03-03
19:08:28 UTC (rev 6503)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-03-03
19:22:03 UTC (rev 6504)
@@ -35,8 +35,10 @@
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLLocator;
import javax.xml.namespace.QName;
+import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
@@ -54,8 +56,6 @@
private String wsdlDefinitionURL;
- private boolean available;
-
private static final String WSRP_URN = "urn:oasis:names:tc:wsrp:v1:wsdl";
private static final String DEFAULT_SERVICE_NAME = "WSRPService";
@@ -65,6 +65,7 @@
private static final String BASE = "base"; // some WSDL use WSRPBaseService
instead of Markup
private static final String MANAGEMENT = "management";
private static final String REGISTRATION = "registration";
+ private boolean available;
public String getWsdlDefinitionURL()
@@ -98,10 +99,9 @@
}
}
-
public boolean isAvailable()
{
- return available && super.isAvailable();
+ return available;
}
private void initServices() throws MalformedURLException
@@ -197,13 +197,44 @@
public InputSource getBaseInputSource()
{
log.info("getBaseInputSource [wsdlUrl=" + wsdlURL + "]");
+
+ // use 1 second time outs and remember previous values
+ String connectTimeOut =
System.setProperty("sun.net.client.defaultConnectTimeout", "1000");
+ String readTimeOut =
System.setProperty("sun.net.client.defaultReadTimeout", "1000");
+
try
{
- Socket socket = new Socket(wsdlURL.getHost(), wsdlURL.getPort());
- socket.setSoTimeout(10000);
+ int port = wsdlURL.getPort();
+ boolean isSecure = false;
+ // check if we use default ports
+ if (port == -1)
+ {
+ port = wsdlURL.getDefaultPort();
+ String protocol = wsdlURL.getProtocol();
+ if ("https".equals(protocol))
+ {
+ isSecure = true;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown protocol: " +
protocol);
+ }
+ }
-// url.setReadTimeout(10000); // would be nice but 1.5 only! :(
- InputStream is = Tools.safeBufferedWrapper(socket.getInputStream());
+ String host = wsdlURL.getHost();
+ Socket socket = new Socket(host, port);
+ socket.setSoTimeout(1000);
+
+ // Create a DataInputStream for reading from socket
+ DataInputStream din = new DataInputStream(socket.getInputStream());
+
+ // Create a PrintStream for writing to socket
+ PrintStream pout = new PrintStream(socket.getOutputStream());
+
+ // Print get request
+ pout.print("GET " + wsdlURL.getFile() + " HTTP" +
(isSecure ? "S" : "") + "/1.1\n\n");
+
+ InputStream is = Tools.safeBufferedWrapper(din);
if (is == null)
{
String message = "Cannot retrieve WSDL: '" + wsdlURL +
"' is not a valid URL.";
@@ -219,6 +250,13 @@
log.info(message);
throw new RuntimeException(message);
}
+ finally
+ {
+ // restore time outs
+ System.setProperty("sun.net.client.defaultConnectTimeout",
connectTimeOut);
+ System.setProperty("sun.net.client.defaultReadTimeout",
readTimeOut);
+ }
+
}
public String getBaseURI()
Show replies by date