You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2007/01/31 21:35:35 UTC
svn commit: r501978 [6/24] - in /webservices/axis2/branches/java/maven2: ./
etc/ modules/adb-codegen/ modules/adb-codegen/src/org/apache/axis2/schema/
modules/adb-codegen/src/org/apache/axis2/schema/template/
modules/adb-codegen/src/org/apache/axis2/sc...
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java Wed Jan 31 12:35:21 2007
@@ -20,6 +20,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -31,7 +32,6 @@
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -46,26 +46,56 @@
public class AsyncResponse implements Response {
private static final Log log = LogFactory.getLog(AsyncResponse.class);
+ private static final boolean debug = log.isDebugEnabled();
private boolean cancelled;
- private Object responseObj;
private MessageContext response;
private Map<String, Object> responseContext;
private Throwable fault;
private CountDownLatch latch;
+ private boolean cacheValid = false;
+ private Object cachedObject = null;
protected AsyncResponse() {
latch = new CountDownLatch(1);
}
protected void onError(Throwable t) {
+ if (debug) {
+ log.debug("AsyncResponse received a fault. Counting down latch.");
+ log.debug("Fault type = " + t.getClass());
+ }
+
fault = t;
latch.countDown();
+
+ // Probably a good idea to invalidate the cache
+ cacheValid = false;
+ cachedObject = null;
+
+ if (debug) {
+ log.debug("New latch count = [" + latch.getCount() + "]");
+ }
}
protected void onComplete(MessageContext mc) {
+ if (debug) {
+ log.debug("AsyncResponse received a MessageContext. Counting down latch.");
+ }
+
+ // A new message context invalidates the cached object retrieved
+ // during the last get()
+ if (response != mc) {
+ cachedObject = null;
+ cacheValid = false;
+ }
+
response = mc;
latch.countDown();
+
+ if (debug) {
+ log.debug("New latch count = [" + latch.getCount() + "]");
+ }
}
//-------------------------------------
@@ -73,66 +103,55 @@
//-------------------------------------
public boolean cancel(boolean mayInterruptIfRunning) {
- // If the task has been cancelled or has completed, then we must
- // return false because the call failed.
- // If the task has NOT been cancelled or completed, then we must
- // set the appropriate flags and not allow the task to continue.
-
- // TODO: Do we actually need to do some level of interrupt on the
- // processing in the get() call? If so, how?
- if (!cancelled || !(latch.getCount() == 0)) {
- return false;
- }
- else {
- //TODO: Implement the actual cancellation.
+ // The task cannot be cancelled if it has already been cancelled
+ // before or if it has already completed.
+ if (cancelled || latch.getCount() == 0) {
+ if (debug) {
+ log.debug("Cancellation attempt failed.");
+ }
return false;
}
+
+ cancelled = true;
+ return cancelled;
}
public Object get() throws InterruptedException, ExecutionException {
- // Wait for the response to come back
- latch.await();
-
- if (hasFault()) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
- }
- if (response == null) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
+ if (cancelled) {
+ throw new CancellationException("The task was cancelled.");
}
- // TODO: Check the type of the object to make sure it corresponds with
- // the parameterized generic type.
- if (responseObj == null) {
- if (log.isDebugEnabled()) {
- log.debug("Demarshalling the async response message");
- }
- responseObj = getResponseValueObject(response);
+ // Wait for the response to come back
+ if (debug) {
+ log.debug("Waiting for async response delivery.");
}
-
- return responseObj;
+ latch.await();
+
+ Object obj = processAsyncResponse(response);
+ return obj;
}
public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ if (cancelled) {
+ throw new CancellationException("The task was cancelled.");
+ }
+
// Wait for the response to come back
+ if (debug) {
+ log.debug("Waiting for async response delivery with time out.");
+ log.debug("timeout = " + timeout);
+ log.debug("units = " + unit);
+ }
latch.await(timeout, unit);
- if (hasFault()) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
- }
- if (response == null) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
+ // If the response still hasn't been returned, then we've timed out
+ // and must throw a TimeoutException
+ if (latch.getCount() > 0) {
+ throw new TimeoutException("The client timed out while waiting for an asynchronous response");
}
- // TODO: Check the type of the object to make sure it corresponds with
- // the parameterized generic type.
- if (responseObj == null) {
- if (log.isDebugEnabled()) {
- log.debug("Demarshalling the async response message");
- }
- responseObj = getResponseValueObject(response);
- }
-
- return responseObj;
+ Object obj = processAsyncResponse(response);
+ return obj;
}
public boolean isCancelled() {
@@ -144,9 +163,6 @@
}
public Map getContext() {
- if (responseContext == null) {
- responseContext = new HashMap<String, Object>();
- }
return responseContext;
}
@@ -157,6 +173,55 @@
return false;
}
+ private void initResponseContext() {
+ responseContext = new HashMap<String, Object>();
+ }
+
+ private Object processAsyncResponse(MessageContext ctx) throws ExecutionException {
+ if (hasFault()) {
+ throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
+ }
+ if (ctx == null) {
+ throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
+ }
+
+ // Avoid a reparse of the message. If we already retrived the object, return
+ // it now.
+ if (cacheValid) {
+ if (log.isDebugEnabled()) {
+ log.debug("Return object cached from last get()");
+ }
+ return cachedObject;
+ }
+
+ // TODO: Check the type of the object to make sure it corresponds with
+ // the parameterized generic type.
+ Object obj = null;
+ try {
+ if (debug) {
+ log.debug("Unmarshalling the async response message.");
+ }
+ obj = getResponseValueObject(ctx);
+ // Cache the object in case it is required again
+ cacheValid = true;
+ cachedObject = obj;
+ }
+ catch (Throwable t) {
+ if (debug) {
+ log.debug("An error occurred while processing the response");
+ }
+ throw new ExecutionException(ExceptionFactory.makeWebServiceException(t));
+ }
+
+ if (debug && obj != null) {
+ log.debug("Unmarshalled response object of type: " + obj.getClass());
+ }
+
+ initResponseContext();
+
+ return obj;
+ }
+
/**
* A default implementation of this method that returns the contents
* of the message in the form of an XML String. Subclasses should override
@@ -167,13 +232,9 @@
if (log.isDebugEnabled()) {
log.debug("Demarshalling response message as a String");
}
- try {
- Message msg = mc.getMessage();
- OMElement om = msg.getAsOMElement();
- return om.toString();
- } catch (MessageException e) {
- throw ExceptionFactory.makeWebServiceException(e);
- }
+ Message msg = mc.getMessage();
+ OMElement om = msg.getAsOMElement();
+ return om.toString();
}
}
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java Wed Jan 31 12:35:21 2007
@@ -18,10 +18,11 @@
*/
package org.apache.axis2.jaxws.client.async;
+import javax.xml.ws.WebServiceException;
+
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.util.Constants;
import org.apache.axis2.util.ThreadContextMigratorUtil;
import org.apache.commons.logging.Log;
@@ -30,9 +31,9 @@
public class AsyncUtils {
private static final Log log = LogFactory.getLog(AsyncUtils.class);
+ private static final boolean debug = log.isDebugEnabled();
- public static MessageContext createMessageContext(AsyncResult result) throws MessageException {
- boolean debug = log.isDebugEnabled();
+ public static MessageContext createMessageContext(AsyncResult result) throws WebServiceException {
MessageContext response = null;
if (debug) {
@@ -50,10 +51,10 @@
}
catch (Throwable t) {
if (debug) {
- log.debug("An error occurred in the ThreadContextMigratorUtil " + t);
+ log.debug(axisResponse.getLogIDString()+" An error occurred in the ThreadContextMigratorUtil " + t);
log.debug("...caused by " + t.getCause());
}
- ExceptionFactory.makeWebServiceException(t);
+ throw ExceptionFactory.makeWebServiceException(t);
}
return response;
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java Wed Jan 31 12:35:21 2007
@@ -24,11 +24,11 @@
import java.util.concurrent.FutureTask;
import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.WebServiceException;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,6 +43,7 @@
public class CallbackFuture extends Callback {
private static final Log log = LogFactory.getLog(CallbackFuture.class);
+ private static final boolean debug = log.isDebugEnabled();
private CallbackFutureTask cft;
private Executor executor;
@@ -61,15 +62,14 @@
@Override
public void onComplete(AsyncResult result) {
- boolean debug = log.isDebugEnabled();
if (debug) {
- log.debug("JAX-WS async response listener received the response");
+ log.debug("JAX-WS received the async response");
}
MessageContext response = null;
try {
response = AsyncUtils.createMessageContext(result);
- } catch (MessageException e) {
+ } catch (WebServiceException e) {
cft.setError(e);
if (debug) {
log.debug("An error occured while processing the async response. " + e.getMessage());
@@ -108,6 +108,7 @@
class CallbackFutureTask implements Callable {
private static final Log log = LogFactory.getLog(CallbackFutureTask.class);
+ private static final boolean debug = log.isDebugEnabled();
AsyncResponse response;
MessageContext responseMsgCtx;
@@ -136,10 +137,20 @@
response.onError(error);
}
- if (log.isDebugEnabled()) {
- log.debug("Calling JAX-WS AsyncHandler with the Response object");
+ try {
+ if (debug) {
+ log.debug("Calling JAX-WS AsyncHandler with the Response object");
+ log.debug("AyncHandler class: " + handler.getClass());
+ }
+ handler.handleResponse(response);
+ }
+ catch (Throwable t) {
+ if (debug) {
+ log.debug("An error occured while invoking the callback object.");
+ log.debug("Error: " + t.getMessage());
+ }
}
- handler.handleResponse(response);
+
return null;
}
}
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java Wed Jan 31 12:35:21 2007
@@ -18,10 +18,11 @@
*/
package org.apache.axis2.jaxws.client.async;
+import javax.xml.ws.WebServiceException;
+
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,7 +46,7 @@
MessageContext responseMsgCtx = null;
try {
responseMsgCtx = AsyncUtils.createMessageContext(result);
- } catch (MessageException e) {
+ } catch (WebServiceException e) {
response.onError(e);
if (debug) {
log.debug("An error occured while processing the async response. " + e.getMessage());
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Wed Jan 31 12:35:21 2007
@@ -23,10 +23,10 @@
import java.lang.reflect.Modifier;
import java.util.concurrent.Future;
-import javax.jws.soap.SOAPBinding;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Binding;
import javax.xml.ws.Response;
+import javax.xml.ws.soap.SOAPBinding;
import org.apache.axis2.jaxws.BindingProvider;
import org.apache.axis2.jaxws.ExceptionFactory;
@@ -128,7 +128,7 @@
if (debug) {
log.debug("An error occured while invoking the method: " + e.getMessage());
}
- throw ExceptionFactory.makeMessageException(e);
+ throw ExceptionFactory.makeWebServiceException(e);
}
}
else {
@@ -159,8 +159,7 @@
// Enable MTOM on the Message if the property was set on the SOAPBinding.
Binding bnd = getBinding();
if (bnd != null && bnd instanceof SOAPBinding) {
- javax.xml.ws.soap.SOAPBinding soapBnd = (javax.xml.ws.soap.SOAPBinding) bnd;
- if (soapBnd.isMTOMEnabled()) {
+ if (((SOAPBinding)bnd).isMTOMEnabled()) {
Message requestMsg = request.getMessage();
requestMsg.setMTOMEnabled(true);
}
@@ -168,10 +167,10 @@
// Only configure the SOAPAction if it hasn't already been
// set by the client.
- String action = operationDesc.getAction();
- if (action != null && requestContext.get(BindingProvider.SOAPACTION_URI_PROPERTY) == null) {
- getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, action);
- }
+ //String action = operationDesc.getAction();
+ //if (action != null && requestContext.get(BindingProvider.SOAPACTION_URI_PROPERTY) == null) {
+ // getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, action);
+ //}
// Before we invoke, copy all of the properties from the client request
// context to the MessageContext
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUitls.java Wed Jan 31 12:35:21 2007
@@ -18,6 +18,9 @@
*/
package org.apache.axis2.jaxws.context.utils;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.util.Map;
import javax.xml.ws.handler.MessageContext.Scope;
@@ -29,8 +32,11 @@
import org.apache.axis2.jaxws.description.ServiceDescriptionWSDL;
import org.apache.axis2.jaxws.util.WSDLWrapper;
import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
public class ContextUitls {
+ private static final Log log = LogFactory.getLog(ContextUitls.class);
/**
* Adds the appropriate properties to the MessageContext that the user will see
@@ -48,9 +54,17 @@
// Set the WSDL properties
ServiceDescription sd = jaxwsMessageContext.getServiceDescription();
- WSDLWrapper wsdlWrapper = ((ServiceDescriptionWSDL) sd).getWSDLWrapper();
- if (wsdlWrapper!=null){
- soapMessageContext.put(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION, wsdlWrapper.getDefinition());
+ URL wsdlLocation = ((ServiceDescriptionWSDL) sd).getWSDLLocation();
+ if (wsdlLocation != null && !"".equals(wsdlLocation)){
+ URI wsdlLocationURI = null;
+ try {
+ wsdlLocationURI = wsdlLocation.toURI();
+ }
+ catch (URISyntaxException ex) {
+ // TODO: NLS/RAS
+ log.warn("Unable to convert WSDL location URL to URI. URL: " + wsdlLocation.toString() + "; Service: " + sd.getServiceQName() , ex);
+ }
+ soapMessageContext.put(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION, wsdlLocationURI);
soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION, Scope.APPLICATION);
}
@@ -94,7 +108,10 @@
soapMessageContext.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY, null);
soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY, Scope.APPLICATION);
- soapMessageContext.put(javax.xml.ws.handler.MessageContext.MESSAGE_ATTACHMENTS, null);
- soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.MESSAGE_ATTACHMENTS, Scope.APPLICATION);
+ soapMessageContext.put(javax.xml.ws.handler.MessageContext.MESSAGE_ATTACHMENTS_INBOUND, null);
+ soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.MESSAGE_ATTACHMENTS_INBOUND, Scope.APPLICATION);
+
+ soapMessageContext.put(javax.xml.ws.handler.MessageContext.MESSAGE_ATTACHMENTS_OUTBOUND, null);
+ soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.MESSAGE_ATTACHMENTS_OUTBOUND, Scope.APPLICATION);
}
}
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java Wed Jan 31 12:35:21 2007
@@ -21,13 +21,13 @@
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.Service.Mode;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.jaxws.description.OperationDescription;
import org.apache.axis2.jaxws.description.ServiceDescription;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.util.MessageUtils;
/**
@@ -62,7 +62,7 @@
properties = new HashMap<String, Object>();
}
- public MessageContext(org.apache.axis2.context.MessageContext mc) throws MessageException {
+ public MessageContext(org.apache.axis2.context.MessageContext mc) throws WebServiceException {
properties = new HashMap<String, Object>();
if (mc != null) {
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java Wed Jan 31 12:35:21 2007
@@ -51,7 +51,6 @@
import org.apache.axis2.jaxws.description.OperationDescription;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.message.util.MessageUtils;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
@@ -122,7 +121,7 @@
// there would be no message on the MessageContext
faultexception = af;
if (log.isDebugEnabled()) {
- log.debug("AxisFault received from client: " + af.getMessage());
+ log.debug(axisRequestMsgCtx.getLogIDString()+" AxisFault received from client: " + af.getMessage());
}
}
@@ -193,7 +192,7 @@
// Whatever exception we get here will not be from the server since a one-way
// invocation has no response. This will always be a SENDER fault
if (log.isDebugEnabled()) {
- log.debug("AxisFault received from client: " + af.getMessage());
+ log.debug(axisRequestMsgCtx.getLogIDString()+" AxisFault received from client: " + af.getMessage());
}
throw ExceptionFactory.makeWebServiceException(ClassUtils.getRootCause(af));
}
@@ -362,8 +361,8 @@
if (log.isDebugEnabled()) {
log.debug("Properties: " + axisRequestMsgCtx.getProperties().toString());
}
- } catch (MessageException e) {
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("prepareRequestFail"), e);
+ } catch (WebServiceException e) {
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("prepareRequestFail"));
} catch (AxisFault e) {
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("prepareRequestFail"), e);
}
@@ -414,28 +413,45 @@
}
/**
- * Returns the SOAPAction that should be used for the invocation. This
- * method will get the information from the MessageContext passed in
- * either from :
- *
- * a) the JAX-WS properties available on the MessageContext or
- * b) the WSDL configuration information available from the MessageContext
+ * Returns the SOAP action that should be used for the invocation. If the
+ * client has already set the property in the JAX-WS request context, then
+ * that value should be used. Otherwise, we should grab it from the
+ * operation description that was configured for the operation.
*
* @param ctx
* @return
*/
private String configureSOAPAction(MessageContext ctx) {
+ OperationDescription op = ctx.getOperationDescription();
+
Boolean useSoapAction = (Boolean) ctx.getProperties().get(BindingProvider.SOAPACTION_USE_PROPERTY);
if(useSoapAction != null && useSoapAction.booleanValue()){
String action = (String) ctx.getProperties().get(BindingProvider.SOAPACTION_URI_PROPERTY);
- if (debug) {
- log.debug("Setting SOAPAction to:" + action);
+ if (action != null) {
+ if (debug) {
+ log.debug("Setting soap action from JAX-WS request context. Action [" + action + "]");
+ }
+ return action;
+ }
+
+ if (op != null) {
+ action = op.getAction();
+ if (action != null) {
+ if (debug) {
+ log.debug("Setting soap action from operation description. Action [" + action + "]");
+ }
+ return action;
+ }
+ }
+ else {
+ if (debug) {
+ log.debug("Cannot set the soap action. No operation description was found.");
+ }
}
- return action;
}
else {
if (debug) {
- log.debug("SOAPAction usage was disabled");
+ log.debug("Soap action usage was disabled");
}
}
@@ -491,7 +507,8 @@
op.setMessageReceiver(new CallbackReceiver());
}
- private Message createMessageFromOM(OMElement om) throws MessageException {
+ /*
+ private Message createMessageFromOM(OMElement om) throws WebServiceException {
try {
MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
Message msg = mf.createFrom(om);
@@ -500,6 +517,7 @@
throw ExceptionFactory.makeWebServiceException(e);
}
}
+ */
/*
* TODO: This is a first pass at filtering the properties that are set on the
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java Wed Jan 31 12:35:21 2007
@@ -16,10 +16,11 @@
*/
package org.apache.axis2.jaxws.core.util;
+import javax.xml.ws.WebServiceException;
+
import org.apache.axis2.AxisFault;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.util.MessageContextBuilder;
/**
@@ -51,8 +52,6 @@
return newMC;
} catch (AxisFault e) {
- throw ExceptionFactory.makeWebServiceException(e);
- } catch (MessageException e) {
throw ExceptionFactory.makeWebServiceException(e);
}
}
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/handler/SoapMessageContext.java Wed Jan 31 12:35:21 2007
@@ -22,11 +22,11 @@
import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
/**
* The SOAPMessageContext is the context handed to SOAP-based application
@@ -51,12 +51,8 @@
}
public SOAPMessage getMessage(){
- try{
- Message msg = getMessageObject();
- return msg.getAsSOAPMessage();
- }catch(MessageException e){
- throw ExceptionFactory.makeWebServiceException(e);
- }
+ Message msg = getMessageObject();
+ return msg.getAsSOAPMessage();
}
public Set<URI> getRoles() {
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/impl/AsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/impl/AsyncListener.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/impl/AsyncListener.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/impl/AsyncListener.java Wed Jan 31 12:35:21 2007
@@ -18,6 +18,7 @@
import java.util.concurrent.Callable;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.Service.Mode;
import org.apache.axiom.om.OMElement;
@@ -27,7 +28,6 @@
import org.apache.axis2.jaxws.core.InvocationContext;
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
/**
* The AsyncListener is responsible for holding the callback that was passed
@@ -100,12 +100,8 @@
* @param msg
*/
protected Object getResponseValueObject(MessageContext mc) {
- try {
- Message msg = mc.getMessage();
- OMElement om = msg.getAsOMElement();
- return om.toString();
- } catch (MessageException e) {
- throw ExceptionFactory.makeWebServiceException(e);
- }
+ Message msg = mc.getMessage();
+ OMElement om = msg.getAsOMElement();
+ return om.toString();
}
}
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java Wed Jan 31 12:35:21 2007
@@ -19,28 +19,19 @@
import javax.jws.soap.SOAPBinding;
import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
-import org.apache.axis2.jaxws.marshaller.impl.DocLitBareMethodMarshallerImpl;
-import org.apache.axis2.jaxws.marshaller.impl.DocLitWrappedMethodMarshallerImpl;
-import org.apache.axis2.jaxws.marshaller.impl.RPCLitMethodMarshallerImpl;
import org.apache.axis2.jaxws.marshaller.impl.alt.DocLitBareMethodMarshaller;
import org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshaller;
+import org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedPlusMethodMarshaller;
import org.apache.axis2.jaxws.marshaller.impl.alt.RPCLitMethodMarshaller;
import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.ParameterDescription;
/**
* The MethodMarshallerFactory creates a Doc/Lit Wrapped, Doc/Lit Bare or RPC Marshaller using SOAPBinding information
*/
public class MethodMarshallerFactory {
- // The following flags are for testing only.
- // The allow us to test the old implementation against the new implementation.
- private static final boolean ALT_RPCLIT_CLIENT = true;
- private static final boolean ALT_DOCLIT_WRAPPED_CLIENT = true;
- private static final boolean ALT_DOCLIT_BARE_CLIENT = true;
- private static final boolean ALT_RPCLIT_SERVER = true;
- private static final boolean ALT_DOCLIT_WRAPPED_SERVER = true;
- private static final boolean ALT_DOCLIT_BARE_SERVER = true;
/**
* Intentionally private
@@ -50,34 +41,27 @@
/**
* Create Marshaller usining the Binding information
- * @param binding
- * @param serviceDesc
- * @param endpointDesc
- * @param operationDesc
- * @param protocol
+ * @param style
+ * @param paramStyle
+ * @param isPlus used to designated DOCLITWRAPPED plus additional rules (i.e. header processing)
+ * @param isClient
* @return
*/
- public static MethodMarshaller createMethodMarshaller(SOAPBinding.Style style,
+ private static MethodMarshaller createMethodMarshaller(SOAPBinding.Style style,
SOAPBinding.ParameterStyle paramStyle,
+ boolean isPlus,
boolean isClient){ // This flag is for testing only !
if (style == SOAPBinding.Style.RPC) {
- if (ALT_RPCLIT_CLIENT && isClient || ALT_RPCLIT_SERVER && !isClient ) {
- return new RPCLitMethodMarshaller();
- } else {
- return new RPCLitMethodMarshallerImpl();
- }
+ return new RPCLitMethodMarshaller();
} else if (paramStyle == SOAPBinding.ParameterStyle.WRAPPED){
- if (ALT_DOCLIT_WRAPPED_CLIENT && isClient || ALT_DOCLIT_WRAPPED_SERVER && !isClient) {
- return new DocLitWrappedMethodMarshaller();
+ if (isPlus) {
+ // Abnormal case
+ return new DocLitWrappedPlusMethodMarshaller();
} else {
- return new DocLitWrappedMethodMarshallerImpl();
+ return new DocLitWrappedMethodMarshaller();
}
} else if (paramStyle == SOAPBinding.ParameterStyle.BARE){
- if (ALT_DOCLIT_BARE_CLIENT && isClient || ALT_DOCLIT_BARE_SERVER && !isClient) {
- return new DocLitBareMethodMarshaller();
- } else {
- return new DocLitBareMethodMarshallerImpl();
- }
+ return new DocLitBareMethodMarshaller();
}
return null;
}
@@ -86,34 +70,37 @@
MethodMarshaller marshaller = null;
if (isClient) {
- if (op.getSoapBindingStyle() == SOAPBinding.Style.DOCUMENT) {
- marshaller = createDocLitMethodMarshaller(op, isClient);
- } else if (op.getSoapBindingStyle() == SOAPBinding.Style.RPC) {
- marshaller = createRPCLitMethodMarshaller(isClient);
- }
+ if (op.getSoapBindingStyle() == SOAPBinding.Style.DOCUMENT) {
+ marshaller = createDocLitMethodMarshaller(op, isClient);
+ } else if (op.getSoapBindingStyle() == SOAPBinding.Style.RPC) {
+ marshaller = createRPCLitMethodMarshaller(isClient);
+ }
} else { // SERVER
- if (op.getSoapBindingStyle() == SOAPBinding.Style.DOCUMENT) {
- marshaller = createDocLitMethodMarshaller(op, isClient);
- } else if (op.getSoapBindingStyle() == SOAPBinding.Style.RPC) {
- marshaller = createRPCLitMethodMarshaller(isClient);
- }
+ if (op.getSoapBindingStyle() == SOAPBinding.Style.DOCUMENT) {
+ marshaller = createDocLitMethodMarshaller(op, isClient);
+ } else if (op.getSoapBindingStyle() == SOAPBinding.Style.RPC) {
+ marshaller = createRPCLitMethodMarshaller(isClient);
+ }
}
return marshaller;
}
private static MethodMarshaller createDocLitMethodMarshaller(OperationDescription op, boolean isClient){
SOAPBinding.ParameterStyle parameterStyle = null;
+ boolean isPlus = false;
if(isDocLitBare(op)){
parameterStyle = SOAPBinding.ParameterStyle.BARE;
- }
- if(isDocLitWrapped(op)){
+ } else if (isDocLitWrappedPlus(op)) {
+ parameterStyle = SOAPBinding.ParameterStyle.WRAPPED;
+ isPlus = true;
+ } else if(isDocLitWrapped(op)){
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED;
}
- return createMethodMarshaller(SOAPBinding.Style.DOCUMENT, parameterStyle, isClient);
+ return createMethodMarshaller(SOAPBinding.Style.DOCUMENT, parameterStyle, isPlus, isClient);
}
private static MethodMarshaller createRPCLitMethodMarshaller(boolean isClient){
- return createMethodMarshaller(SOAPBinding.Style.RPC, SOAPBinding.ParameterStyle.WRAPPED, isClient);
+ return createMethodMarshaller(SOAPBinding.Style.RPC, SOAPBinding.ParameterStyle.WRAPPED, false, isClient);
}
protected static boolean isDocLitBare(OperationDescription op){
@@ -136,5 +123,29 @@
SOAPBinding.ParameterStyle SEIParamStyle = op.getEndpointInterfaceDescription().getSoapBindingParameterStyle();
return SEIParamStyle == SOAPBinding.ParameterStyle.WRAPPED;
}
+ }
+
+ /**
+ * If an web service is created using wsgen, it is possible that the
+ * sei does not comply with the wrapped rules. For example, wsgen will
+ * allow header parameters and return values.
+ * In such cases we will use the DocLitWrappedPlus marshaller to marshal
+ * and unmarshal the xml in these extraordinary situations
+ * @param op
+ * @return
+ */
+ protected static boolean isDocLitWrappedPlus(OperationDescription op){
+ if (isDocLitWrapped(op)) {
+ if (op.isResultHeader()) {
+ return true;
+ }
+ ParameterDescription[] pds = op.getParameterDescriptions();
+ for (int i=0; i<pds.length; i++) {
+ if (pds[i].isHeader()) {
+ return true;
+ }
+ }
+ }
+ return false;
}
}
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java Wed Jan 31 12:35:21 2007
@@ -30,7 +30,6 @@
import org.apache.axis2.jaxws.description.ParameterDescription;
import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.Protocol;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
@@ -75,7 +74,13 @@
Class returnType = operationDesc.getResultActualType();
Object returnValue = null;
if (returnType != void.class) {
- returnValue = MethodMarshallerUtils.getReturnValue(packages, message, null);
+ // If the webresult is in the header, we need the name of the header so that we can find it.
+ if (operationDesc.isResultHeader()) {
+ returnValue = MethodMarshallerUtils.getReturnValue(packages, message, null, true,
+ operationDesc.getResultTargetNamespace(), operationDesc.getResultName());
+ } else {
+ returnValue = MethodMarshallerUtils.getReturnValue(packages, message, null, false, null, null);
+ }
}
// Unmarshall the ParamValues from the Message
@@ -137,12 +142,7 @@
// We want to respond with the same protocol as the request,
// It the protocol is null, then use the Protocol defined by the binding
if (protocol == null) {
- try {
- protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
- } catch (MessageException e) {
- // TODO better handling than this?
- e.printStackTrace();
- }
+ protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
}
// Note all exceptions are caught and rethrown with a WebServiceException
@@ -177,7 +177,8 @@
MethodMarshallerUtils.toMessage(returnObject, returnType,
operationDesc.getResultTargetNamespace(),
operationDesc.getResultName(), packages, m,
- false); // don't force xsi:type for doc/lit
+ false, // don't force xsi:type for doc/lit
+ operationDesc.isResultHeader());
}
// Convert the holder objects into a list of JAXB objects for marshalling
@@ -200,13 +201,7 @@
EndpointInterfaceDescription ed = operationDesc.getEndpointInterfaceDescription();
EndpointDescription endpointDesc = ed.getEndpointDescription();
- Protocol protocol = null;
- try {
- protocol = Protocol.getProtocolForBinding(endpointDesc.getClientBindingID());
- } catch (MessageException e) {
- // TODO better handling than this?
- e.printStackTrace();
- }
+ Protocol protocol = Protocol.getProtocolForBinding(endpointDesc.getClientBindingID());
// Note all exceptions are caught and rethrown with a WebServiceException
try {
@@ -257,12 +252,7 @@
// We want to respond with the same protocol as the request,
// It the protocol is null, then use the Protocol defined by the binding
if (protocol == null) {
- try {
- protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
- } catch (MessageException e) {
- // TODO better handling than this?
- e.printStackTrace();
- }
+ protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
}
// Note all exceptions are caught and rethrown with a WebServiceException
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java Wed Jan 31 12:35:21 2007
@@ -22,7 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.WeakHashMap;
+import java.util.HashMap;
import javax.jws.WebParam.Mode;
import javax.xml.bind.JAXBElement;
@@ -38,7 +38,6 @@
import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.Protocol;
import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
@@ -92,8 +91,7 @@
// or null
Object returnValue = null;
Class returnType = operationDesc.getResultActualType();
- boolean isChildReturn = (operationDesc instanceof OperationDescriptionJava) &&
- ((OperationDescriptionJava) operationDesc).isWebResultAnnotationSpecified();
+ boolean isChildReturn = !operationDesc.isJAXWSAsyncClientMethod() && (operationDesc.getResultPartName() != null);
boolean isNoReturn = (returnType == void.class);
// In usage=WRAPPED, there will be a single JAXB block inside the body.
@@ -263,12 +261,7 @@
// We want to respond with the same protocol as the request,
// It the protocol is null, then use the Protocol defined by the binding
if (protocol == null) {
- try {
- protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
- } catch (MessageException e) {
- // TODO better handling than this?
- e.printStackTrace();
- }
+ protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
}
// Note all exceptions are caught and rethrown with a WebServiceException
@@ -305,13 +298,12 @@
signatureArgs,
false, // output
true); // use partNames (which are child names)
-
// Now we want to create a single JAXB element that contains the
// ParameterValues. We will use the wrapper tool to do this.
// Create the inputs to the wrapper tool
ArrayList<String> nameList = new ArrayList<String>();
- Map<String, Object> objectList = new WeakHashMap<String, Object>();
+ Map<String, Object> objectList = new HashMap<String, Object>();
for(PDElement pv:pvList) {
String name = pv.getParam().getParameterName();
@@ -367,13 +359,8 @@
EndpointInterfaceDescription ed = operationDesc.getEndpointInterfaceDescription();
EndpointDescription endpointDesc = ed.getEndpointDescription();
- Protocol protocol = null;
- try {
- protocol = Protocol.getProtocolForBinding(endpointDesc.getClientBindingID());
- } catch (MessageException e) {
- // TODO better handling than this?
- e.printStackTrace();
- }
+ Protocol protocol = Protocol.getProtocolForBinding(endpointDesc.getClientBindingID());
+
// Note all exceptions are caught and rethrown with a WebServiceException
try {
@@ -411,7 +398,7 @@
// ParameterValues. We will use the wrapper tool to do this.
// Create the inputs to the wrapper tool
ArrayList<String> nameList = new ArrayList<String>();
- Map<String, Object> objectList = new WeakHashMap<String, Object>();
+ Map<String, Object> objectList = new HashMap<String, Object>();
for(PDElement pv:pvList){
String name = pv.getParam().getParameterName();
@@ -461,12 +448,7 @@
// We want to respond with the same protocol as the request,
// It the protocol is null, then use the Protocol defined by the binding
if (protocol == null) {
- try {
- protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
- } catch (MessageException e) {
- // TODO better handling than this?
- e.printStackTrace();
- }
+ protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
}
// Note all exceptions are caught and rethrown with a WebServiceException
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java Wed Jan 31 12:35:21 2007
@@ -30,6 +30,7 @@
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPFault;
import javax.xml.stream.XMLStreamException;
@@ -46,7 +47,6 @@
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.Protocol;
import org.apache.axis2.jaxws.message.XMLFault;
import org.apache.axis2.jaxws.message.XMLFaultReason;
@@ -56,6 +56,7 @@
import org.apache.axis2.jaxws.registry.FactoryRegistry;
import org.apache.axis2.jaxws.util.ClassUtils;
import org.apache.axis2.jaxws.util.ConvertUtils;
+import org.apache.axis2.jaxws.util.SAAJFactory;
import org.apache.axis2.jaxws.util.XMLRootElementUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -144,7 +145,7 @@
Message message,
Set<String> packages,
boolean isInput,
- boolean usePartName) throws MessageException, XMLStreamException {
+ boolean usePartName) throws XMLStreamException {
List<PDElement> pvList = new ArrayList<PDElement>();
@@ -313,14 +314,14 @@
* @param isRPC
* @throws MessageException
*/
- static void toMessage(List<PDElement> pvList, Message message, Set<String> packages, boolean isRPC) throws MessageException {
+ static void toMessage(List<PDElement> pvList, Message message, Set<String> packages, boolean isRPC) throws WebServiceException {
int index = message.getNumBodyBlocks();
for (int i=0; i<pvList.size(); i++) {
PDElement pv = pvList.get(i);
// Create the JAXBBlockContext
- // RPC uses type marshalling, so recored the rpcType
+ // RPC uses type marshalling, so use the rpcType
JAXBBlockContext context = new JAXBBlockContext(packages);
if (isRPC) {
context.setRPCType(pv.getParam().getParameterActualType());
@@ -357,6 +358,7 @@
* @param packages
* @param message
* @param isRPC
+ * @param isHeader
* @throws MessageException
*/
static void toMessage(Object returnValue,
@@ -365,8 +367,9 @@
String returnLocalPart,
Set<String> packages,
Message message,
- boolean isRPC)
- throws MessageException {
+ boolean isRPC,
+ boolean isHeader)
+ throws WebServiceException {
// Create the JAXBBlockContext
// RPC uses type marshalling, so recored the rpcType
@@ -385,20 +388,33 @@
Block block = factory.createFrom(returnValue,
context,
null); // The factory will get the qname from the value
- message.setBodyBlock(0, block);
+
+ if (isHeader) {
+ message.setHeaderBlock(returnNS, returnLocalPart, block);
+ } else {
+ message.setBodyBlock(0, block);
+ }
}
/**
* Unmarshal the return object from the message
* @param packages
* @param message
- * @param rpcType RPC Declared Type class (only used for RPC processing
+ * @param rpcType RPC Declared Type class (only used for RPC processing)
+ * @param isHeader
+ * @param headerNS (only needed if isHeader)
+ * @param headerLocalPart (only needed if isHeader)
* @return type enabled object
- * @throws MessageException
+ * @throws WebService
* @throws XMLStreamException
*/
- static Object getReturnValue(Set<String> packages, Message message, Class rpcType)
- throws MessageException, XMLStreamException {
+ static Object getReturnValue(Set<String> packages,
+ Message message,
+ Class rpcType,
+ boolean isHeader,
+ String headerNS,
+ String headerLocalPart)
+ throws WebServiceException, XMLStreamException {
// The return object is the first block in the body
@@ -406,7 +422,12 @@
if (rpcType != null) {
context.setRPCType(rpcType); // RPC is type-based, so the unmarshalled type must be provided
}
- Block block = message.getBodyBlock(0, context, factory);
+ Block block = null;
+ if (isHeader) {
+ block = message.getHeaderBlock(headerNS, headerLocalPart, context, factory);
+ } else {
+ block = message.getBodyBlock(0, context, factory);
+ }
// Get the business object. We want to return the object that represents the type.
Object returnValue = block.getBusinessObject(true);
@@ -423,14 +444,12 @@
* @param packages Packages needed to marshal the object
* @param message Message
* @param isRPC
- * @throws MessageException
- * @throws NoSuchMethodException
- * @throws InvocationTargetException
- * @throws IllegalAccessException
*/
- static void marshalFaultResponse(Throwable throwable, OperationDescription operationDesc, Set<String> packages, Message message, boolean isRPC)
- throws MessageException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
-
+ static void marshalFaultResponse(Throwable throwable,
+ OperationDescription operationDesc,
+ Set<String> packages,
+ Message message,
+ boolean isRPC) {
// Get the root cause of the throwable object
Throwable t = ClassUtils.getRootCause(throwable);
if (log.isDebugEnabled()) {
@@ -438,81 +457,173 @@
log.debug(" rootCause =" + t.getClass().getName());
log.debug(" exception=" + t.toString());
}
-
+
XMLFault xmlfault = null;
-
- // There are 5 different categories of exceptions. Each category has a little different marshaling code.
- // A) Service Exception that matches the JAX-WS specification (chapter 2.5 of the spec)
- // B) Service Exception that matches the JAX-WS "legacy" exception (chapter 3.7 of the spec)
- // C) SOAPFaultException
- // D) WebServiceException
- // E) Other runtime exceptions (i.e. NullPointerException)
-
- // Get the FaultDescriptor matching this Exception.
- // If FaultDescriptor is found, this is a JAX-B Service Exception.
- // If not found, this is a System Exception
- FaultDescription fd = operationDesc.resolveFaultByExceptionName(t.getClass().getName());
-
- if (t instanceof SOAPFaultException) {
- // Category C: SOAPFaultException
- // Construct the xmlFault from the SOAPFaultException's Fault
- SOAPFaultException sfe = (SOAPFaultException) t;
- SOAPFault soapFault = sfe.getFault();
- if (soapFault == null) {
- // No fault ? I will treat this like category E
- xmlfault = new XMLFault(null, // Use the default XMLFaultCode
- new XMLFaultReason(t.toString())); // Assumes text is the language supported by the current Locale
- } else {
- xmlfault = XMLFaultUtils.createXMLFault(soapFault);
- }
-
- } else if (fd != null) {
- // The exception is a Service Exception. It may be (A) JAX-WS compliant exception or (B) JAX-WS legacy exception
-
- // TODO Need to add detection and code to differentiate between (A) and (B)
-
- // Get the fault bean object. Make sure it can be rendered as an element
- Method getFaultInfo = t.getClass().getMethod("getFaultInfo", null);
- Object faultBeanObject = getFaultInfo.invoke(t, null);
- if (!XMLRootElementUtil.isElementEnabled(faultBeanObject.getClass())) {
- faultBeanObject = XMLRootElementUtil.getElementEnabledObject(fd.getTargetNamespace(), fd.getName(),
- faultBeanObject.getClass(), faultBeanObject);
+
+ try {
+
+ // There are 5 different categories of exceptions. Each category has a little different marshaling code.
+ // A) Service Exception that matches the JAX-WS specification (chapter 2.5 of the spec)
+ // B) Service Exception that matches the JAX-WS "legacy" exception (chapter 3.7 of the spec)
+ // C) SOAPFaultException
+ // D) WebServiceException
+ // E) Other runtime exceptions (i.e. NullPointerException)
+
+ // Get the FaultDescriptor matching this Exception.
+ // If FaultDescriptor is found, this is a JAX-B Service Exception.
+ // If not found, this is a System Exception
+ FaultDescription fd = operationDesc.resolveFaultByExceptionName(t.getClass().getCanonicalName());
+
+ if (fd != null) {
+ if (log.isErrorEnabled()) {
+ log.debug("Marshal as a Service Exception");
+ }
+ // The exception is a Service Exception. It may be (A) JAX-WS compliant exception or (B) JAX-WS legacy exception
+
+ // The faultBeanObject is a JAXB object that represents the data of the exception. It is marshalled in the detail
+ // section of the soap fault. The faultBeanObject is obtained direction from the exception (A) or via
+ // the legacy exception rules (B).
+ Object faultBeanObject = null;
+
+ if (LegacyExceptionUtil.isLegacyException(t.getClass())) {
+ // Legacy Exception case
+ faultBeanObject = LegacyExceptionUtil.createFaultBean(t, fd);
+ } else {
+ // Normal case
+ // Get the fault bean object.
+ Method getFaultInfo = t.getClass().getMethod("getFaultInfo", null);
+ faultBeanObject = getFaultInfo.invoke(t, null);
+ }
+
+ if (log.isErrorEnabled()) {
+ log.debug("The faultBean type is" + faultBeanObject.getClass().getName());
+ }
+ // Make sure the faultBeanObject can be marshalled as an element
+ if (!XMLRootElementUtil.isElementEnabled(faultBeanObject.getClass())) {
+ faultBeanObject = XMLRootElementUtil.getElementEnabledObject(fd.getTargetNamespace(), fd.getName(),
+ faultBeanObject.getClass(), faultBeanObject);
+ }
+
+
+ // Create the JAXBBlockContext
+ // RPC uses type marshalling, so recored the rpcType
+ JAXBBlockContext context = new JAXBBlockContext(packages);
+ if (isRPC) {
+ context.setRPCType(faultBeanObject.getClass());
+ }
+
+ // Create a detailblock representing the faultBeanObject
+ Block[] detailBlocks = new Block[1];
+ detailBlocks[0] = factory.createFrom(faultBeanObject,context,null);
+
+ if (log.isErrorEnabled()) {
+ log.debug("Create the xmlFault for the Service Exception");
+ }
+ // Get the fault text using algorithm defined in JAX-WS 10.2.2.3
+ String text = t.getMessage();
+ if (text == null || text.length() == 0) {
+ text = t.toString();
+ }
+ // Now make a XMLFault containing the detailblock
+ xmlfault = new XMLFault(null, new XMLFaultReason(text), detailBlocks);
+ } else {
+ xmlfault = createXMLFaultFromSystemException(t);
}
-
-
- // Create the JAXBBlockContext
- // RPC uses type marshalling, so recored the rpcType
- JAXBBlockContext context = new JAXBBlockContext(packages);
- if (isRPC) {
- context.setRPCType(faultBeanObject.getClass());
+ } catch (Throwable e) {
+ // If an exception occurs while demarshalling an exception, then rinse and repeat with a system exception
+ if (log.isDebugEnabled()) {
+ log.debug("An exception (" + e + ") occurred while marshalling exception (" + t + ")");
}
-
- // Create a detailblock representing the faultBeanObject
- Block[] detailBlocks = new Block[1];
- detailBlocks[0] = factory.createFrom(faultBeanObject,context,null);
-
- // Now make a XMLFault containing the detailblock
- xmlfault = new XMLFault(null, new XMLFaultReason(t.getMessage()), detailBlocks);
- } else if (t instanceof WebServiceException) {
- // Category D: WebServiceException
- // The reason is constructed with the getMessage of the exception.
- // There is no detail
- WebServiceException wse = (WebServiceException) t;
- xmlfault = new XMLFault(null, // Use the default XMLFaultCode
- new XMLFaultReason(wse.getMessage())); // Assumes text is the language supported by the current Locale
- } else {
- // Category E: Other System Exception
- // The reason is constructed with the toString of the exception.
- // This places the class name of the exception in the reason
- // There is no detail.
- xmlfault = new XMLFault(null, // Use the default XMLFaultCode
- new XMLFaultReason(t.toString())); // Assumes text is the language supported by the current Locale
+ WebServiceException wse = ExceptionFactory.makeWebServiceException(e);
+ xmlfault = createXMLFaultFromSystemException(wse);
}
+
// Add the fault to the message
message.setXMLFault(xmlfault);
}
/**
+ * This method is used by WebService Impl and Provider to create
+ * an XMLFault (for marshalling) from an exception that is a non-service exception
+ * @param t Throwable that represents a Service Exception
+ * @return XMLFault
+ */
+ public static XMLFault createXMLFaultFromSystemException(Throwable t) {
+
+ try {
+ XMLFault xmlfault = null;
+ if (t instanceof SOAPFaultException) {
+ if (log.isErrorEnabled()) {
+ log.debug("Marshal SOAPFaultException");
+ }
+ // Category C: SOAPFaultException
+ // Construct the xmlFault from the SOAPFaultException's Fault
+ SOAPFaultException sfe = (SOAPFaultException) t;
+ SOAPFault soapFault = sfe.getFault();
+ if (soapFault == null) {
+ // No fault ? I will treat this like category E
+ xmlfault = new XMLFault(null, // Use the default XMLFaultCode
+ new XMLFaultReason(t.toString())); // Assumes text is the language supported by the current Locale
+ } else {
+ xmlfault = XMLFaultUtils.createXMLFault(soapFault);
+ }
+
+ } else if (t instanceof WebServiceException) {
+ if (log.isErrorEnabled()) {
+ log.debug("Marshal as a WebServiceException");
+ }
+ // Category D: WebServiceException
+ // The reason is constructed with the getMessage of the exception.
+ // There is no detail
+ WebServiceException wse = (WebServiceException) t;
+
+ // Get the fault text using algorithm defined in JAX-WS 10.2.2.3
+ String text = wse.getMessage();
+ if (text == null || text.length() == 0) {
+ text = wse.toString();
+ }
+ xmlfault = new XMLFault(null, // Use the default XMLFaultCode
+ new XMLFaultReason(text)); // Assumes text is the language supported by the current Locale
+ } else {
+ if (log.isErrorEnabled()) {
+ log.debug("Marshal as a unchecked System Exception");
+ }
+ // Category E: Other System Exception
+ // The reason is constructed with the toString of the exception.
+ // This places the class name of the exception in the reason
+ // There is no detail.
+ // Get the fault text using algorithm defined in JAX-WS 10.2.2.3
+ String text = t.getMessage();
+ if (text == null || text.length() == 0) {
+ text = t.toString();
+ }
+ xmlfault = new XMLFault(null, // Use the default XMLFaultCode
+ new XMLFaultReason(text)); // Assumes text is the language supported by the current Locale
+ }
+ return xmlfault;
+ } catch (Throwable e) {
+ try {
+ // If an exception occurs while demarshalling an exception, then rinse and repeat with a webservice exception
+ if (log.isDebugEnabled()) {
+ log.debug("An exception (" + e + ") occurred while marshalling exception (" + t + ")");
+ }
+ // Get the fault text using algorithm defined in JAX-WS 10.2.2.3
+ String text = e.getMessage();
+ if (text == null || text.length() == 0) {
+ text = e.toString();
+ }
+ WebServiceException wse = ExceptionFactory.makeWebServiceException(e);
+
+ return new XMLFault(null, // Use the default XMLFaultCode
+ new XMLFaultReason(text)); // Assumes text is the language supported by the current Locale
+ } catch (Exception e2) {
+ // Exception while creating Exception for Exception
+ throw ExceptionFactory.makeWebServiceException(e2);
+ }
+ }
+ }
+
+ /**
* Unmarshal the service/system exception from a Message.
* This is used by all of the marshallers
* @param operationDesc
@@ -520,7 +631,7 @@
* @param message
* @param isRPC
* @return Throwable
- * @throws MessageException
+ * @throws WebServiceException
* @throws ClassNotFoundException
* @throws IllegalAccessException
* @throws InstantiationException
@@ -529,7 +640,7 @@
* @throws NoSuchMethodException
*/
static Throwable demarshalFaultResponse(OperationDescription operationDesc, Set<String> packages,Message message, boolean isRPC)
- throws MessageException, ClassNotFoundException, IllegalAccessException,
+ throws WebServiceException, ClassNotFoundException, IllegalAccessException,
InstantiationException, XMLStreamException, InvocationTargetException, NoSuchMethodException {
Throwable exception = null;
@@ -537,14 +648,28 @@
XMLFault xmlfault = message.getXMLFault();
Block[] detailBlocks = xmlfault.getDetailBlocks();
+ // Sometimes Axis2 will flow a single detail element with the name "Exception".
+ // "Exception" contains stack information. This is a violation of the WSI specification; however
+ // we still need to work around it.
+ boolean isStack = false;
+ QName elementName = null;
+ if (detailBlocks !=null && detailBlocks.length == 1) {
+ elementName = detailBlocks[0].getQName();
+ isStack = (elementName.getNamespaceURI().length() == 0 && elementName.getLocalPart().equals("Exception"));
+ }
+
if ((operationDesc.getFaultDescriptions().length == 0) ||
+ isStack ||
(detailBlocks == null) ||
(detailBlocks.length > 1)) {
// This is a system exception if the method does not throw a checked exception or if
// the detail block is missing or contains multiple items.
exception = createSystemException(xmlfault, message);
- } else {
+ } else {
+ if (log.isErrorEnabled()) {
+ log.debug("Ready to demarshal service exception. The detail entry name is " + elementName);
+ }
// Get the JAXB object from the block
JAXBBlockContext blockContext = new JAXBBlockContext(packages);
@@ -554,9 +679,6 @@
// to unmarshal the object. But we don't know the declared
// type without knowing the name of the type (sigh)
- // First get the QName...this might cause a parse
- QName elementName = detailBlocks[0].getQName();
-
// Now search the FaultDescriptors to find the right
// declared type
Class rpcType = null;
@@ -574,7 +696,7 @@
// TODO This code assumes that the block can be demarshalled as a
// known JAXB object. But what if a detail is flowed that we don't know how to handle.
- // for example, what if the detail is a stack trace. To be on the safe side, we should
+ // To be on the safe side, we should
// probably make a copy of the OMBlock and then throw create a SystemException if
// with the original detail if JAXB unmarshalling fails.
// (I agree that this would not be performant, but we are on an exception path)
@@ -593,23 +715,34 @@
faultBeanQName = XMLRootElementUtil.getXmlRootElementQName(faultBeanObject);
}
+ if (log.isErrorEnabled()) {
+ log.debug("Searching for the matching FaultDescription");
+ }
// Using the faultBeanQName, find the matching faultDescription
FaultDescription faultDesc = null;
for(int i=0; i<operationDesc.getFaultDescriptions().length && faultDesc == null; i++) {
FaultDescription fd = operationDesc.getFaultDescriptions()[i];
QName tryQName = new QName(fd.getTargetNamespace(), fd.getName());
-
+ if (log.isErrorEnabled()) {
+ log.debug(" FaultDescription qname is (" + tryQName + ") and demarshalled bean qname is (" + faultBeanQName + ")");
+ }
if (faultBeanQName == null || faultBeanQName.equals(tryQName)) {
faultDesc = fd;
}
}
if (faultDesc == null) {
+ if (log.isErrorEnabled()) {
+ log.debug("A FaultDescription was not found");
+ }
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("MethodMarshallerErr1", faultBeanObject.getClass().toString()));
}
// Construct the JAX-WS generated exception that holds the faultBeanObject
Class exceptionClass = loadClass(faultDesc.getExceptionClassName());
+ if (log.isErrorEnabled()) {
+ log.debug("Found FaultDescription. The exception name is " + exceptionClass.getName());
+ }
Class faultBeanFormalClass = loadClass(faultDesc.getFaultBean()); // Note that faultBean may not be a bean, it could be a primitive
exception =createServiceException(xmlfault.getReason().getText(), exceptionClass, faultBeanObject, faultBeanFormalClass);
}
@@ -682,15 +815,21 @@
* @throws NoSuchMethodException
*/
private static Exception createServiceException(String message, Class exceptionclass, Object bean, Class beanFormalType) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
- // All webservice exception classes are required to have a constructor that takes a (String, bean) argument
- // TODO necessary to be more careful here with instantiating, cassting, etc?
+
if (log.isDebugEnabled()) {
log.debug("Constructing JAX-WS Exception:" + exceptionclass);
}
- Constructor constructor = exceptionclass.getConstructor(new Class[] { String.class, beanFormalType });
- Object exception = constructor.newInstance(new Object[] { message, bean });
+ Exception exception = null;
+ if (LegacyExceptionUtil.isLegacyException(exceptionclass)) {
+ // Legacy Exception
+ exception = LegacyExceptionUtil.createFaultException(exceptionclass, bean);
+ } else {
+ // Normal case, use the contstructor to create the exception
+ Constructor constructor = exceptionclass.getConstructor(new Class[] { String.class, beanFormalType });
+ exception = (Exception) constructor.newInstance(new Object[] { message, bean });
+ }
- return (Exception) exception;
+ return exception;
}
@@ -703,16 +842,20 @@
ProtocolException e = null;
Protocol protocol = message.getProtocol();
String text = xmlFault.getReason().getText();
+
if (protocol == Protocol.soap11 || protocol == Protocol.soap12) {
// Throw a SOAPFaultException
if (log.isDebugEnabled()) {
log.debug("Constructing SOAPFaultException for " + text);
}
+ String protocolNS = (protocol == Protocol.soap11) ?
+ SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE :
+ SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE;
try {
// The following set of instructions is used to avoid
// some unimplemented methods in the Axis2 SAAJ implementation
- SOAPEnvelope env = message.getAsSOAPEnvelope();
- SOAPBody body = env.getBody();
+ javax.xml.soap.MessageFactory mf = SAAJFactory.createMessageFactory(protocolNS);
+ SOAPBody body = mf.createMessage().getSOAPBody();
SOAPFault soapFault = XMLFaultUtils.createSAAJFault(xmlFault, body);
e = new SOAPFaultException(soapFault);
} catch (Exception ex) {
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java Wed Jan 31 12:35:21 2007
@@ -33,7 +33,6 @@
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.MessageException;
import org.apache.axis2.jaxws.message.Protocol;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
@@ -55,7 +54,7 @@
Protocol protocol = null;
try {
protocol = Protocol.getProtocolForBinding(endpointDesc.getClientBindingID());
- } catch (MessageException e) {
+ } catch (WebServiceException e) {
// TODO better handling than this?
e.printStackTrace();
}
@@ -191,7 +190,7 @@
if (protocol == null) {
try {
protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
- } catch (MessageException e) {
+ } catch (WebServiceException e) {
// TODO better handling than this?
e.printStackTrace();
}
@@ -245,7 +244,8 @@
operationDesc.getResultPartName(),
packages,
m,
- true); // forceXSI since this is rpc/lit
+ true, // forceXSI since this is rpc/lit
+ operationDesc.isResultHeader());
}
// Convert the holder objects into a list of JAXB objects for marshalling
@@ -303,7 +303,13 @@
Class returnType = operationDesc.getResultActualType();
Object returnValue = null;
if (returnType != void.class) {
- returnValue = MethodMarshallerUtils.getReturnValue(packages, message, returnType);
+ // If the webresult is in the header, we need the name of the header so that we can find it.
+ if (operationDesc.isResultHeader()) {
+ returnValue = MethodMarshallerUtils.getReturnValue(packages, message, returnType, true,
+ operationDesc.getResultTargetNamespace(), operationDesc.getResultPartName());
+ } else {
+ returnValue = MethodMarshallerUtils.getReturnValue(packages, message, returnType, false, null, null);
+ }
}
// Unmarshall the ParamValues from the Message
@@ -328,7 +334,7 @@
if (protocol == null) {
try {
protocol = Protocol.getProtocolForBinding(endpointDesc.getBindingType());
- } catch (MessageException e) {
+ } catch (WebServiceException e) {
// TODO better handling than this?
e.printStackTrace();
}
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Block.java Wed Jan 31 12:35:21 2007
@@ -20,6 +20,7 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import javax.xml.ws.WebServiceException;
import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMElement;
@@ -53,9 +54,9 @@
* @param consume true if this is the last request on the block.
* @return Object (JAXB, String etc.)
* @throws XMLStreamException
- * @throws MessageException
+ * @throws WebServiceException
*/
- public Object getBusinessObject(boolean consume) throws XMLStreamException, MessageException;
+ public Object getBusinessObject(boolean consume) throws XMLStreamException, WebServiceException;
/**
* GetBusinesContext
@@ -70,25 +71,25 @@
* @return XMLStreamReader
* @throws XMLStreamException
*/
- public XMLStreamReader getXMLStreamReader(boolean consume) throws XMLStreamException, MessageException;
+ public XMLStreamReader getXMLStreamReader(boolean consume) throws XMLStreamException, WebServiceException;
/**
* Get the OMElement represented by this Block.
* This call always consumes the block because you are taking control of the underlying OM
* @return
* @throws XMLStreamException
- * @throws MessageException
+ * @throws WebServiceException
*/
- public OMElement getOMElement() throws XMLStreamException, MessageException;
+ public OMElement getOMElement() throws XMLStreamException, WebServiceException;
/**
* Write out the Block
* @param writer XMLStreamWriter
* @param consume true if this is the last request on the block.
* @throws XMLStreamException
- * @trhows MessageException
+ * @trhows WebServiceException
*/
- public void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, MessageException;
+ public void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, WebServiceException;
/**
* isConsumed
@@ -119,9 +120,9 @@
* Asking for the QName can cause a performant hit.
* @see isQNameAvailable
* @return QName of the block
- * @throw MessageException
+ * @throw WebServiceException
*/
- public QName getQName() throws MessageException;
+ public QName getQName() throws WebServiceException;
/**
* Get BlockFactory
@@ -129,4 +130,15 @@
*/
public BlockFactory getBlockFactory();
+ /**
+ * Get the Message associated with this block
+ * @return Message
+ */
+ public Message getParent();
+
+ /** Set the Message associated with this block
+ * (This method is intended to be called by the Message Implementation only)
+ * @param parent
+ */
+ public void setParent(Message parent);
}
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java Wed Jan 31 12:35:21 2007
@@ -21,6 +21,7 @@
import javax.activation.DataHandler;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
/**
* Message
@@ -47,7 +48,7 @@
* Get the xml part as a read/write SOAPEnvelope
* @return SOAPEnvelope
*/
- public SOAPMessage getAsSOAPMessage() throws MessageException;
+ public SOAPMessage getAsSOAPMessage() throws WebServiceException;
/**
* Adds an attachment part to the message
Modified: webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java (original)
+++ webservices/axis2/branches/java/maven2/modules/jaxws/src/org/apache/axis2/jaxws/message/Protocol.java Wed Jan 31 12:35:21 2007
@@ -18,6 +18,7 @@
*/
package org.apache.axis2.jaxws.message;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.SOAPBinding;
import org.apache.axis2.jaxws.ExceptionFactory;
@@ -45,9 +46,9 @@
* URL that was passed in.
*
* @param url
- * @return
+ * @return Protocol or null
*/
- public static Protocol getProtocolForBinding(String url) throws MessageException {
+ public static Protocol getProtocolForBinding(String url) {
boolean debug = log.isDebugEnabled();
if (debug) {
log.debug("Configuring message protocol for binding [" + url + "]");
@@ -70,7 +71,10 @@
return Protocol.soap12;
}
else {
- throw ExceptionFactory.makeMessageException(Messages.getMessage("protoNotFound00", url));
+ if (debug) {
+ log.debug("Protocol was not found for:" + url);
+ }
+ return null;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org