You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2009/08/14 10:05:37 UTC
svn commit: r804112 - in
/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src:
main/java/org/apache/servicemix/cxfbc/
main/java/org/apache/servicemix/cxfbc/interceptors/
test/java/org/apache/servicemix/cxfbc/ tes...
Author: ffang
Date: Fri Aug 14 08:05:37 2009
New Revision: 804112
URL: http://svn.apache.org/viewvc?rev=804112&view=rev
Log:
[SMXCOMP-616]add schemaValidationEnabled flag for cxf bc provider
Modified:
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/AbstractSchemaValidationInterceptor.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider.xml
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean.xml
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java?rev=804112&r1=804111&r2=804112&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java Fri Aug 14 08:05:37 2009
@@ -102,6 +102,7 @@
import org.apache.servicemix.cxfbc.interceptors.JbiOutInterceptor;
import org.apache.servicemix.cxfbc.interceptors.JbiOutWsdl1Interceptor;
import org.apache.servicemix.cxfbc.interceptors.MtomCheckInterceptor;
+import org.apache.servicemix.cxfbc.interceptors.SchemaValidationOutInterceptor;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.soap.util.DomUtil;
import org.springframework.core.io.Resource;
@@ -150,6 +151,8 @@
private boolean synchronous = true;
+ private boolean schemaValidationEnabled;
+
private List<AbstractFeature> features = new CopyOnWriteArrayList<AbstractFeature>();
public void processExchange(MessageExchange exchange) {
@@ -302,6 +305,9 @@
}
outList.add(new JbiOutInterceptor());
+ if (isSchemaValidationEnabled()) {
+ outList.add(new SchemaValidationOutInterceptor(isUseJBIWrapper(), isUseSOAPEnvelope()));
+ }
outList.add(new JbiOutWsdl1Interceptor(isUseJBIWrapper(), isUseSOAPEnvelope()));
outList.add(new SoapPreProtocolOutInterceptor());
outList.add(new SoapOutInterceptor(getBus()));
@@ -747,4 +753,20 @@
return features;
}
+ public boolean isSchemaValidationEnabled() {
+ return schemaValidationEnabled;
+ }
+
+ /**
+ * Specifies if the endpoint use schemavalidation for the incoming/outgoing message.
+ *
+ * @param schemaValidationEnabled
+ * a boolean
+ * @org.apache.xbean.Property description="Specifies if the endpoint use schemavalidation for the incoming/outgoing message.
+ * Default is <code>false</code>.
+ */
+
+ public void setSchemaValidationEnabled(boolean schemaValidationEnabled) {
+ this.schemaValidationEnabled = schemaValidationEnabled;
+ }
}
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java?rev=804112&r1=804111&r2=804112&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java Fri Aug 14 08:05:37 2009
@@ -49,6 +49,7 @@
import org.apache.cxf.transport.MessageObserver;
import org.apache.servicemix.JbiConstants;
import org.apache.servicemix.cxfbc.interceptors.JbiInWsdl1Interceptor;
+import org.apache.servicemix.cxfbc.interceptors.SchemaValidationInInterceptor;
@@ -114,6 +115,10 @@
inList.add(new StaxInInterceptor());
inList.add(new JbiInWsdl1Interceptor(this.providerEndpoint.isUseJBIWrapper(),
this.providerEndpoint.isUseSOAPEnvelope()));
+ if (this.providerEndpoint.isSchemaValidationEnabled()) {
+ inList.add(new SchemaValidationInInterceptor(this.providerEndpoint.isUseJBIWrapper(),
+ this.providerEndpoint.isUseSOAPEnvelope()));
+ }
inList.add(new AttachmentInInterceptor());
PhaseInterceptorChain inChain = inboundChainCache.get(pm
.getInPhases(), inList);
@@ -124,7 +129,8 @@
soapMessage.setInterceptorChain(inChain);
inChain.doIntercept(soapMessage);
closeConnectionStream(soapMessage);
- if (soapMessage.getContent(Source.class) == null) {
+
+ if (soapMessage.getContent(Exception.class) != null || soapMessage.getContent(Source.class) == null) {
Exception ex = soapMessage.getContent(Exception.class);
if (!(soapMessage.getExchange().get(MessageExchange.class) instanceof InOnly)
&& ex != null) {
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/AbstractSchemaValidationInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/AbstractSchemaValidationInterceptor.java?rev=804112&r1=804111&r2=804112&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/AbstractSchemaValidationInterceptor.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/AbstractSchemaValidationInterceptor.java Fri Aug 14 08:05:37 2009
@@ -48,7 +48,10 @@
if (schema != null) {
javax.xml.validation.Validator validator = schema.newValidator();
try {
+
+
Element sourceMessage = new SourceTransformer().toDOMElement(message.getContent(Source.class));
+ message.setContent(Source.class, new DOMSource(sourceMessage));
if (!useJBIWrapper && !useSOAPEnvelope) {
validator.validate(new DOMSource(sourceMessage));
} else {
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java?rev=804112&r1=804111&r2=804112&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java Fri Aug 14 08:05:37 2009
@@ -161,6 +161,9 @@
//test soap header using helloworld
soapHeader();
+ //test schemavalidation
+ schemaValidation();
+
//test concurrency
concurrency();
// Shutdown CXF Service/Endpoint so that next test doesn't fail.
@@ -168,6 +171,38 @@
factory.getBus().shutdown(true);
}
+ private void schemaValidation() throws Exception {
+ String address;
+ factory = new JaxWsServerFactoryBean();
+ factory.setServiceClass(org.apache.hello_world_soap_http_provider.Greeter.class);
+ factory.setServiceBean(new org.apache.servicemix.cxfbc.provider.GreeterImpl());
+ address = "http://localhost:9008/schemavalidation";
+ factory.setAddress(address);
+ server = factory.create();
+ endpoint = server.getEndpoint();
+ endpoint.getInInterceptors().add(new LoggingInInterceptor());
+ endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
+ service = endpoint.getEndpointInfo().getService();
+ assertNotNull(service);
+ io = client.createInOutExchange();
+ io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
+ io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
+ //send message to proxy
+ io.getInMessage().setContent(new StringSource(
+ "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+ + "<part> "
+ + "<greetMe xmlns='http://apache.org/hello_world_soap_http/types'><requestType>"
+ + "schemavalidation"
+ + "</requestType></greetMe>"
+ + "</part> "
+ + "</message>"));
+ client.sendSync(io);
+ client.done(io);
+ assertTrue(new SourceTransformer().contentToString(
+ io.getOutMessage()).indexOf("is not facet-valid with respect to maxLength '30' for type 'MyStringType'.") >= 0);
+
+ }
+
private void concurrency() throws Exception {
io = client.createInOutExchange();
io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java?rev=804112&r1=804111&r2=804112&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/GreeterImplForProvider.java Fri Aug 14 08:05:37 2009
@@ -58,6 +58,8 @@
private Greeter securityGreeter;
private HelloPortType hello;
private TestMtom mtom;
+ private org.apache.hello_world_soap_http_provider.Greeter providerGreeter;
+
public String greetMe(String me) {
String ret = "";
@@ -70,6 +72,12 @@
} else if ("oneway test".equals(me)) {
getGreeter().greetMeOneWay("oneway");
ret = "oneway";
+ } else if ("schemavalidation".equals(me)) {
+ try {
+ ret = getProviderGreeter().greetMe("schemavalidation");
+ } catch (Exception e) {
+ ret = e.getMessage();
+ }
} else if ("header test".equals(me)) {
HelloRequest req = new HelloRequest();
req.setText("12");
@@ -133,6 +141,7 @@
if ("no server".equals(ret)) {
ret = "server is stop";
} else {
+
ret = e.getMessage();
}
}
@@ -288,6 +297,15 @@
}
+ public void setProviderGreeter(org.apache.hello_world_soap_http_provider.Greeter providerGreeter) {
+ this.providerGreeter = providerGreeter;
+ }
+
+ public org.apache.hello_world_soap_http_provider.Greeter getProviderGreeter() {
+ return providerGreeter;
+ }
+
+
class MultiClientThread extends Thread {
private CalculatorPortType port;
private int index;
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider.xml?rev=804112&r1=804111&r2=804112&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider.xml Fri Aug 14 08:05:37 2009
@@ -24,6 +24,7 @@
xmlns:hello="uri:HelloWorld"
xmlns:calculator="http://apache.org/cxf/calculator"
xmlns:greeter="http://apache.org/hello_world_soap_http"
+ xmlns:provider_greeter="http://apache.org/hello_world_soap_http_provider"
xmlns:mtom="http://cxf.apache.org/mime">
<sm:container id="jbi" embedded="true">
@@ -72,6 +73,28 @@
</cxfbc:outFaultInterceptors>
</cxfbc:provider>
+ <cxfbc:provider wsdl="hello_world.wsdl"
+ locationURI="http://localhost:9008/schemavalidation"
+ endpoint="SoapPort"
+ service="provider_greeter:SOAPService"
+ interfaceName="provider_greeter:Greeter"
+ schemaValidationEnabled="true"
+ >
+ <cxfbc:inInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfbc:inInterceptors>
+ <cxfbc:outInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfbc:outInterceptors>
+ <cxfbc:inFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfbc:inFaultInterceptors>
+ <cxfbc:outFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfbc:outFaultInterceptors>
+ </cxfbc:provider>
+
+
<cxfbc:provider wsdl="/HelloWorld-DOC.wsdl"
locationURI="http://localhost:9003/helloWorld"
endpoint="HelloPortProxy"
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean.xml?rev=804112&r1=804111&r2=804112&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean.xml Fri Aug 14 08:05:37 2009
@@ -24,6 +24,7 @@
xmlns:hello="uri:HelloWorld"
xmlns:calculator="http://apache.org/cxf/calculator"
xmlns:greeter="http://apache.org/hello_world_soap_http"
+ xmlns:provider_greeter="http://apache.org/hello_world_soap_http_provider"
xmlns:mtom="http://cxf.apache.org/mime">
@@ -39,6 +40,10 @@
<property name="greeter">
<cxfse:proxy service="greetr:SOAPService" context="#context" type="org.apache.hello_world_soap_http.Greeter"/>
</property>
+ <property name="providerGreeter">
+ <cxfse:proxy service="provider_greetr:SOAPService" context="#context" type="org.apache.hello_world_soap_http_provider.Greeter"/>
+ </property>
+
<property name="hello">
<cxfse:proxy service="hello:HelloService" context="#context" type="uri.helloworld.HelloPortType"/>
</property>