diff --git a/pom.xml b/pom.xml index 6c56aa88..57f778ee 100644 --- a/pom.xml +++ b/pom.xml @@ -658,6 +658,7 @@ http://www.extreme.indiana.edu/apis/wsdl4j/ http://jakarta.apache.org/commons/httpclient/apidocs/ http://ws.apache.org/wss4j/apidocs/ + http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/ diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 3e31c9a1..2b33fb5e 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -62,18 +62,10 @@ org.springframework spring-webmvc - - org.springframework - spring-mock - org.springframework spring-jms - - org.springframework - spring-remoting - org.springframework spring-jmx diff --git a/sandbox/src/main/java/org/springframework/ws/transport/http/HttpServerFactoryBean.java b/sandbox/src/main/java/org/springframework/ws/transport/http/HttpServerFactoryBean.java deleted file mode 100644 index f9a349eb..00000000 --- a/sandbox/src/main/java/org/springframework/ws/transport/http/HttpServerFactoryBean.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2007 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.transport.http; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.UnknownHostException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; - -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.Lifecycle; -import org.springframework.util.Assert; - -/** - * Factory bean for the HTTP server built into Java 6. - * - * @author Arjen Poutsma - * @see - * @since 1.5.0 - */ -public class HttpServerFactoryBean implements ApplicationContextAware, InitializingBean, Lifecycle, FactoryBean { - - private static final Log logger = LogFactory.getLog(HttpServerFactoryBean.class); - - public static final int DEFAULT_PORT = 8080; - - private InetAddress bindAddress; - - private int port = DEFAULT_PORT; - - private int backlog = -1; - - private boolean autoStartup = true; - - private boolean running = false; - - private final Object lifecycleMonitor = new Object(); - - private HttpServer httpServer; - - private Map handlerMap = new HashMap(); - - private ApplicationContext applicationContext; - - /** - * Set whether to automatically start the receiver after initialization. - *

- * Default is true; set this to false to allow for manual startup. - */ - public void setAutoStartup(boolean autoStartup) { - this.autoStartup = autoStartup; - } - - /** Sets the port the server will bind to. */ - public void setPort(int port) { - this.port = port; - } - - /** Sets the server back log. */ - public void setBacklog(int backlog) { - this.backlog = backlog; - } - - public void setHandlers(Properties handlers) { - this.handlerMap.putAll(handlers); - } - - public void setHandlerMap(Map handlerMap) { - this.handlerMap.putAll(handlerMap); - } - - /** - * Sets the local internet address the server will bind to. By default, it will accept connections on any/all local - * addresses. - * - * @throws UnknownHostException when the given address is not known - * @see ServerSocket#ServerSocket(int,int,java.net.InetAddress) - */ - public void setBindAddress(String bindAddress) throws UnknownHostException { - this.bindAddress = InetAddress.getByName(bindAddress); - } - - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - - public void afterPropertiesSet() throws IOException { - if (bindAddress == null) { - bindAddress = InetAddress.getLocalHost(); - } - InetSocketAddress bindSocketAddress = new InetSocketAddress(bindAddress, port); - httpServer = HttpServer.create(bindSocketAddress, backlog); - registerContexts(this.handlerMap); - if (autoStartup) { - start(); - } - } - - protected void registerContexts(Map handlerMap) { - if (handlerMap.isEmpty()) { - logger.warn("Neither 'contextMap' nor 'contexts' set on HttpServerFactoryBean"); - } - else { - Iterator it = handlerMap.keySet().iterator(); - while (it.hasNext()) { - String path = (String) it.next(); - Object handler = handlerMap.get(path); - // Prepend with slash if not already present. - if (!path.startsWith("/")) { - path = "/" + path; - } - registerHandler(path, handler); - } - } - } - - protected void registerHandler(String path, Object handler) throws BeansException, IllegalStateException { - Assert.notNull(path, "Path must not be null"); - Assert.notNull(handler, "Handler object must not be null"); - - // Eagerly resolve handler if referencing singleton via name. - if (handler instanceof String) { - String handlerName = (String) handler; - if (applicationContext.isSingleton(handlerName)) { - handler = applicationContext.getBean(handlerName, HttpHandler.class); - } - } - if (handler == null || !(handler instanceof HttpHandler)) { - throw new IllegalStateException("Cannot resolve handler [" + handler + "] to HttpHandler instance"); - } - httpServer.createContext(path, (HttpHandler) handler); - if (logger.isDebugEnabled()) { - logger.debug("Mapped path [" + path + "] onto handler [" + handler + "]"); - } - } - - public void start() { - if (logger.isInfoEnabled()) { - logger.info("Starting HttpServer [" + httpServer.getAddress() + "]"); - } - synchronized (lifecycleMonitor) { - running = true; - lifecycleMonitor.notifyAll(); - } - httpServer.start(); - } - - public void stop() { - synchronized (lifecycleMonitor) { - running = false; - lifecycleMonitor.notifyAll(); - } - httpServer.stop(0); - } - - public boolean isRunning() { - synchronized (lifecycleMonitor) { - return running; - } - } - - public Object getObject() throws Exception { - return httpServer; - } - - public Class getObjectType() { - return HttpServer.class; - } - - public boolean isSingleton() { - return true; - } -} diff --git a/sandbox/src/test/java/org/springframework/ws/transport/http/Driver.java b/sandbox/src/test/java/org/springframework/ws/transport/http/Driver.java deleted file mode 100644 index 44c9ded6..00000000 --- a/sandbox/src/test/java/org/springframework/ws/transport/http/Driver.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2007 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.transport.http; - -import java.io.IOException; - -import com.sun.net.httpserver.HttpServer; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class Driver { - - public static void main(String[] args) throws IOException { - ApplicationContext context = - new ClassPathXmlApplicationContext("httpserver-applicationContext.xml", Driver.class); - HttpServer server = (HttpServer) context.getBean("httpServer"); - System.in.read(); - } - -} diff --git a/sandbox/src/test/java/org/springframework/ws/transport/http/DummyHandler.java b/sandbox/src/test/java/org/springframework/ws/transport/http/DummyHandler.java deleted file mode 100644 index 6540fb1d..00000000 --- a/sandbox/src/test/java/org/springframework/ws/transport/http/DummyHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2007 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.transport.http; - -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; - -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; - -import org.springframework.util.FileCopyUtils; - -/** - * @author Arjen Poutsma - * @since 1.5.0 - */ -public class DummyHandler implements HttpHandler { - - public void handle(HttpExchange exchange) throws IOException { - - ByteArrayOutputStream os = new ByteArrayOutputStream(); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os)); - writer.write("Hello world!"); - writer.flush(); - - byte[] buf = os.toByteArray(); - exchange.sendResponseHeaders(HttpTransportConstants.STATUS_OK, buf.length); - FileCopyUtils.copy(buf, exchange.getResponseBody()); - exchange.close(); - } -} diff --git a/sandbox/src/test/java/org/springframework/ws/transport/http/HttpServerFactoryBeanTest.java b/sandbox/src/test/java/org/springframework/ws/transport/http/HttpServerFactoryBeanTest.java deleted file mode 100644 index 349a3d5c..00000000 --- a/sandbox/src/test/java/org/springframework/ws/transport/http/HttpServerFactoryBeanTest.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright ${YEAR} 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ws.transport.http; - -import junit.framework.TestCase; - -public class HttpServerFactoryBeanTest extends TestCase { - - private HttpServerFactoryBean bean; - - protected void setUp() throws Exception { - bean = new HttpServerFactoryBean(); - } -} \ No newline at end of file diff --git a/sandbox/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml b/sandbox/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml deleted file mode 100644 index c9cd80b0..00000000 --- a/sandbox/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - handler - - - - - - - diff --git a/support/pom.xml b/support/pom.xml index 070b3c4f..186ef6b7 100644 --- a/support/pom.xml +++ b/support/pom.xml @@ -1,4 +1,5 @@ - + spring-ws-parent org.springframework.ws @@ -117,5 +118,10 @@ 1.6 test + + commons-httpclient + commons-httpclient + test + diff --git a/sandbox/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java b/support/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java similarity index 76% rename from sandbox/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java rename to support/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java index fae49d5a..a095fdcb 100644 --- a/sandbox/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java +++ b/support/src/main/java/org/springframework/ws/transport/http/HttpExchangeConnection.java @@ -20,6 +20,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.URI; +import java.net.URISyntaxException; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -49,6 +51,8 @@ public class HttpExchangeConnection extends AbstractReceiverConnection private int responseStatusCode = HttpTransportConstants.STATUS_ACCEPTED; + private boolean chunkedEncoding; + /** Constructs a new exchange connection with the given HttpExchange. */ protected HttpExchangeConnection(HttpExchange httpExchange) { Assert.notNull(httpExchange, "'httpExchange' must not be null"); @@ -60,12 +64,16 @@ public class HttpExchangeConnection extends AbstractReceiverConnection return httpExchange; } - public void endpointNotFound() { - responseStatusCode = HttpTransportConstants.STATUS_NOT_FOUND; + public URI getUri() throws URISyntaxException { + return httpExchange.getRequestURI(); } - protected void onClose() throws IOException { - httpExchange.close(); + void setChunkedEncoding(boolean chunkedEncoding) { + this.chunkedEncoding = chunkedEncoding; + } + + public void endpointNotFound() { + responseStatusCode = HttpTransportConstants.STATUS_NOT_FOUND; } /* @@ -106,17 +114,34 @@ public class HttpExchangeConnection extends AbstractReceiverConnection } protected OutputStream getResponseOutputStream() throws IOException { - if (responseBuffer == null) { - responseBuffer = new ByteArrayOutputStream(); + if (chunkedEncoding) { + httpExchange.sendResponseHeaders(responseStatusCode, 0); + return httpExchange.getResponseBody(); + } + else { + if (responseBuffer == null) { + responseBuffer = new ByteArrayOutputStream(); + } + return responseBuffer; } - return responseBuffer; } protected void onSendAfterWrite(WebServiceMessage message) throws IOException { - byte[] buf = responseBuffer.toByteArray(); - httpExchange.sendResponseHeaders(responseStatusCode, buf.length); - OutputStream responseBody = httpExchange.getResponseBody(); - FileCopyUtils.copy(buf, responseBody); + if (!chunkedEncoding) { + byte[] buf = responseBuffer.toByteArray(); + httpExchange.sendResponseHeaders(responseStatusCode, buf.length); + OutputStream responseBody = httpExchange.getResponseBody(); + FileCopyUtils.copy(buf, responseBody); + } + responseBuffer = null; + } + + public void onClose() throws IOException { + if (responseStatusCode == HttpTransportConstants.STATUS_ACCEPTED || + responseStatusCode == HttpTransportConstants.STATUS_NOT_FOUND) { + httpExchange.sendResponseHeaders(responseStatusCode, -1); + } + httpExchange.close(); } /* diff --git a/sandbox/src/main/java/org/springframework/ws/transport/http/WebServiceHttpHandler.java b/support/src/main/java/org/springframework/ws/transport/http/WebServiceHttpHandler.java similarity index 56% rename from sandbox/src/main/java/org/springframework/ws/transport/http/WebServiceHttpHandler.java rename to support/src/main/java/org/springframework/ws/transport/http/WebServiceHttpHandler.java index e9179377..446bcc26 100644 --- a/sandbox/src/main/java/org/springframework/ws/transport/http/WebServiceHttpHandler.java +++ b/support/src/main/java/org/springframework/ws/transport/http/WebServiceHttpHandler.java @@ -21,18 +21,34 @@ import java.io.IOException; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; -import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.support.SimpleWebServiceMessageReceiverObjectSupport; /** + * {@link HttpHandler} that can be used to handle incoming {@link HttpExchange} service requests. Designed for Sun's JRE + * 1.6 HTTP server. + *

+ * Requires a {@link org.springframework.ws.WebServiceMessageFactory} which is used to convert the incoming {@link + * HttpExchange} into a {@link org.springframework.ws.WebServiceMessage}, and passes that to the {@link + * org.springframework.ws.transport.WebServiceMessageReceiver} {@link #setMessageReceiver(org.springframework.ws.transport.WebServiceMessageReceiver) + * registered}. + * * @author Arjen Poutsma + * @see org.springframework.remoting.support.SimpleHttpServerFactoryBean * @since 1.5.0 */ public class WebServiceHttpHandler extends SimpleWebServiceMessageReceiverObjectSupport implements HttpHandler { + private boolean chunkedEncoding = false; + + /** Enables chunked encoding on response bodies. Defaults to false. */ + public void setChunkedEncoding(boolean chunkedEncoding) { + this.chunkedEncoding = chunkedEncoding; + } + public void handle(HttpExchange httpExchange) throws IOException { - if ("POST".equals(httpExchange.getRequestMethod())) { - WebServiceConnection connection = new HttpExchangeConnection(httpExchange); + if (HttpTransportConstants.METHOD_POST.equals(httpExchange.getRequestMethod())) { + HttpExchangeConnection connection = new HttpExchangeConnection(httpExchange); + connection.setChunkedEncoding(chunkedEncoding); try { handleConnection(connection); } diff --git a/core/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java b/support/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java similarity index 99% rename from core/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java rename to support/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java index 69cfb2ee..c7dc5523 100644 --- a/core/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java +++ b/support/src/test/java/org/springframework/ws/transport/http/FaultEndpoint.java @@ -28,4 +28,4 @@ public class FaultEndpoint implements MessageEndpoint { SoapMessage response = (SoapMessage) messageContext.getResponse(); response.getSoapBody().addServerOrReceiverFault("Something went wrong", Locale.ENGLISH); } -} +} \ No newline at end of file diff --git a/core/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java b/support/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java similarity index 99% rename from core/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java rename to support/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java index 38e77ef2..d7746f68 100644 --- a/core/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java +++ b/support/src/test/java/org/springframework/ws/transport/http/NoResponseEndpoint.java @@ -24,4 +24,4 @@ public class NoResponseEndpoint implements MessageEndpoint { public void invoke(MessageContext messageContext) throws Exception { } -} +} \ No newline at end of file diff --git a/core/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java b/support/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java similarity index 99% rename from core/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java rename to support/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java index 4d876d3e..672bf43d 100644 --- a/core/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java +++ b/support/src/test/java/org/springframework/ws/transport/http/ResponseEndpoint.java @@ -25,4 +25,4 @@ public class ResponseEndpoint implements MessageEndpoint { public void invoke(MessageContext messageContext) throws Exception { messageContext.getResponse(); } -} +} \ No newline at end of file diff --git a/support/src/test/java/org/springframework/ws/transport/http/WebServiceHttpHandlerIntegrationTest.java b/support/src/test/java/org/springframework/ws/transport/http/WebServiceHttpHandlerIntegrationTest.java new file mode 100644 index 00000000..fec7b8bd --- /dev/null +++ b/support/src/test/java/org/springframework/ws/transport/http/WebServiceHttpHandlerIntegrationTest.java @@ -0,0 +1,100 @@ +/* + * Copyright ${YEAR} 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.transport.http; + +import java.io.IOException; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.InputStreamRequestEntity; +import org.apache.commons.httpclient.methods.PostMethod; + +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.test.AbstractDependencyInjectionSpringContextTests; +import org.springframework.ws.transport.TransportConstants; + +public class WebServiceHttpHandlerIntegrationTest extends AbstractDependencyInjectionSpringContextTests { + + private HttpClient client; + + protected String[] getConfigLocations() { + return new String[]{"classpath:org/springframework/ws/transport/http/httpserver-applicationContext.xml"}; + } + + protected void onSetUp() throws Exception { + client = new HttpClient(); + } + + public void testInvalidMethod() throws IOException { + GetMethod getMethod = new GetMethod("http://localhost:8888/service"); + client.executeMethod(getMethod); + assertEquals("Invalid Response Code", HttpTransportConstants.STATUS_METHOD_NOT_ALLOWED, + getMethod.getStatusCode()); + assertEquals("Response retrieved", 0, getMethod.getResponseContentLength()); + } + + public void testNoResponse() throws IOException { + PostMethod postMethod = new PostMethod("http://localhost:8888/service"); + postMethod.addRequestHeader(HttpTransportConstants.HEADER_CONTENT_TYPE, "text/xml"); + postMethod.addRequestHeader(TransportConstants.HEADER_SOAP_ACTION, + "http://springframework.org/spring-ws/NoResponse"); + Resource soapRequest = new ClassPathResource("soapRequest.xml", WebServiceHttpHandlerIntegrationTest.class); + postMethod.setRequestEntity(new InputStreamRequestEntity(soapRequest.getInputStream())); + client.executeMethod(postMethod); + assertEquals("Invalid Response Code", HttpTransportConstants.STATUS_ACCEPTED, postMethod.getStatusCode()); + assertEquals("Response retrieved", 0, postMethod.getResponseContentLength()); + } + + public void testResponse() throws IOException { + PostMethod postMethod = new PostMethod("http://localhost:8888/service"); + postMethod.addRequestHeader(HttpTransportConstants.HEADER_CONTENT_TYPE, "text/xml"); + postMethod.addRequestHeader(TransportConstants.HEADER_SOAP_ACTION, + "http://springframework.org/spring-ws/Response"); + Resource soapRequest = new ClassPathResource("soapRequest.xml", WebServiceHttpHandlerIntegrationTest.class); + postMethod.setRequestEntity(new InputStreamRequestEntity(soapRequest.getInputStream())); + client.executeMethod(postMethod); + assertEquals("Invalid Response Code", HttpTransportConstants.STATUS_OK, postMethod.getStatusCode()); + assertTrue("No Response retrieved", postMethod.getResponseContentLength() > 0); + } + + public void testNoEndpoint() throws IOException { + PostMethod postMethod = new PostMethod("http://localhost:8888/service"); + postMethod.addRequestHeader(HttpTransportConstants.HEADER_CONTENT_TYPE, "text/xml"); + postMethod.addRequestHeader(TransportConstants.HEADER_SOAP_ACTION, + "http://springframework.org/spring-ws/NoEndpoint"); + Resource soapRequest = new ClassPathResource("soapRequest.xml", WebServiceHttpHandlerIntegrationTest.class); + postMethod.setRequestEntity(new InputStreamRequestEntity(soapRequest.getInputStream())); + client.executeMethod(postMethod); + assertEquals("Invalid Response Code", HttpTransportConstants.STATUS_NOT_FOUND, postMethod.getStatusCode()); + assertEquals("Response retrieved", 0, postMethod.getResponseContentLength()); + } + + public void testFault() throws IOException { + PostMethod postMethod = new PostMethod("http://localhost:8888/service"); + postMethod.addRequestHeader(HttpTransportConstants.HEADER_CONTENT_TYPE, "text/xml"); + postMethod + .addRequestHeader(TransportConstants.HEADER_SOAP_ACTION, "http://springframework.org/spring-ws/Fault"); + Resource soapRequest = new ClassPathResource("soapRequest.xml", WebServiceHttpHandlerIntegrationTest.class); + postMethod.setRequestEntity(new InputStreamRequestEntity(soapRequest.getInputStream())); + client.executeMethod(postMethod); + assertEquals("Invalid Response Code", HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR, + postMethod.getStatusCode()); + assertTrue("No Response retrieved", postMethod.getResponseContentLength() > 0); + } + +} \ No newline at end of file diff --git a/support/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml b/support/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml new file mode 100644 index 00000000..79d02920 --- /dev/null +++ b/support/src/test/resources/org/springframework/ws/transport/http/httpserver-applicationContext.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + noResponseEndpoint + responseEndpoint + faultEndpoint + + + + + + + + + + + + diff --git a/support/src/test/resources/org/springframework/ws/transport/http/soapRequest.xml b/support/src/test/resources/org/springframework/ws/transport/http/soapRequest.xml new file mode 100644 index 00000000..199de8ec --- /dev/null +++ b/support/src/test/resources/org/springframework/ws/transport/http/soapRequest.xml @@ -0,0 +1,7 @@ + + + + DIS + + + \ No newline at end of file