You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2006/12/08 21:21:23 UTC
svn commit: r484739 - in
/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core:
AbstractResourceClient.java routing/AbstractMessageHandler.java
routing/ReflectionMessageHandler.java
Author: danj
Date: Fri Dec 8 12:21:22 2006
New Revision: 484739
URL: http://svn.apache.org/viewvc?view=rev&rev=484739
Log:
Fix for MUSE-144 and 145 - empty SOAP bodies and custom SOAP headers in client.
Modified:
webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/AbstractResourceClient.java
webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/AbstractMessageHandler.java
webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/ReflectionMessageHandler.java
Modified: webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/AbstractResourceClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/AbstractResourceClient.java?view=diff&rev=484739&r1=484738&r2=484739
==============================================================================
--- webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/AbstractResourceClient.java (original)
+++ webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/AbstractResourceClient.java Fri Dec 8 12:21:22 2006
@@ -232,13 +232,38 @@
public Element invoke(String action, Element soapBody)
throws SoapFault
{
+ return invoke(action, soapBody, new Element[0]);
+ }
+
+
+ /**
+ *
+ * A generic method invocation mechanism - this can be used by other
+ * proxy methods as well as users in order to send arbitrary requests
+ * to a resource.
+ * <br><br>
+ * The parameters are wrapped in a SOAP envelope and sent to the
+ * destination using the proxy's SoapClient. If a SOAP Fault is returned,
+ * it is parsed and thrown as a SoapFault object.
+ * <br><br>
+ * The 'extra headers' provided must be outside of the WS-Addressing
+ * namespace - all WS-A headers are provided by the endpoint references
+ * for the source and destination.
+ *
+ * @return The SOAP Body from the response message, or null if there was
+ * no response.
+ *
+ */
+ public Element invoke(String action, Element soapBody, Element[] extraHeaders)
+ throws SoapFault
+ {
//
// SOAP bodies can technically have more than one element, so we
// have to wrap our data in an array
//
Element[] body = new Element[] { soapBody };
- Element[] response = getSoapClient().send(getSource(), getDestination(), action, body);
+ Element[] response = getSoapClient().send(getSource(), getDestination(), action, body, extraHeaders);
//
// no response at all is still a valid response
Modified: webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/AbstractMessageHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/AbstractMessageHandler.java?view=diff&rev=484739&r1=484738&r2=484739
==============================================================================
--- webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/AbstractMessageHandler.java (original)
+++ webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/AbstractMessageHandler.java Fri Dec 8 12:21:22 2006
@@ -75,23 +75,19 @@
* The WS-A Action URI this handler is used for.
*
* @param requestQName
- * The QName of the element that wraps parameters for incoming
- * requests. This class will use the request name in order to
- * create an appropriate response name.
- *
- * @see #createResponseName()
+ * The QName of the element that wraps parameters for incoming messages.
*
*/
protected AbstractMessageHandler(String actionURI, QName requestQName)
{
if (actionURI == null)
throw new NullPointerException(_MESSAGES.get("NullAction"));
-
- if (requestQName == null)
- throw new NullPointerException(_MESSAGES.get("NullRequestName"));
_actionURI = actionURI;
_requestQName = requestQName;
+
+ if (_requestQName != null)
+ _responseQName = createResponseName();
}
/**
@@ -109,16 +105,12 @@
* @see #getResponseName()
*
*/
- protected QName createResponseName()
+ private QName createResponseName()
{
QName request = getRequestName();
String uri = request.getNamespaceURI();
String name = request.getLocalPart();
- String prefix = request.getPrefix();
-
- if (prefix == null || prefix.length() == 0)
- return new QName(uri, name + "Response");
-
+ String prefix = request.getPrefix();
return new QName(uri, name + "Response", prefix);
}
@@ -139,9 +131,6 @@
public QName getResponseName()
{
- if (_responseQName == null)
- _responseQName = createResponseName();
-
return _responseQName;
}
Modified: webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/ReflectionMessageHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/ReflectionMessageHandler.java?view=diff&rev=484739&r1=484738&r2=484739
==============================================================================
--- webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/ReflectionMessageHandler.java (original)
+++ webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/routing/ReflectionMessageHandler.java Fri Dec 8 12:21:22 2006
@@ -161,23 +161,23 @@
throw new IllegalStateException(_MESSAGES.get("NoMethod"));
Class returnType = method.getReturnType();
+ QName returnValueName = getReturnValueName();
+ QName responseBodyName = getResponseName();
//
- // void methods -> empty element
+ // void methods & no output part = no soap body
//
- if (returnType == Void.TYPE)
- return XmlUtils.createElement(getResponseName());
+ if (returnType == Void.TYPE && responseBodyName == null)
+ return null;
+
+ Element responseXML = XmlUtils.createElement(responseBodyName);
//
- // for all non-void methods, we need to find the serializer
- // for the return type, then determine if it's an array and
- // deal with it accordingly
+ // void method w/ output part = empty element
//
- SerializerRegistry registry = SerializerRegistry.getInstance();
- Serializer ser = registry.getSerializer(returnType);
+ if (returnType == Void.TYPE)
+ return responseXML;
- QName returnValueName = getReturnValueName();
- QName responseBodyName = getResponseName();
boolean isComplex = true;
//
@@ -191,10 +191,17 @@
}
//
+ // for all non-void methods, we need to find the serializer
+ // for the return type, then determine if it's an array and
+ // deal with it accordingly
+ //
+ SerializerRegistry registry = SerializerRegistry.getInstance();
+ Serializer ser = registry.getSerializer(returnType);
+
+ //
// for complex types, we need a child element under the
// response body element
//
- Element responseXML = XmlUtils.createElement(responseBodyName);
Element valueXML = ser.toXML(result, returnValueName);
//
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org