Split out WS-Addressing to multiple packages (SWS-84)
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -26,7 +26,10 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.soap.SoapHeaderElement;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.addressing.core.EndpointReference;
|
||||
import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
|
||||
import org.springframework.ws.soap.addressing.messageid.MessageIdStrategy;
|
||||
import org.springframework.ws.soap.addressing.version.WsAddressingVersion;
|
||||
import org.springframework.ws.soap.server.SoapEndpointInterceptor;
|
||||
import org.springframework.ws.transport.WebServiceConnection;
|
||||
import org.springframework.ws.transport.WebServiceMessageSender;
|
||||
@@ -59,9 +62,7 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor {
|
||||
URI faultAction) {
|
||||
Assert.notNull(version, "version must not be null");
|
||||
Assert.notNull(messageIdStrategy, "messageIdStrategy must not be null");
|
||||
if (messageSenders == null) {
|
||||
messageSenders = new WebServiceMessageSender[0];
|
||||
}
|
||||
Assert.notNull(messageSenders, "'messageSenders' must not be null");
|
||||
this.version = version;
|
||||
this.messageIdStrategy = messageIdStrategy;
|
||||
this.messageSenders = messageSenders;
|
||||
@@ -77,7 +78,7 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor {
|
||||
version.addMessageAddressingHeaderRequiredFault((SoapMessage) messageContext.getResponse());
|
||||
return false;
|
||||
}
|
||||
if (!requestMap.isValid() || messageIdStrategy.isDuplicate(requestMap.getMessageId())) {
|
||||
if (messageIdStrategy.isDuplicate(requestMap.getMessageId())) {
|
||||
version.addInvalidAddressingHeaderFault((SoapMessage) messageContext.getResponse());
|
||||
return false;
|
||||
}
|
||||
@@ -101,10 +102,11 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor {
|
||||
if (handleNoneAddress(messageContext, replyEpr)) {
|
||||
return false;
|
||||
}
|
||||
URI responseMessageId = getMessageId(messageContext);
|
||||
SoapMessage reply = (SoapMessage) messageContext.getResponse();
|
||||
URI replyMessageId = getMessageId(reply);
|
||||
URI action = !isFault ? replyAction : faultAction;
|
||||
MessageAddressingProperties replyMap = requestMap.getReplyProperties(replyEpr, action, responseMessageId);
|
||||
version.addAddressingHeaders((SoapMessage) messageContext.getResponse(), replyMap);
|
||||
MessageAddressingProperties replyMap = requestMap.getReplyProperties(replyEpr, action, replyMessageId);
|
||||
version.addAddressingHeaders(reply, replyMap);
|
||||
if (handleAnonymousAddress(messageContext, replyEpr)) {
|
||||
return true;
|
||||
}
|
||||
@@ -161,16 +163,16 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!supported) {
|
||||
if (!supported && logger.isWarnEnabled()) {
|
||||
logger.warn("Could not send out-of-band response to [" + replyEpr.getAddress() + "]. " +
|
||||
"Configure WebServiceMessageSenders which support this uri.");
|
||||
}
|
||||
}
|
||||
|
||||
private URI getMessageId(MessageContext messageContext) {
|
||||
URI responseMessageId = messageIdStrategy.newMessageId(messageContext);
|
||||
private URI getMessageId(SoapMessage response) {
|
||||
URI responseMessageId = messageIdStrategy.newMessageId(response);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Generated reply MessageID [" + responseMessageId + "] for [" + messageContext + "]");
|
||||
logger.trace("Generated reply MessageID [" + responseMessageId + "] for [" + response + "]");
|
||||
}
|
||||
return responseMessageId;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.version;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -38,6 +38,9 @@ import org.springframework.ws.soap.SoapFault;
|
||||
import org.springframework.ws.soap.SoapHeader;
|
||||
import org.springframework.ws.soap.SoapHeaderElement;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.addressing.WsAddressingException;
|
||||
import org.springframework.ws.soap.addressing.core.EndpointReference;
|
||||
import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
|
||||
import org.springframework.ws.soap.soap11.Soap11Body;
|
||||
import org.springframework.ws.soap.soap12.Soap12Body;
|
||||
import org.springframework.ws.soap.soap12.Soap12Fault;
|
||||
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.version;
|
||||
|
||||
import java.net.URI;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.springframework.ws.soap.addressing.core.EndpointReference;
|
||||
import org.springframework.xml.namespace.QNameUtils;
|
||||
|
||||
/**
|
||||
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.version;
|
||||
|
||||
import java.net.URI;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.springframework.ws.soap.addressing.core.EndpointReference;
|
||||
import org.springframework.xml.namespace.QNameUtils;
|
||||
|
||||
/**
|
||||
@@ -14,11 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.version;
|
||||
|
||||
import org.springframework.ws.soap.SoapFault;
|
||||
import org.springframework.ws.soap.SoapHeaderElement;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.addressing.core.EndpointReference;
|
||||
import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
|
||||
|
||||
/**
|
||||
* Defines the contract for a specific version of the WS-Addressing specification.
|
||||
@@ -29,7 +31,8 @@ import org.springframework.ws.soap.SoapMessage;
|
||||
public interface WsAddressingVersion {
|
||||
|
||||
/**
|
||||
* Returns the {@link MessageAddressingProperties} for the given message.
|
||||
* Returns the {@link org.springframework.ws.soap.addressing.core.MessageAddressingProperties} for the given
|
||||
* message.
|
||||
*
|
||||
* @param message the message to find the map for
|
||||
* @return the message addressing properties
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) 2007, Your Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.server;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Iterator;
|
||||
@@ -13,7 +13,10 @@ import org.easymock.MockControl;
|
||||
import org.springframework.ws.context.DefaultMessageContext;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.soap.SoapHeaderElement;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.addressing.AbstractWsAddressingTestCase;
|
||||
import org.springframework.ws.soap.addressing.messageid.MessageIdStrategy;
|
||||
import org.springframework.ws.soap.addressing.version.WsAddressingVersion;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessage;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.ws.transport.WebServiceConnection;
|
||||
@@ -76,7 +79,7 @@ public abstract class AbstractAddressingInterceptorTestCase extends AbstractWsAd
|
||||
SaajSoapMessage valid = loadSaajMessage(getTestPath() + "/request-no-reply-to.xml");
|
||||
MessageContext context = new DefaultMessageContext(valid, new SaajSoapMessageFactory(messageFactory));
|
||||
URI messageId = new URI("uid:1234");
|
||||
strategyControl.expectAndReturn(strategyMock.newMessageId(context), messageId);
|
||||
strategyControl.expectAndReturn(strategyMock.newMessageId((SoapMessage) context.getResponse()), messageId);
|
||||
strategyControl.replay();
|
||||
boolean result = interceptor.handleResponse(context, null);
|
||||
assertTrue("Request with no ReplyTo not handled", result);
|
||||
@@ -91,7 +94,7 @@ public abstract class AbstractAddressingInterceptorTestCase extends AbstractWsAd
|
||||
SaajSoapMessage valid = loadSaajMessage(getTestPath() + "/request-anonymous.xml");
|
||||
MessageContext context = new DefaultMessageContext(valid, new SaajSoapMessageFactory(messageFactory));
|
||||
URI messageId = new URI("uid:1234");
|
||||
strategyControl.expectAndReturn(strategyMock.newMessageId(context), messageId);
|
||||
strategyControl.expectAndReturn(strategyMock.newMessageId((SoapMessage) context.getResponse()), messageId);
|
||||
strategyControl.replay();
|
||||
boolean result = interceptor.handleResponse(context, null);
|
||||
assertTrue("Request with anonymous ReplyTo not handled", result);
|
||||
@@ -117,7 +120,7 @@ public abstract class AbstractAddressingInterceptorTestCase extends AbstractWsAd
|
||||
SaajSoapMessage response = (SaajSoapMessage) context.getResponse();
|
||||
response.getSoapBody().addServerOrReceiverFault("Error", Locale.ENGLISH);
|
||||
URI messageId = new URI("uid:1234");
|
||||
strategyControl.expectAndReturn(strategyMock.newMessageId(context), messageId);
|
||||
strategyControl.expectAndReturn(strategyMock.newMessageId((SoapMessage) context.getResponse()), messageId);
|
||||
strategyControl.replay();
|
||||
boolean result = interceptor.handleFault(context, null);
|
||||
assertTrue("Request with anonymous FaultTo not handled", result);
|
||||
@@ -144,7 +147,7 @@ public abstract class AbstractAddressingInterceptorTestCase extends AbstractWsAd
|
||||
SaajSoapMessage response = (SaajSoapMessage) context.getResponse();
|
||||
|
||||
URI messageId = new URI("uid:1234");
|
||||
strategyControl.expectAndReturn(strategyMock.newMessageId(context), messageId);
|
||||
strategyControl.expectAndReturn(strategyMock.newMessageId((SoapMessage) context.getResponse()), messageId);
|
||||
|
||||
URI uri = new URI("http://example.com/business/client1");
|
||||
senderControl.expectAndReturn(senderMock.supports(uri), true);
|
||||
@@ -2,7 +2,10 @@
|
||||
* Copyright (c) 2007, Your Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.server;
|
||||
|
||||
import org.springframework.ws.soap.addressing.version.WsAddressing200408;
|
||||
import org.springframework.ws.soap.addressing.version.WsAddressingVersion;
|
||||
|
||||
public class AddressingInterceptor200408Test extends AbstractAddressingInterceptorTestCase {
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
* Copyright (c) 2007, Your Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.server;
|
||||
|
||||
import org.springframework.ws.soap.addressing.version.WsAddressing200605;
|
||||
import org.springframework.ws.soap.addressing.version.WsAddressingVersion;
|
||||
|
||||
public class AddressingInterceptor200605Test extends AbstractAddressingInterceptorTestCase {
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.soap.addressing;
|
||||
package org.springframework.ws.soap.addressing.server;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -24,6 +25,7 @@ import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.server.EndpointInterceptor;
|
||||
import org.springframework.ws.server.EndpointInvocationChain;
|
||||
import org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor;
|
||||
import org.springframework.ws.soap.addressing.AbstractWsAddressingTestCase;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessage;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;
|
||||
@@ -34,17 +36,16 @@ public class SimpleActionEndpointMappingTest extends AbstractWsAddressingTestCas
|
||||
|
||||
private Endpoint1 endpoint1;
|
||||
|
||||
private Endpoint2 endpoint2;
|
||||
|
||||
protected void onSetUp() throws Exception {
|
||||
mapping = new SimpleActionEndpointMapping();
|
||||
Map map = new HashMap();
|
||||
endpoint1 = new Endpoint1();
|
||||
endpoint2 = new Endpoint2();
|
||||
Endpoint2 endpoint2 = new Endpoint2();
|
||||
map.put("http://fabrikam123.example/mail/Delete", endpoint1);
|
||||
map.put("http://fabrikam123.example/mail/Add", endpoint2);
|
||||
mapping.setPreInterceptors(new EndpointInterceptor[]{new PayloadLoggingInterceptor()});
|
||||
mapping.setPostInterceptors(new EndpointInterceptor[]{new PayloadValidatingInterceptor()});
|
||||
mapping.setAddress(new URI("mailto:joe@fabrikam123.example"));
|
||||
mapping.setActionMap(map);
|
||||
mapping.afterPropertiesSet();
|
||||
}
|
||||
Reference in New Issue
Block a user