SWS-520 - HTTP Accept header field contains invalid type, and omits text/xml

This commit is contained in:
Arjen Poutsma
2009-06-02 14:28:53 +00:00
parent 2be929febd
commit 51db8f012c
5 changed files with 25 additions and 11 deletions

View File

@@ -232,13 +232,17 @@ public class AxiomSoapMessage extends AbstractSoapMessage {
String charsetEncoding = axiomMessage.getCharsetEncoding();
contentType += "; charset=" + charsetEncoding;
}
if (SoapVersion.SOAP_11 == getVersion()) {
SoapVersion version = getVersion();
if (SoapVersion.SOAP_11 == version) {
transportOutputStream.addHeader(TransportConstants.HEADER_SOAP_ACTION, soapAction);
transportOutputStream.addHeader(TransportConstants.HEADER_ACCEPT, version.getContentType());
}
else if (SoapVersion.SOAP_12 == getVersion()) {
else if (SoapVersion.SOAP_12 == version) {
contentType += "; action=" + soapAction;
transportOutputStream.addHeader(TransportConstants.HEADER_ACCEPT, version.getContentType());
}
transportOutputStream.addHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType);
}
if (!(outputFormat.isOptimized()) & outputFormat.isDoingSWA()) {
writeSwAMessage(outputStream, outputFormat);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -155,6 +155,10 @@ public class SaajSoapMessage extends AbstractSoapMessage {
}
public void writeTo(OutputStream outputStream) throws IOException {
MimeHeaders mimeHeaders = getImplementation().getMimeHeaders(getSaajMessage());
if (ObjectUtils.isEmpty(mimeHeaders.getHeader(TransportConstants.HEADER_ACCEPT))) {
mimeHeaders.setHeader(TransportConstants.HEADER_ACCEPT, getVersion().getContentType());
}
try {
getImplementation().writeTo(getSaajMessage(), outputStream);
outputStream.flush();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,9 @@ package org.springframework.ws.transport;
*/
public interface TransportConstants {
/** The "Accept" header. */
String HEADER_ACCEPT = "Accept";
/** The "Content-Id" header. */
String HEADER_CONTENT_ID = "Content-Id";
@@ -42,8 +45,6 @@ public interface TransportConstants {
/** The "action" parameter, used to set SOAP Actions in SOAP 1.2. */
String PARAMETER_ACTION = "action";
/**
* The empty SOAP action value.
*/
/** The empty SOAP action value. */
String EMPTY_SOAP_ACTION = "\"\"";
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,6 +58,8 @@ public abstract class AbstractSoap11MessageTestCase extends AbstractSoapMessageT
assertTrue("Invalid Content-Type set", contentType.indexOf(SoapVersion.SOAP_11.getContentType()) != -1);
String resultSoapAction = (String) tos.getHeaders().get("SOAPAction");
assertEquals("Invalid soap action", "\"" + soapAction + "\"", resultSoapAction);
String resultAccept = (String) tos.getHeaders().get("Accept");
assertNotNull("Invalid accept header", resultAccept);
}
public void testWriteToTransportResponseAttachment() throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,8 +58,11 @@ public abstract class AbstractSoap12MessageTestCase extends AbstractSoapMessageT
result);
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));
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);
String resultAccept = (String) tos.getHeaders().get("Accept");
assertNotNull("Invalid accept header", resultAccept);
}
public void testWriteToTransportResponseAttachment() throws Exception {
@@ -74,5 +77,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);
}
}