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/08/20 16:52:48 UTC
svn commit: r687364 - 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: Wed Aug 20 07:52:47 2008
New Revision: 687364
URL: http://svn.apache.org/viewvc?rev=687364&view=rev
Log:
[SM-1508]servicemix-cxf service with outbound attachment and jms transport generates XMLStreamReader error
Added:
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/ParseContentTypeInterceptor.java (with props)
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcHttpJmsBridgeMtomTest.java (with props)
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_bridge_http_jms.xml (with props)
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_xop.wsdl (with props)
Modified:
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
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/JbiConstants.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiOutInterceptor.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiOutWsdl1Interceptor.java
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.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/CxfBcConsumer.java?rev=687364&r1=687363&r2=687364&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java Wed Aug 20 07:52:47 2008
@@ -97,6 +97,7 @@
import org.apache.servicemix.cxfbc.interceptors.JbiOperationInterceptor;
import org.apache.servicemix.cxfbc.interceptors.JbiOutWsdl1Interceptor;
import org.apache.servicemix.cxfbc.interceptors.MtomCheckInterceptor;
+import org.apache.servicemix.cxfbc.interceptors.ParseContentTypeInterceptor;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.soap.util.DomUtil;
import org.mortbay.jetty.Handler;
@@ -299,6 +300,9 @@
getConfiguration().getAuthenticationService()));
cxfService.getInInterceptors().add(new JbiInvokerInterceptor());
cxfService.getInInterceptors().add(new JbiPostInvokerInterceptor());
+ if (isMtomEnabled()) {
+ cxfService.getInInterceptors().add(new ParseContentTypeInterceptor());
+ }
cxfService.getInInterceptors().add(new OutgoingChainInterceptor());
@@ -309,6 +313,7 @@
cxfService.getOutInterceptors().add(new AttachmentOutInterceptor());
cxfService.getOutInterceptors().add(
new MtomCheckInterceptor(isMtomEnabled()));
+
cxfService.getOutInterceptors().add(new StaxOutInterceptor());
cxfService.getOutInterceptors().add(
new SoapPreProtocolOutInterceptor());
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=687364&r1=687363&r2=687364&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 Wed Aug 20 07:52:47 2008
@@ -56,6 +56,7 @@
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.interceptor.AttachmentOutInterceptor;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.Interceptor;
@@ -171,34 +172,7 @@
cxfExchange.put(BindingOperationInfo.class, boi);
cxfExchange.put(Endpoint.class, ep);
cxfExchange.put(Service.class, cxfService);
- PhaseChainCache outboundChainCache = new PhaseChainCache();
- PhaseManager pm = getBus().getExtension(PhaseManager.class);
- List<Interceptor> outList = new ArrayList<Interceptor>();
- if (isMtomEnabled()) {
- outList.add(new JbiOutInterceptor());
- outList.add(new MtomCheckInterceptor(true));
- outList.add(new AttachmentOutInterceptor());
-
- }
-
- outList.add(new JbiOutInterceptor());
- outList.add(new JbiOutWsdl1Interceptor(isUseJBIWrapper()));
- outList.add(new SoapPreProtocolOutInterceptor());
- outList.add(new SoapOutInterceptor(getBus()));
- outList.add(new SoapActionOutInterceptor());
- outList.add(new StaxOutInterceptor());
-
-
- getInInterceptors().addAll(getBus().getInInterceptors());
- getInFaultInterceptors().addAll(getBus().getInFaultInterceptors());
- getOutInterceptors().addAll(getBus().getOutInterceptors());
- getOutFaultInterceptors()
- .addAll(getBus().getOutFaultInterceptors());
- PhaseInterceptorChain outChain = outboundChainCache.get(pm
- .getOutPhases(), outList);
- outChain.add(getOutInterceptors());
- outChain.add(getOutFaultInterceptors());
- message.setInterceptorChain(outChain);
+ PhaseInterceptorChain outChain = createInterceptorChain(message);
InputStream is = JBIMessageHelper.convertMessageToInputStream(nm
.getContent());
@@ -206,10 +180,9 @@
message.setContent(Source.class, source);
message.setContent(InputStream.class, is);
-
+
conduit.prepare(message);
OutputStream os = message.getContent(OutputStream.class);
-
message.put(org.apache.cxf.message.Message.REQUESTOR_ROLE, true);
try {
outChain.doIntercept(message);
@@ -222,7 +195,17 @@
if (ex != null) {
throw ex;
}
-
+ String contentType = (String)message.get(Message.CONTENT_TYPE);
+
+ Map<String, List<String>> headers = getSetProtocolHeaders(message);
+ if (headers.get(Message.CONTENT_TYPE) == null) {
+ List<String> ct = new ArrayList<String>();
+ ct.add(contentType);
+ headers.put(Message.CONTENT_TYPE, ct);
+ } else {
+ List<String> ct = headers.get(Message.CONTENT_TYPE);
+ ct.add(contentType);
+ }
os = message.getContent(OutputStream.class);
os.flush();
@@ -234,6 +217,49 @@
}
+ private PhaseInterceptorChain createInterceptorChain(Message message) {
+ PhaseChainCache outboundChainCache = new PhaseChainCache();
+ PhaseManager pm = getBus().getExtension(PhaseManager.class);
+ List<Interceptor> outList = new ArrayList<Interceptor>();
+ if (isMtomEnabled()) {
+ outList.add(new JbiOutInterceptor());
+ outList.add(new MtomCheckInterceptor(true));
+ outList.add(new AttachmentOutInterceptor());
+
+ }
+
+ outList.add(new JbiOutInterceptor());
+ outList.add(new JbiOutWsdl1Interceptor(isUseJBIWrapper()));
+ outList.add(new SoapPreProtocolOutInterceptor());
+ outList.add(new SoapOutInterceptor(getBus()));
+ outList.add(new SoapActionOutInterceptor());
+ outList.add(new StaxOutInterceptor());
+
+
+ getInInterceptors().addAll(getBus().getInInterceptors());
+ getInFaultInterceptors().addAll(getBus().getInFaultInterceptors());
+ getOutInterceptors().addAll(getBus().getOutInterceptors());
+ getOutFaultInterceptors()
+ .addAll(getBus().getOutFaultInterceptors());
+ PhaseInterceptorChain outChain = outboundChainCache.get(pm
+ .getOutPhases(), outList);
+ outChain.add(getOutInterceptors());
+ outChain.add(getOutFaultInterceptors());
+ message.setInterceptorChain(outChain);
+ return outChain;
+ }
+
+ private Map<String, List<String>> getSetProtocolHeaders(Message message) {
+ Map<String, List<String>> headers =
+ CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
+ if (null == headers) {
+ headers = new HashMap<String, List<String>>();
+ message.put(Message.PROTOCOL_HEADERS, headers);
+ }
+ return headers;
+ }
+
+
private void faultProcess(MessageExchange exchange, Message message, Exception e) throws MessagingException {
javax.jbi.messaging.Fault fault = exchange.createFault();
if (e.getCause() != null) {
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=687364&r1=687363&r2=687364&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 Wed Aug 20 07:52:47 2008
@@ -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.ParseContentTypeInterceptor;
public class CxfBcProviderMessageObserver implements MessageObserver {
@@ -130,6 +131,7 @@
inList.add(new JbiInWsdl1Interceptor(this.providerEndpoint.isUseJBIWrapper()));
if (providerEndpoint.isMtomEnabled()) {
inList.add(new AttachmentInInterceptor());
+ inList.add(new ParseContentTypeInterceptor());
}
PhaseInterceptorChain inChain = inboundChainCache.get(pm
.getInPhases(), inList);
@@ -140,35 +142,7 @@
soapMessage.setInterceptorChain(inChain);
inChain.doIntercept(soapMessage);
- if (boi.getOperationInfo().isOneWay()) {
- messageExchange.setStatus(ExchangeStatus.DONE);
- } else if (soapMessage.get("jbiFault") != null
- && soapMessage.get("jbiFault").equals(true)) {
- Fault fault = messageExchange.createFault();
- fault.setContent(soapMessage.getContent(Source.class));
- messageExchange.setFault(fault);
- } 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);
- }
- } else {
- messageExchange.setStatus(ExchangeStatus.DONE);
-
- }
+ setMessageStatus(soapMessage, boi);
boolean txSync = messageExchange.getStatus() == ExchangeStatus.ACTIVE
&& messageExchange.isTransacted()
&& Boolean.TRUE.equals(messageExchange
@@ -190,6 +164,38 @@
}
}
}
+
+ private void setMessageStatus(SoapMessage soapMessage, BindingOperationInfo boi) throws MessagingException {
+ if (boi.getOperationInfo().isOneWay()) {
+ messageExchange.setStatus(ExchangeStatus.DONE);
+ } else if (soapMessage.get("jbiFault") != null
+ && soapMessage.get("jbiFault").equals(true)) {
+ Fault fault = messageExchange.createFault();
+ fault.setContent(soapMessage.getContent(Source.class));
+ messageExchange.setFault(fault);
+ } 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);
+ }
+ } else {
+ messageExchange.setStatus(ExchangeStatus.DONE);
+
+ }
+ }
private void toNMSAttachments(NormalizedMessage normalizedMessage,
Message soapMessage) throws MessagingException {
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiConstants.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/JbiConstants.java?rev=687364&r1=687363&r2=687364&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiConstants.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiConstants.java Wed Aug 20 07:52:47 2008
@@ -80,6 +80,10 @@
public static final QName WSDL11_WRAPPER_PART = new QName(
WSDL11_WRAPPER_NAMESPACE, WSDL11_WRAPPER_PART_LOCALNAME,
WSDL11_WRAPPER_PREFIX);
+ public static final String CONTENT_TYPE = "content.type";
+
+ public static final String TRANSPORT_PROTOCOL_HEADERS = "transport.protocol.header";
+
private JbiConstants() {
//Added to keep checkstyle 4.3 happy.
}
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiOutInterceptor.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/JbiOutInterceptor.java?rev=687364&r1=687363&r2=687364&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiOutInterceptor.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiOutInterceptor.java Wed Aug 20 07:52:47 2008
@@ -164,6 +164,7 @@
attachmentList.add(attachment);
}
message.setAttachments(attachmentList);
+
if (message instanceof SoapMessage) {
SoapMessage soapMessage = (SoapMessage)message;
SoapVersion soapVersion = soapMessage.getVersion();
@@ -210,6 +211,8 @@
}
}
}
+
+
}
private boolean isRequestor(org.apache.cxf.message.Message message) {
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiOutWsdl1Interceptor.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/JbiOutWsdl1Interceptor.java?rev=687364&r1=687363&r2=687364&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiOutWsdl1Interceptor.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiOutWsdl1Interceptor.java Wed Aug 20 07:52:47 2008
@@ -17,8 +17,10 @@
package org.apache.servicemix.cxfbc.interceptors;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -35,6 +37,7 @@
import org.apache.cxf.binding.soap.model.SoapHeaderInfo;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.headers.Header;
+import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.NSStack;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
@@ -137,6 +140,8 @@
if ("rpc".equals(style)) {
xmlWriter.writeEndElement();
}
+
+ setContentType(message);
} catch (Fault e) {
throw e;
} catch (Exception e) {
@@ -146,6 +151,25 @@
+ private void setContentType(SoapMessage message) {
+ String contentType = (String) message.get(Message.CONTENT_TYPE);
+ Map<String, List<String>> headers =
+ CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
+ if (null == headers) {
+ headers = new HashMap<String, List<String>>();
+ message.put(Message.PROTOCOL_HEADERS, headers);
+ }
+ if (headers.get(Message.CONTENT_TYPE) == null) {
+ List<String> ct = new ArrayList<String>();
+ ct.add(contentType);
+ headers.put(Message.CONTENT_TYPE, ct);
+ } else {
+ List<String> ct = headers.get(Message.CONTENT_TYPE);
+ ct.add(contentType);
+ }
+
+ }
+
private void getRPCPartWrapper(BindingMessageInfo msg,
Element element,
SoapMessage message,
Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/ParseContentTypeInterceptor.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/ParseContentTypeInterceptor.java?rev=687364&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/ParseContentTypeInterceptor.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/ParseContentTypeInterceptor.java Wed Aug 20 07:52:47 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.cxfbc.interceptors;
+
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+public class ParseContentTypeInterceptor extends AbstractPhaseInterceptor<Message> {
+
+ public ParseContentTypeInterceptor() {
+ super(Phase.RECEIVE);
+ addBefore(AttachmentInInterceptor.class.getName());
+ }
+
+ public void handleMessage(Message message) throws Fault {
+ Object headers = message.get(Message.PROTOCOL_HEADERS);
+ if (headers != null) {
+ String ct = headers.toString();
+ //parse content-type from protocal headers
+ if (ct.indexOf("content-type") != -1) {
+ ct = ct.substring(ct.indexOf("content-type") + 14,
+ ct.indexOf("]", ct.indexOf("content-type")));
+ }
+ message.put(Message.CONTENT_TYPE, ct);
+ }
+
+ }
+
+
+}
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/ParseContentTypeInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/ParseContentTypeInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcHttpJmsBridgeMtomTest.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/CxfBcHttpJmsBridgeMtomTest.java?rev=687364&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcHttpJmsBridgeMtomTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcHttpJmsBridgeMtomTest.java Wed Aug 20 07:52:47 2008
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.servicemix.cxfbc;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+import javax.mail.util.ByteArrayDataSource;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientImpl;
+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.binding.soap.SOAPBindingImpl;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.mime.TestMtom;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.testutil.common.ServerLauncher;
+import org.apache.servicemix.cxfbc.mtom.TestMtomImpl;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class CxfBcHttpJmsBridgeMtomTest extends SpringTestSupport {
+
+ public static final QName MTOM_PORT = new QName(
+ "http://cxf.apache.org/mime", "TestMtomPort");
+
+ public static final QName MTOM_SERVICE = new QName(
+ "http://cxf.apache.org/mime", "TestMtomService");
+
+
+ protected static boolean serversStarted;
+ private ServerLauncher sl;
+ private ServerLauncher embeddedLauncher;
+
+
+
+
+ public void startServers() throws Exception {
+ if (serversStarted) {
+ return;
+ }
+ Map<String, String> props = new HashMap<String, String>();
+ if (System.getProperty("activemq.store.dir") != null) {
+ props.put("activemq.store.dir", System.getProperty("activemq.store.dir"));
+ }
+ props.put("java.util.logging.config.file",
+ System.getProperty("java.util.logging.config.file"));
+
+ assertTrue("server did not launch correctly",
+ launchServer(EmbededJMSBrokerLauncher.class, props, false));
+ embeddedLauncher = sl;
+
+
+ serversStarted = true;
+ }
+
+ protected void setUp() throws Exception {
+ startServers();
+ super.setUp();
+
+ }
+
+ protected void tearDown() throws Exception {
+ try {
+ embeddedLauncher.stopServer();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ fail("failed to stop server " + embeddedLauncher.getClass());
+ }
+
+ serversStarted = false;
+ }
+
+ public boolean launchServer(Class<?> clz, Map<String, String> p, boolean inProcess) {
+ boolean ok = false;
+ try {
+ sl = new ServerLauncher(clz.getName(), p, null, inProcess);
+ ok = sl.launchServer();
+ assertTrue("server failed to launch", ok);
+
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ fail("failed to launch server " + clz);
+ }
+
+ return ok;
+ }
+
+ public void testBridge() throws Exception {
+ // start external service
+ 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());
+
+ // start external client
+ TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class,
+ true);
+ try {
+
+ Holder<DataHandler> param = new Holder<DataHandler>();
+
+ param.value = new DataHandler(new ByteArrayDataSource("foobar".getBytes(),
+ "application/octet-stream"));
+
+ Holder<String> name = new Holder<String>("call detail");
+ mtomPort.testXop(name, param);
+ assertEquals("call detailfoobar",
+ name.value);
+ assertNotNull(param.value);
+ InputStream bis = param.value.getDataSource().getInputStream();
+ byte b[] = new byte[10];
+ bis.read(b, 0, 10);
+ String attachContent = new String(b);
+ assertEquals(attachContent, "testfoobar");
+ } catch (UndeclaredThrowableException ex) {
+ throw (Exception) ex.getCause();
+ }
+
+ }
+
+ @Override
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext(
+ "org/apache/servicemix/cxfbc/mtom_bridge_http_jms.xml");
+ }
+
+ private <T> T createPort(QName serviceName, QName portName,
+ Class<T> serviceEndpointInterface, boolean enableMTOM)
+ throws Exception {
+ Bus bus = BusFactory.getDefaultBus();
+ ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
+ serviceFactory.setBus(bus);
+ serviceFactory.setServiceName(serviceName);
+ serviceFactory.setServiceClass(serviceEndpointInterface);
+ serviceFactory.setWsdlURL(getClass().getResource("/wsdl/mtom_xop.wsdl"));
+ Service service = serviceFactory.create();
+ EndpointInfo ei = service.getEndpointInfo(portName);
+ JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service,
+ ei);
+ SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding());
+ jaxWsSoapBinding.setMTOMEnabled(enableMTOM);
+
+ Client client = new ClientImpl(bus, jaxwsEndpoint);
+ InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint
+ .getJaxwsBinding());
+ Object obj = Proxy.newProxyInstance(serviceEndpointInterface
+ .getClassLoader(), new Class[] {serviceEndpointInterface,
+ BindingProvider.class}, ih);
+ return serviceEndpointInterface.cast(obj);
+ }
+
+}
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcHttpJmsBridgeMtomTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcHttpJmsBridgeMtomTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_bridge_http_jms.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/mtom_bridge_http_jms.xml?rev=687364&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_bridge_http_jms.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_bridge_http_jms.xml Wed Aug 20 07:52:47 2008
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
+ xmlns:mtom="http://cxf.apache.org/mime">
+
+ <sm:container id="jbi" embedded="true">
+
+ <sm:endpoints>
+ <cxfbc:consumer wsdl="/wsdl/mtom_xop.wsdl"
+ service="mtom:TestMtomService"
+ endpoint="TestMtomPort"
+ targetEndpoint="TestMtomProviderJmsPort"
+ targetService="mtom:TestMtomProviderService"
+ targetInterface="mtom:TestMtom"
+ mtomEnabled="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:consumer>
+
+
+ <cxfbc:provider wsdl="org/apache/servicemix/cxfbc/mtom_xop.wsdl"
+ service="mtom:TestMtomProviderService"
+ endpoint="TestMtomProviderJmsPort"
+ interfaceName="mtom:TestMtom"
+ mtomEnabled="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:consumer wsdl="org/apache/servicemix/cxfbc/mtom_xop.wsdl"
+ service="mtom:TestMtomService"
+ endpoint="TestMtomJmsPort"
+ targetEndpoint="TestMtomPortProxy"
+ targetService="mtom:TestMtomService"
+ targetInterface="mtom:TestMtom"
+ mtomEnabled="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:consumer>
+
+ <cxfbc:provider wsdl="/wsdl/mtom_xop.wsdl"
+ locationURI="http://localhost:9001/mtombridgetest"
+ service="mtom:TestMtomService"
+ endpoint="TestMtomPortProxy"
+ interfaceName="mtom:TestMtom"
+ mtomEnabled="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>
+ </sm:endpoints>
+
+ </sm:container>
+
+</beans>
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_bridge_http_jms.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_bridge_http_jms.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_bridge_http_jms.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_xop.wsdl
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_xop.wsdl?rev=687364&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_xop.wsdl (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_xop.wsdl Wed Aug 20 07:52:47 2008
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<wsdl:definitions name="SOAPBuilders-mime-cr-test" xmlns:types="http://cxf.apache.org/mime/types"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://cxf.apache.org/mime"
+ xmlns:jms="http://cxf.apache.org/transports/jms"
+ xmlns:xmime="http://www.w3.org/2005/05/xmlmime" targetNamespace="http://cxf.apache.org/mime">
+
+ <wsdl:types>
+ <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://cxf.apache.org/mime/types"
+ xmlns:xmime="http://www.w3.org/2005/05/xmlmime" elementFormDefault="qualified">
+ <complexType name="XopType">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ <element name="attachinfo" type="xsd:base64Binary" xmime:expectedContentTypes="application/octet-stream"/>
+ </sequence>
+ </complexType>
+ <complexType name="XopStringType">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ <element name="attachinfo" type="xsd:base64Binary" xmime:expectedContentTypes="text/plain; charset=utf-8"/>
+ </sequence>
+ </complexType>
+ <element name="testXop" type="types:XopType" />
+ <element name="testXopResponse" type="types:XopType" />
+ <element name="testXopStringArgument" type="types:XopStringType"/>
+ <element name="testXopStringResponse" type="types:XopStringType"/>
+ </schema>
+
+ </wsdl:types>
+
+ <wsdl:message name="testXopIn">
+ <wsdl:part name="data" element="types:testXop" />
+ </wsdl:message>
+
+ <wsdl:message name="testXopOut">
+ <wsdl:part name="data" element="types:testXopResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="testXopStringIn">
+ <wsdl:part name="data" element="types:testXopStringArgument" />
+ </wsdl:message>
+
+ <wsdl:message name="testXopStringOut">
+ <wsdl:part name="data" element="types:testXopStringResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="TestMtom">
+
+ <wsdl:operation name="testXop">
+ <wsdl:input message="tns:testXopIn" />
+ <wsdl:output message="tns:testXopOut" />
+ </wsdl:operation>
+
+ <wsdl:operation name="testXopString">
+ <wsdl:input message="tns:testXopStringIn" />
+ <wsdl:output message="tns:testXopStringOut" />
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="TestMtomBinding" type="tns:TestMtom">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+
+ <wsdl:operation name="testXop">
+ <soap:operation soapAction="" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="testXopString">
+ <soap:operation soapAction="" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="TestMtomService">
+ <wsdl:port name="TestMtomPort" binding="tns:TestMtomBinding">
+ <soap:address location="http://localhost:9036/mime-test" />
+ </wsdl:port>
+ <wsdl:port name="TestMtomJmsPort" binding="tns:TestMtomBinding">
+ <jms:address
+ destinationStyle="queue"
+ jndiConnectionFactoryName="ConnectionFactory"
+ jndiDestinationName="dynamicQueues/person.queue">
+ <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
+ <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61616"/>
+ </jms:address>
+ </wsdl:port>
+ </wsdl:service>
+
+ <wsdl:service name="TestMtomProviderService">
+ <wsdl:port name="TestMtomProviderJmsPort" binding="tns:TestMtomBinding">
+ <jms:address
+ destinationStyle="queue"
+ jndiConnectionFactoryName="ConnectionFactory"
+ jndiDestinationName="dynamicQueues/person.queue">
+ <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
+ <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61616"/>
+ </jms:address>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_xop.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_xop.wsdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/mtom_xop.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml