You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/03/09 15:25:00 UTC
svn commit: r516414 - in
/incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src:
main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
test/java/org/apache/servicemix/http/HttpSoapTest.java
Author: gnodet
Date: Fri Mar 9 06:25:00 2007
New Revision: 516414
URL: http://svn.apache.org/viewvc?view=rev&rev=516414
Log:
SM-873, SM-874: invalid faults returned when the xml is invalid / soap version not honored
Modified:
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java
Modified: incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?view=diff&rev=516414&r1=516413&r2=516414
==============================================================================
--- incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Fri Mar 9 06:25:00 2007
@@ -30,6 +30,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
@@ -51,6 +52,7 @@
import org.apache.servicemix.soap.marshalers.JBIMarshaler;
import org.apache.servicemix.soap.marshalers.SoapMessage;
import org.apache.servicemix.soap.marshalers.SoapWriter;
+import org.mortbay.jetty.RetryRequest;
import org.mortbay.util.ajax.Continuation;
import org.mortbay.util.ajax.ContinuationSupport;
import org.w3c.dom.Node;
@@ -192,7 +194,13 @@
}
request.removeAttribute(MessageExchange.class.getName());
}
+ } catch (RetryRequest retry) {
+ throw retry;
} catch (SoapFault fault) {
+ sendFault(fault, request, response);
+ return;
+ } catch (Exception e) {
+ SoapFault fault = new SoapFault(e);
sendFault(fault, request, response);
return;
}
Modified: incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java?view=diff&rev=516414&r1=516413&r2=516414
==============================================================================
--- incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java (original)
+++ incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java Fri Mar 9 06:25:00 2007
@@ -44,6 +44,8 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.client.DefaultServiceMixClient;
import org.apache.servicemix.client.Destination;
import org.apache.servicemix.client.ServiceMixClient;
@@ -67,6 +69,7 @@
import com.ibm.wsdl.util.xml.DOMUtils;
public class HttpSoapTest extends TestCase {
+ private static Log logger = LogFactory.getLog(HttpSoapTest.class);
protected JBIContainer container;
@@ -177,7 +180,7 @@
assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
String str = new SourceTransformer().contentToString(me.getOutMessage());
client.done(me);
- System.err.println(str);
+ logger.info(str);
}
public void testSoapRoundtripProviderConsumerProvider() throws Exception {
@@ -230,7 +233,7 @@
assertEquals(HttpServletResponse.SC_OK, state);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileUtil.copyInputStream(method.getResponseBodyAsStream(), baos);
- System.err.println(baos.toString());
+ logger.info(baos.toString());
}
public void testSoapFault12() throws Exception {
@@ -286,7 +289,7 @@
assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, state);
SourceTransformer st = new SourceTransformer();
Node node = st.toDOMNode(new StreamSource(method.getResponseBodyAsStream()));
- System.err.println(st.toString(node));
+ logger.info(st.toString(node));
Element e = ((Document) node).getDocumentElement();
assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.ENVELOPE), DOMUtil.getQName(e));
@@ -294,6 +297,34 @@
assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.BODY), DOMUtil.getQName(e));
e = DOMUtil.getFirstChildElement(e);
assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.FAULT), DOMUtil.getQName(e));
+
+ method = new PostMethod("http://localhost:8193/ep2/");
+ method.setRequestBody("hello");
+ state = new HttpClient().executeMethod(method);
+ String str = method.getResponseBodyAsString();
+ logger.info(str);
+ assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, state);
+ node = st.toDOMNode(new StringSource(str));
+ e = ((Document) node).getDocumentElement();
+ assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.ENVELOPE), DOMUtil.getQName(e));
+ e = DOMUtil.getFirstChildElement(e);
+ assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.BODY), DOMUtil.getQName(e));
+ e = DOMUtil.getFirstChildElement(e);
+ assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.FAULT), DOMUtil.getQName(e));
+
+ method = new PostMethod("http://localhost:8193/ep2/");
+ method.setRequestBody("<hello/>");
+ state = new HttpClient().executeMethod(method);
+ str = method.getResponseBodyAsString();
+ logger.info(str);
+ assertEquals(HttpServletResponse.SC_BAD_REQUEST, state);
+ node = st.toDOMNode(new StringSource(str));
+ e = ((Document) node).getDocumentElement();
+ assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.ENVELOPE), DOMUtil.getQName(e));
+ e = DOMUtils.getFirstChildElement(e);
+ assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.BODY), DOMUtil.getQName(e));
+ e = DOMUtils.getFirstChildElement(e);
+ assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.FAULT), DOMUtil.getQName(e));
}
public void testSoapFault11() throws Exception {
@@ -318,6 +349,7 @@
ep1.setRoleAsString("consumer");
ep1.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
ep1.setSoap(true);
+ ep1.setSoapVersion("1.1");
HttpEndpoint ep2 = new HttpEndpoint();
ep2.setService(new QName("urn:test", "http"));
@@ -328,6 +360,7 @@
ep2.setRoleAsString("consumer");
ep2.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
ep2.setSoap(true);
+ ep2.setSoapVersion("1.1");
HttpEndpoint ep3 = new HttpEndpoint();
ep3.setService(new QName("urn:test", "http"));
@@ -336,6 +369,7 @@
ep3.setRoleAsString("provider");
ep3.setDefaultMep(URI.create("http://www.w3.org/2004/08/wsdl/in-out"));
ep3.setSoap(true);
+ ep3.setSoapVersion("1.1");
HttpComponent http = new HttpComponent();
http.setEndpoints(new HttpEndpoint[] { ep1, ep2, ep3 });
@@ -347,7 +381,7 @@
method.setRequestEntity(new InputStreamRequestEntity(getClass().getResourceAsStream("soap-request.xml")));
int state = new HttpClient().executeMethod(method);
String str = method.getResponseBodyAsString();
- System.err.println(str);
+ logger.info(str);
assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, state);
SourceTransformer st = new SourceTransformer();
Node node = st.toDOMNode(new StringSource(str));
@@ -358,6 +392,34 @@
assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.BODY), DOMUtil.getQName(e));
e = DOMUtils.getFirstChildElement(e);
assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.FAULT), DOMUtil.getQName(e));
+
+ method = new PostMethod("http://localhost:8194/ep2/");
+ method.setRequestBody("hello");
+ state = new HttpClient().executeMethod(method);
+ str = method.getResponseBodyAsString();
+ logger.info(str);
+ assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, state);
+ node = st.toDOMNode(new StringSource(str));
+ e = ((Document) node).getDocumentElement();
+ assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.ENVELOPE), DOMUtil.getQName(e));
+ e = DOMUtils.getFirstChildElement(e);
+ assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.BODY), DOMUtil.getQName(e));
+ e = DOMUtils.getFirstChildElement(e);
+ assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.FAULT), DOMUtil.getQName(e));
+
+ method = new PostMethod("http://localhost:8194/ep2/");
+ method.setRequestBody("<hello/>");
+ state = new HttpClient().executeMethod(method);
+ str = method.getResponseBodyAsString();
+ logger.info(str);
+ assertEquals(HttpServletResponse.SC_BAD_REQUEST, state);
+ node = st.toDOMNode(new StringSource(str));
+ e = ((Document) node).getDocumentElement();
+ assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.ENVELOPE), DOMUtil.getQName(e));
+ e = DOMUtils.getFirstChildElement(e);
+ assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.BODY), DOMUtil.getQName(e));
+ e = DOMUtils.getFirstChildElement(e);
+ assertEquals(new QName(SoapMarshaler.SOAP_11_URI, SoapMarshaler.FAULT), DOMUtil.getQName(e));
}
public void testSoapXml() throws Exception {
@@ -410,7 +472,7 @@
SourceTransformer st = new SourceTransformer();
Element e = st.toDOMElement(msg);
String strMsg = DOMUtil.asXML(e);
- System.err.println(strMsg);
+ logger.info(strMsg);
assertEquals(new QName(SoapMarshaler.SOAP_12_URI, SoapMarshaler.ENVELOPE), DOMUtil.getQName(e));
e = DOMUtil.getFirstChildElement(e);