Author: richard.opalka(a)jboss.com
Date: 2010-04-01 10:20:47 -0400 (Thu, 01 Apr 2010)
New Revision: 11921
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonMessageContext.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java
Log:
[JBWS-2985] fixing addressing Action header to follow JAX-WS 2.2 specification
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonMessageContext.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonMessageContext.java 2010-04-01
10:11:01 UTC (rev 11920)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonMessageContext.java 2010-04-01
14:20:47 UTC (rev 11921)
@@ -70,6 +70,7 @@
protected Scope currentScope = Scope.APPLICATION;
private boolean isModified;
+ private Throwable currentException;
public CommonMessageContext()
{
@@ -85,6 +86,16 @@
this.scopedProps = new HashMap<String,
ScopedProperty>(msgContext.scopedProps);
this.currentScope = msgContext.currentScope;
}
+
+ public Throwable getCurrentException()
+ {
+ return currentException;
+ }
+
+ public void setCurrentException(Throwable t)
+ {
+ this.currentException = t;
+ }
public Scope getCurrentScope()
{
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java 2010-04-01
10:11:01 UTC (rev 11920)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java 2010-04-01
14:20:47 UTC (rev 11921)
@@ -132,6 +132,7 @@
log.debug("callFaultHandlerChain: " + type);
HandlerChainExecutor executor = getExecutor(type);
MessageContext msgContext =
(MessageContext)MessageContextAssociation.peekMessageContext();
+ ((CommonMessageContext)msgContext).setCurrentException(ex);
boolean status = (executor != null ? executor.handleFault(msgContext, ex) : true);
MessageAbstraction msg =
((CommonMessageContext)msgContext).getMessageAbstraction();
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java 2010-04-01
10:11:01 UTC (rev 11920)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java 2010-04-01
14:20:47 UTC (rev 11921)
@@ -24,6 +24,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.extensions.addressing.AddressingClientUtil;
import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
+import org.jboss.ws.extensions.addressing.metadata.AddressingOpMetaExt;
import org.jboss.ws.extensions.addressing.soap.SOAPAddressingPropertiesImpl;
import org.jboss.ws.metadata.umdm.ClientEndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
@@ -114,7 +115,13 @@
}
else
{
- addrProps.setAction(ADDR_BUILDER.newURI(opMetaData.getJavaName()));
+ AddressingOpMetaExt addressingMD =
(AddressingOpMetaExt)opMetaData.getExtension(ADDR_CONSTANTS.getNamespaceURI());
+ if (addressingMD == null)
+ throw new IllegalStateException("Addressing Meta Data not
available");
+
+ String action = addressingMD.getInboundAction();
+ if (action == null) action = opMetaData.getJavaName();
+ addrProps.setAction(ADDR_BUILDER.newURI(action));
}
}
catch (URISyntaxException ex)
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java 2010-04-01
10:11:01 UTC (rev 11920)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java 2010-04-01
14:20:47 UTC (rev 11921)
@@ -26,6 +26,7 @@
import org.jboss.ws.core.soap.SOAPFaultImpl;
import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
import org.jboss.ws.extensions.addressing.metadata.AddressingOpMetaExt;
+import org.jboss.ws.metadata.umdm.FaultMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
import org.jboss.wsf.common.handler.GenericSOAPHandler;
@@ -36,8 +37,6 @@
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.FaultAction;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.addressing.AddressingBuilder;
import javax.xml.ws.addressing.JAXWSAConstants;
@@ -198,26 +197,24 @@
try
{
// supply the response action
+ CommonMessageContext commonCtx = (CommonMessageContext)msgContext;
+ OperationMetaData operationMD = commonCtx.getOperationMetaData();
+
+ AddressingOpMetaExt addressingMD =
(AddressingOpMetaExt)operationMD.getExtension(ADDR_CONSTANTS.getNamespaceURI());
+
+ if (addressingMD == null)
+ throw new IllegalStateException("Addressing meta data not
available");
- OperationMetaData opMetaData =
((CommonMessageContext)msgContext).getOperationMetaData();
-
- if (!isFault && !opMetaData.isOneWay())
+ if (!isFault && !operationMD.isOneWay())
{
-
- AddressingOpMetaExt addrExt =
(AddressingOpMetaExt)opMetaData.getExtension(ADDR_CONSTANTS.getNamespaceURI());
- if (addrExt != null)
- {
- outProps.setAction(ADDR_BUILDER.newURI(addrExt.getOutboundAction()));
- }
- else
- {
- log.warn("Unable to resolve replyAction for " + opMetaData.getQName());
- }
-
+ outProps.setAction(ADDR_BUILDER.newURI(addressingMD.getOutboundAction()));
}
else if (isFault)
{
- outProps.setAction(ADDR_BUILDER.newURI(ADDR_CONSTANTS.getDefaultFaultAction()));
+ Throwable exception = commonCtx.getCurrentException();
+ String faultAction = getFaultAction(operationMD, addressingMD, exception);
+
+ outProps.setAction(ADDR_BUILDER.newURI(faultAction));
}
}
@@ -229,7 +226,20 @@
outProps.writeHeaders(soapMessage);
}
- /* check wsa formal constraints */
+ private String getFaultAction(final OperationMetaData operationMD, final
AddressingOpMetaExt addressingMD, final Throwable exception)
+ {
+ final FaultMetaData faultMD = operationMD.getFaultMetaData(exception.getClass());
+
+ if (faultMD != null)
+ {
+ final String beanName = faultMD.getFaultBeanName();
+ return addressingMD.getFaultAction(beanName);
+ }
+
+ return ADDR_CONSTANTS.getDefaultFaultAction();
+ }
+
+ /* check wsa formal constraints */
private void validateRequest(SOAPAddressingProperties addrProps)
{
// If wsa:ReplyTo is supplied and the message lacks a [message id] property, the
processor MUST fault.