Author: jason.greene(a)jboss.com
Date: 2007-03-22 14:56:39 -0400 (Thu, 22 Mar 2007)
New Revision: 2664
Modified:
trunk/jbossws-core/src/java/javax/xml/soap/SOAPConnection.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
Log:
Add support for SOAPConnection.get()
Wrap SOAPExceptions in the unmarshaller so that they can be thrown by remoting
Modified: trunk/jbossws-core/src/java/javax/xml/soap/SOAPConnection.java
===================================================================
--- trunk/jbossws-core/src/java/javax/xml/soap/SOAPConnection.java 2007-03-22 18:20:09 UTC
(rev 2663)
+++ trunk/jbossws-core/src/java/javax/xml/soap/SOAPConnection.java 2007-03-22 18:56:39 UTC
(rev 2664)
@@ -63,11 +63,7 @@
* @throws SOAPException if there is a SOAP error
* @since SAAJ 1.3
*/
- public SOAPMessage get(Object to) throws SOAPException
- {
- //TODO: SAAJ 1.3
- throw new NotImplementedException();
- }
+ public abstract SOAPMessage get(Object to) throws SOAPException;
/** Closes this SOAPConnection object.
*
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2007-03-22
18:20:09 UTC (rev 2663)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2007-03-22
18:56:39 UTC (rev 2664)
@@ -23,6 +23,7 @@
// $Id$
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.util.HashMap;
@@ -106,23 +107,37 @@
*/
public SOAPMessage call(SOAPMessage reqMessage, Object endpoint) throws SOAPException
{
+ if (reqMessage == null)
+ throw new IllegalArgumentException("Given SOAPMessage cannot be
null");
return callInternal(reqMessage, endpoint, false);
}
/**
+ * Sends an HTTP GET request to an endpoint and blocks until a SOAP message is
received
+ */
+ public SOAPMessage get(Object endpoint) throws SOAPException
+ {
+ return callInternal(null, endpoint, false);
+ }
+
+ /**
* Sends the given message to the specified endpoint. This method is logically
* non blocking.
*/
public SOAPMessage callOneWay(SOAPMessage reqMessage, Object endpoint) throws
SOAPException
{
+ if (reqMessage == null)
+ throw new IllegalArgumentException("Given SOAPMessage cannot be
null");
return callInternal(reqMessage, endpoint, true);
}
- /** Sends the given message to the specified endpoint. */
+ /**
+ * Sends the given message to the specified endpoint.
+ *
+ * A null reqMessage signifies a HTTP GET request.
+ */
private SOAPMessage callInternal(SOAPMessage reqMessage, Object endpoint, boolean
oneway) throws SOAPException
{
- if (reqMessage == null)
- throw new IllegalArgumentException("Given SOAPMessage cannot be
null");
if (endpoint == null)
throw new IllegalArgumentException("Given endpoint cannot be null");
@@ -160,7 +175,7 @@
XOPContext.eagerlyCreateAttachments();
// save object model changes
- if (reqMessage.saveRequired())
+ if (reqMessage != null && reqMessage.saveRequired())
reqMessage.saveChanges();
// setup remoting client
@@ -170,7 +185,7 @@
try
{
// debug the outgoing message
- if (msgLog.isTraceEnabled())
+ if (reqMessage != null && msgLog.isTraceEnabled())
{
SOAPEnvelope soapReqEnv = reqMessage.getSOAPPart().getEnvelope();
String envStr = SOAPElementWriter.writeElement((SOAPElementImpl)soapReqEnv,
true);
@@ -192,7 +207,11 @@
}
catch (RuntimeException rte)
{
- if (timeout != null && rte.getCause() instanceof
SocketTimeoutException)
+ Throwable cause = rte.getCause();
+ // The CTS expects only SOAPException to be thrown.
+ if (cause instanceof IOException && cause.getCause() instanceof
SOAPException)
+ throw cause.getCause();
+ else if (timeout != null && cause instanceof SocketTimeoutException)
throw new WSTimeoutException("Timeout after: " + timeout +
"ms", new Long(timeout.toString()));
else throw rte;
}
@@ -282,6 +301,68 @@
private Map<String, Object> createRemotingMetaData(SOAPMessage reqMessage, Map
callProps) throws SOAPException
{
+
+ Map<String, Object> metadata = new HashMap<String, Object>();
+
+ // We need to unmarshall faults (HTTP 500)
+ // metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); //
since 2.0.0.GA
+ metadata.put("NoThrowOnError", "true");
+
+ if (reqMessage != null)
+ populateHeaders(reqMessage, metadata);
+ else
+ metadata.put("TYPE", "GET");
+
+ if (callProps != null)
+ {
+ Iterator it = callProps.entrySet().iterator();
+
+ // Get authentication type, default to BASIC authetication
+ String authType = (String)callProps.get(StubExt.PROPERTY_AUTH_TYPE);
+ if (authType == null)
+ authType = StubExt.PROPERTY_AUTH_TYPE_BASIC;
+
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry)it.next();
+ String key = (String)entry.getKey();
+ Object val = entry.getValue();
+
+ // pass properties to remoting meta data
+ if (metadataMap.containsKey(key))
+ {
+ String remotingKey = metadataMap.get(key);
+ if ("http.basic.username".equals(remotingKey) ||
"http.basic.password".equals(remotingKey))
+ {
+ if (authType.equals(StubExt.PROPERTY_AUTH_TYPE_BASIC))
+ {
+ metadata.put(remotingKey, val);
+ }
+ else
+ {
+ log.warn("Ignore '" + key + "' with auth
typy: " + authType);
+ }
+ }
+ else
+ {
+ metadata.put(remotingKey, val);
+ }
+ }
+
+ // pass properties to remoting client config
+ if (configMap.containsKey(key))
+ {
+ String remotingKey = configMap.get(key);
+ config.put(remotingKey, val);
+ }
+ }
+ }
+
+ return metadata;
+ }
+
+ private void populateHeaders(SOAPMessage reqMessage, Map<String, Object>
metadata)
+ {
// R2744 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
// with a quoted value equal to the value of the soapAction attribute of
// soapbind:operation, if present in the corresponding WSDL description.
@@ -308,12 +389,6 @@
mimeHeaders.setHeader("SOAPAction", "\"\"");
}
- Map<String, Object> metadata = new HashMap<String, Object>();
-
- // We need to unmarshall faults (HTTP 500)
- // metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); //
since 2.0.0.GA
- metadata.put("NoThrowOnError", "true");
-
Properties props = new Properties();
metadata.put("HEADER", props);
@@ -345,52 +420,5 @@
props.put(header.getName(), header.getValue());
}
}
-
- if (callProps != null)
- {
- Iterator it = callProps.entrySet().iterator();
-
- // Get authentication type, default to BASIC authetication
- String authType = (String)callProps.get(StubExt.PROPERTY_AUTH_TYPE);
- if (authType == null)
- authType = StubExt.PROPERTY_AUTH_TYPE_BASIC;
-
- while (it.hasNext())
- {
- Map.Entry entry = (Map.Entry)it.next();
- String key = (String)entry.getKey();
- Object val = entry.getValue();
-
- // pass properties to remoting meta data
- if (metadataMap.containsKey(key))
- {
- String remotingKey = metadataMap.get(key);
- if ("http.basic.username".equals(remotingKey) ||
"http.basic.password".equals(remotingKey))
- {
- if (authType.equals(StubExt.PROPERTY_AUTH_TYPE_BASIC))
- {
- metadata.put(remotingKey, val);
- }
- else
- {
- log.warn("Ignore '" + key + "' with auth
typy: " + authType);
- }
- }
- else
- {
- metadata.put(remotingKey, val);
- }
- }
-
- // pass properties to remoting client config
- if (configMap.containsKey(key))
- {
- String remotingKey = configMap.get(key);
- config.put(remotingKey, val);
- }
- }
- }
-
- return metadata;
}
}
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2007-03-22
18:20:09 UTC (rev 2663)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2007-03-22
18:56:39 UTC (rev 2664)
@@ -78,7 +78,9 @@
catch (SOAPException e)
{
log.error("Cannot unmarshall SOAPMessage", e);
- throw new IOException(e.toString());
+ IOException e2 = new IOException(e.toString());
+ e2.initCause(e);
+ throw e2;
}
}