Author: richard.opalka(a)jboss.com
Date: 2010-04-30 03:47:03 -0400 (Fri, 30 Apr 2010)
New Revision: 12125
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchSOAPBinding.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/soap/SOAPAddressingPropertiesImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java
Log:
[JBWS-3008] ensuring proper Dispatch usage with @Addressing feature
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java 2010-04-30
07:31:52 UTC (rev 12124)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java 2010-04-30
07:47:03 UTC (rev 12125)
@@ -29,6 +29,7 @@
import java.util.concurrent.Future;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;
@@ -157,17 +158,13 @@
handlerResolver.initHandlerChain(ecmd, HandlerType.PRE, true);
handlerResolver.initHandlerChain(ecmd, HandlerType.ENDPOINT, true);
handlerResolver.initHandlerChain(ecmd, HandlerType.POST, true);
-
+
PortInfo portInfo = epMetaData.getPortInfo();
- List<Handler> preChain = handlerResolver.getHandlerChain(portInfo,
HandlerType.PRE);
- List<Handler> epChain = handlerResolver.getHandlerChain(portInfo,
HandlerType.ENDPOINT);
- List<Handler> postChain = handlerResolver.getHandlerChain(portInfo,
HandlerType.POST);
-
- binding.setHandlerChain(preChain, HandlerType.PRE);
- binding.setHandlerChain(epChain, HandlerType.ENDPOINT);
- binding.setHandlerChain(postChain, HandlerType.POST);
+ this.appendHandlers(HandlerType.PRE, portInfo, binding);
+ this.appendHandlers(HandlerType.ENDPOINT, portInfo, binding);
+ this.appendHandlers(HandlerType.POST, portInfo, binding);
}
-
+
retObj = invokeInternalSOAP(obj);
}
else
@@ -176,6 +173,21 @@
}
return retObj;
}
+
+ private void appendHandlers(final HandlerType handlerType, final PortInfo portInfo,
final BindingExt binding)
+ {
+ final List<Handler> resolverHandlerChain =
this.handlerResolver.getHandlerChain(portInfo, handlerType);
+ final List<Handler> bindingHandlerChain =
binding.getHandlerChain(handlerType);
+
+ if (bindingHandlerChain == null || bindingHandlerChain.size() == 0)
+ {
+ binding.setHandlerChain(resolverHandlerChain, handlerType);
+ }
+ else
+ {
+ bindingHandlerChain.addAll(resolverHandlerChain);
+ }
+ }
private Object invokeInternalSOAP(Object obj) throws Exception
{
@@ -261,7 +273,8 @@
if (handlerPass)
{
- retObj = getReturnObject(resMsg);
+ boolean unwrap = !(obj instanceof JAXBElement);
+ retObj = getReturnObject(resMsg, unwrap);
}
}
catch (Exception ex)
@@ -299,7 +312,8 @@
targetAddress = (String)
callProps.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
}
MessageAbstraction resMsg = getRemotingConnection().invoke(reqMsg, targetAddress,
false);
- Object retObj = getReturnObject(resMsg);
+ boolean unwrap = !(obj instanceof JAXBElement);
+ Object retObj = getReturnObject(resMsg, unwrap);
return retObj;
}
@@ -452,7 +466,7 @@
return message;
}
- private Object getReturnObject(MessageAbstraction resMsg)
+ private Object getReturnObject(MessageAbstraction resMsg, boolean unwrap)
{
String bindingID = bindingProvider.getBinding().getBindingID();
if (EndpointMetaData.SUPPORTED_BINDINGS.contains(bindingID) == false)
@@ -467,7 +481,7 @@
else
{
DispatchSOAPBinding helper = new DispatchSOAPBinding(mode, type, jaxbContext);
- retObj = helper.getReturnObject(resMsg);
+ retObj = helper.getReturnObject(resMsg, unwrap);
}
return retObj;
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchSOAPBinding.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchSOAPBinding.java 2010-04-30
07:31:52 UTC (rev 12124)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/DispatchSOAPBinding.java 2010-04-30
07:47:03 UTC (rev 12125)
@@ -142,7 +142,7 @@
return reqMsg;
}
- public Object getReturnObject(MessageAbstraction message)
+ public Object getReturnObject(MessageAbstraction message, boolean unwrap)
{
SOAPMessage resMsg = (SOAPMessage)message;
@@ -187,7 +187,7 @@
log.debug("JAXB unmarshal: " + DOMWriter.printNode(soapElement,
false));
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
retObj = unmarshaller.unmarshal(soapElement);
- if (retObj instanceof JAXBElement<?>)
+ if ((retObj instanceof JAXBElement<?>) && unwrap)
{
retObj = ((JAXBElement<?>)retObj).getValue();
}
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-30
07:31:52 UTC (rev 12124)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java 2010-04-30
07:47:03 UTC (rev 12125)
@@ -199,7 +199,7 @@
private AttributedURI getAction(final MessageContext msgContext)
{
- String action = null;
+ String action = "UNSPECIFIED";
if (msgContext.get(BindingProvider.SOAPACTION_URI_PROPERTY) != null)
action = msgContext.get(BindingProvider.SOAPACTION_URI_PROPERTY).toString();
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java 2010-04-30
07:31:52 UTC (rev 12124)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java 2010-04-30
07:47:03 UTC (rev 12125)
@@ -255,8 +255,7 @@
if (soapHeader == null)
{
- log.warn("No SOAP headers found!");
- return;
+ soapHeader = message.getSOAPPart().getEnvelope().addHeader();
}
// Add the xmlns:wsa declaration
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java 2010-04-30
07:31:52 UTC (rev 12124)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java 2010-04-30
07:47:03 UTC (rev 12125)
@@ -56,20 +56,22 @@
public <T extends EndpointReference> T getEndpointReference(final Class<T>
clazz, final Element... referenceParameters)
{
- EndpointMetaData epMetaData =
((CommonMessageContext)getMessageContext()).getEndpointMetaData();
- if (epMetaData == null)
+ EndpointMetaData endpointMD =
((CommonMessageContext)getMessageContext()).getEndpointMetaData();
+ if (endpointMD == null)
{
throw new WebServiceException("Cannot get EndpointMetaData!");
}
- if (HTTPBinding.HTTP_BINDING.equals(epMetaData.getBindingId()))
+ if (HTTPBinding.HTTP_BINDING.equals(endpointMD.getBindingId()))
{
throw new UnsupportedOperationException("Cannot get epr when using the
XML/HTTP binding");
}
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
- String address = epMetaData.getEndpointAddress();
+ String address = endpointMD.getEndpointAddress();
builder.address(address);
builder.wsdlDocumentLocation(address + "?wsdl");
- //TODO set other parameters in the builder
+ builder.serviceName(endpointMD.getServiceMetaData().getServiceName());
+ builder.endpointName(endpointMD.getPortName());
+
if (referenceParameters != null &&
W3CEndpointReference.class.getName().equals(clazz.getName()))
{
for (Element el : referenceParameters)