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 2008/06/28 03:25:33 UTC
svn commit: r672451 - in
/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src:
main/java/org/apache/servicemix/cxfbc/ test/java/org/apache/servicemix/cxfbc/
Author: ffang
Date: Fri Jun 27 18:25:33 2008
New Revision: 672451
URL: http://svn.apache.org/viewvc?rev=672451&view=rev
Log:
[SM-1430]Incoming attachments not processed in CxfBcProviderMessageObserver.
Modified:
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/test/java/org/apache/servicemix/cxfbc/CxfBcProviderConsumerMtomTest.java
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=672451&r1=672450&r2=672451&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 Jun 27 18:25:33 2008
@@ -25,13 +25,16 @@
import javax.jbi.messaging.InOptionalOut;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.ExchangeImpl;
import org.apache.cxf.message.Message;
@@ -121,6 +124,9 @@
inList.add(new RetrievePayLoadInterceptor());
inList.add(new JbiInWsdl1Interceptor(this.providerEndpoint.isUseJBIWrapper()));
+ if (providerEndpoint.isMtomEnabled()) {
+ inList.add(new AttachmentInInterceptor());
+ }
PhaseInterceptorChain inChain = inboundChainCache.get(pm
.getInPhases(), inList);
inChain.add(providerEndpoint.getInInterceptors());
@@ -140,11 +146,17 @@
} else if (messageExchange instanceof InOut) {
NormalizedMessage msg = messageExchange.createMessage();
msg.setContent(soapMessage.getContent(Source.class));
+ if (providerEndpoint.isMtomEnabled()) {
+ toNMSAttachments(msg, soapMessage);
+ }
messageExchange.setMessage(msg, "out");
} else if (messageExchange instanceof InOptionalOut) {
if (soapMessage.getContent(Source.class) != null) {
NormalizedMessage msg = messageExchange.createMessage();
msg.setContent(soapMessage.getContent(Source.class));
+ if (providerEndpoint.isMtomEnabled()) {
+ toNMSAttachments(msg, soapMessage);
+ }
messageExchange.setMessage(msg, "out");
} else {
messageExchange.setStatus(ExchangeStatus.DONE);
@@ -174,5 +186,15 @@
}
}
}
+
+ private void toNMSAttachments(NormalizedMessage normalizedMessage,
+ Message soapMessage) throws MessagingException {
+ if (soapMessage.getAttachments() != null) {
+ for (Attachment att : soapMessage.getAttachments()) {
+ normalizedMessage.addAttachment(att.getId(), att
+ .getDataHandler());
+ }
+ }
+ }
}
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderConsumerMtomTest.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/CxfBcProviderConsumerMtomTest.java?rev=672451&r1=672450&r2=672451&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderConsumerMtomTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderConsumerMtomTest.java Fri Jun 27 18:25:33 2008
@@ -32,12 +32,10 @@
import org.apache.cxf.BusFactory;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.ClientImpl;
-import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.endpoint.Server;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.jaxws.JaxWsClientProxy;
-import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
@@ -45,7 +43,6 @@
import org.apache.cxf.service.Service;
import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.service.model.ServiceInfo;
import org.apache.servicemix.cxfbc.mtom.TestMtomImpl;
import org.apache.servicemix.tck.SpringTestSupport;
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
@@ -61,18 +58,15 @@
public void testBridge() throws Exception {
// start external service
- JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
- factory.setServiceClass(TestMtom.class);
- factory.setServiceBean(new TestMtomImpl());
- String address = "http://localhost:9001/mtombridgetest";
- factory.setAddress(address);
- Server server = factory.create();
- Endpoint endpoint = server.getEndpoint();
+ EndpointImpl endpoint =
+ (EndpointImpl)javax.xml.ws.Endpoint.publish("http://localhost:9001/mtombridgetest",
+ new TestMtomImpl());
+
+ SOAPBinding binding = (SOAPBinding)endpoint.getBinding();
+ binding.setMTOMEnabled(true);
endpoint.getInInterceptors().add(new LoggingInInterceptor());
endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
- ServiceInfo service = endpoint.getEndpointInfo().getService();
- assertNotNull(service);
-
+
// start external client
TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class,
true);