This commit is contained in:
Arjen Poutsma
2008-09-26 13:55:45 +00:00
parent 1545bd2c60
commit e6423696f3
4 changed files with 21 additions and 6 deletions

View File

@@ -36,6 +36,14 @@ public interface TransportConstants {
/** The "Content-Type" header. */
String HEADER_CONTENT_TYPE = "Content-Type";
/** The "SOAPAction" header. */
/** The "SOAPAction" header, used in SOAP 1.1. */
String HEADER_SOAP_ACTION = "SOAPAction";
/** The "action" parameter, used to set SOAP Actions in SOAP 1.2. */
String PARAMETER_ACTION = "action";
/**
* The empty SOAP action value.
*/
String EMPTY_SOAP_ACTION = "\"\"";
}

View File

@@ -41,7 +41,7 @@ public abstract class AbstractSoap11MessageFactoryTestCase extends AbstractSoapM
InputStream is = AbstractSoap11MessageFactoryTestCase.class.getResourceAsStream("soap11.xml");
Properties headers = new Properties();
headers.setProperty("Content-Type", "text/xml");
String soapAction = "http://springframework.org/spring-ws/Action";
String soapAction = "\"http://springframework.org/spring-ws/Action\"";
headers.setProperty("SOAPAction", soapAction);
TransportInputStream tis = new MockTransportInputStream(is, headers);

View File

@@ -27,6 +27,7 @@ import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.transport.MockTransportInputStream;
import org.springframework.ws.transport.TransportInputStream;
import org.springframework.ws.transport.TransportConstants;
public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapMessageFactoryTestCase {
@@ -40,13 +41,15 @@ public abstract class AbstractSoap12MessageFactoryTestCase extends AbstractSoapM
public void testCreateSoapMessageNoAttachment() throws Exception {
InputStream is = AbstractSoap12MessageFactoryTestCase.class.getResourceAsStream("soap12.xml");
final Properties headers = new Properties();
headers.setProperty("Content-Type", "application/soap+xml");
String soapAction = "\"http://springframework.org/spring-ws/Action\"";
headers.setProperty(TransportConstants.HEADER_CONTENT_TYPE, "application/soap+xml; action=" + soapAction);
TransportInputStream tis = new MockTransportInputStream(is, headers);
WebServiceMessage message = messageFactory.createWebServiceMessage(tis);
assertTrue("Not a SoapMessage", message instanceof SoapMessage);
SoapMessage soapMessage = (SoapMessage) message;
assertEquals("Invalid soap version", SoapVersion.SOAP_12, soapMessage.getVersion());
assertEquals("Invalid soap action", soapAction, soapMessage.getSoapAction());
assertFalse("Message is a XOP pacakge", soapMessage.isXopPackage());
}

View File

@@ -28,6 +28,7 @@ import org.springframework.ws.soap.AbstractSoapMessageTestCase;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.transport.MockTransportOutputStream;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.xml.transform.StringSource;
public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageTestCase {
@@ -48,13 +49,17 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
MockTransportOutputStream tos = new MockTransportOutputStream(bos);
String soapAction = "http://springframework.org/spring-ws/Action";
soapMessage.setSoapAction(soapAction);
soapMessage.writeTo(tos);
String result = bos.toString("UTF-8");
assertXMLEqual(
"<Envelope xmlns='http://www.w3.org/2003/05/soap-envelope'><Body><payload xmlns='http://www.springframework.org' /></Body></Envelope>",
result);
String contentType = (String) tos.getHeaders().get("Content-Type");
String contentType = (String) tos.getHeaders().get(TransportConstants.HEADER_CONTENT_TYPE);
assertTrue("Invalid Content-Type set", contentType.indexOf(SoapVersion.SOAP_12.getContentType()) != -1);
assertNull(TransportConstants.HEADER_SOAP_ACTION + " header must not be found", tos.getHeaders().get(TransportConstants.HEADER_SOAP_ACTION));
assertTrue("Invalid Content-Type set", contentType.indexOf(soapAction) != -1);
}
public void testWriteToTransportResponseAttachment() throws Exception {
@@ -69,6 +74,5 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT
assertTrue("Content-Type for attachment message does not contains type=\"application/soap+xml\"",
contentType.indexOf("type=\"application/soap+xml\"") != -1);
}
}