Author: gertv
Date: Wed Jun 27 05:26:21 2007
New Revision: 551139
URL: http://svn.apache.org/viewvc?view=rev&rev=551139
Log:
SM-939: CXF Based Binding component
Added:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/HelloPortTypeImpl.java
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcComponentTest.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/HelloWorld-DOC.wsdl
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml?view=diff&rev=551139&r1=551138&r2=551139
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml
(original)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml
Wed Jun 27 05:26:21 2007
@@ -132,6 +132,34 @@
</excludes>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>${cxf-version}</version>
+ <executions>
+ <execution>
+ <id>generate-test-sources</id>
+ <phase>generate-sources</phase>
+ <configuration>
+
<sourceRoot>${basedir}/target/generated/src/test/java</sourceRoot>
+ <wsdlOptions>
+ <wsdlOption>
+
<wsdl>${basedir}/src/test/resources/HelloWorld-DOC.wsdl</wsdl>
+ <extraargs>
+ <extraarg>-verbose</extraarg>
+ </extraargs>
+ </wsdlOption>
+
+ </wsdlOptions>
+
+ </configuration>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java?view=diff&rev=551139&r1=551138&r2=551139
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
(original)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
Wed Jun 27 05:26:21 2007
@@ -40,6 +40,8 @@
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.endpoint.ServerImpl;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.interceptor.OutgoingChainInterceptor;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
@@ -142,6 +144,8 @@
service.getInInterceptors().add(new JbiInvokerInterceptor());
service.getInInterceptors().add(new JbiPostInvokerInterceptor());
service.getInInterceptors().add(new OutgoingChainInterceptor());
+ service.getInInterceptors().add(new LoggingInInterceptor());
+ service.getOutInterceptors().add(new LoggingOutInterceptor());
service.getOutInterceptors().add(new JbiOutWsdl1Interceptor());
ep = new EndpointImpl(getBus(), service, ei);
chain = new JbiChainInitiationObserver(ep, getBus());
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java?view=diff&rev=551139&r1=551138&r2=551139
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java
(original)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInInterceptor.java
Wed Jun 27 05:26:21 2007
@@ -18,6 +18,8 @@
import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
import javax.jbi.JBIException;
import javax.jbi.component.ComponentContext;
@@ -29,6 +31,8 @@
import javax.security.auth.Subject;
import javax.xml.transform.Source;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.headers.Header;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Message;
@@ -36,6 +40,7 @@
import org.apache.cxf.phase.Phase;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
+import org.apache.servicemix.soap.util.QNameUtil;
/**
* @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
@@ -129,15 +134,19 @@
* Convert SoapMessage headers to NormalizedMessage headers
*/
private void toNMSHeaders(NormalizedMessage normalizedMessage, Message
soapMessage) {
- // TODO
- /*
+ SoapMessage message = null;
+ if (!(soapMessage instanceof SoapMessage)) {
+ return;
+ } else {
+ message = (SoapMessage)soapMessage;
+ }
Map<String, Object> headers = new HashMap<String, Object>();
- for (Map.Entry<QName, DocumentFragment> entry :
soapMessage.getSoapHeaders().entrySet()) {
- headers.put(QNameUtil.toString(entry.getKey()), entry.getValue());
+ for (Header header : message.getHeaders()) {
+ headers.put(QNameUtil.toString(header.getName()),
header.getObject());
}
- headers.putAll(soapMessage.getTransportHeaders());
+
normalizedMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, headers);
- */
+
}
/**
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java?view=diff&rev=551139&r1=551138&r2=551139
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
(original)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
Wed Jun 27 05:26:21 2007
@@ -32,6 +32,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.apache.cxf.binding.soap.SoapHeader;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
import org.apache.cxf.binding.soap.model.SoapBindingInfo;
@@ -152,6 +153,8 @@
addPart(root, (Node) part);
} else if (part instanceof NodeList) {
addPart(root, (NodeList) part);
+ } else if (part instanceof SoapHeader) {
+ addPart(root, (Node)((SoapHeader)part).getObject());
}
}
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcComponentTest.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcComponentTest.java?view=diff&rev=551139&r1=551138&r2=551139
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcComponentTest.java
(original)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcComponentTest.java
Wed Jun 27 05:26:21 2007
@@ -22,6 +22,7 @@
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
+import java.util.logging.Logger;
import javax.xml.namespace.QName;
@@ -32,9 +33,19 @@
import org.apache.servicemix.jbi.util.FileUtil;
import org.springframework.core.io.ClassPathResource;
+import uri.helloworld.HelloHeader;
+import uri.helloworld.HelloPortType;
+import uri.helloworld.HelloRequest;
+import uri.helloworld.HelloResponse;
+import uri.helloworld.HelloService;
+
public class CxfBcComponentTest extends TestCase {
+ static final Logger LOG =
Logger.getLogger(CxfBcComponentTest.class.getName());
+ private final QName serviceName = new QName(
+ "uri:HelloWorld",
+ "HelloService");
private JBIContainer jbi;
protected void setUp() throws Exception {
@@ -78,6 +89,34 @@
Thread.sleep(100);
}
+ public void testEndpointDOCWithExternalConsumer() throws Exception {
+ CxfBcComponent comp = new CxfBcComponent();
+ CxfBcConsumer ep = new CxfBcConsumer();
+ ep.setWsdl(new ClassPathResource("HelloWorld-DOC.wsdl"));
+ ep.setTargetService(new QName("urn:test", "target"));
+ comp.setEndpoints(new CxfBcEndpointType[] { ep });
+ jbi.activateComponent(comp, "servicemix-cxfbc");
+
+ MockServiceComponent echo = new MockServiceComponent();
+ echo.setService(new QName("urn:test", "target"));
+ echo.setEndpoint("endpoint");
+ echo.setResponseXml("<jbi:message
xmlns:jbi='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'><jbi:part><ns2:HelloResponse
xmlns:ns2='uri:HelloWorld'><text>helloffang</text></ns2:HelloResponse></jbi:part></jbi:message>");
+ jbi.activateComponent(echo, "echo");
+
+ URL wsdl = getClass().getResource("/HelloWorld-DOC.wsdl");
+ assertNotNull(wsdl);
+ HelloService helloService = new HelloService(wsdl, serviceName);
+ HelloPortType port = helloService.getHelloPort();
+ HelloRequest req = new HelloRequest();
+ req.setText("hello");
+ HelloHeader header = new HelloHeader();
+ header.setId("ffang");
+ HelloResponse rep = port.hello(req, header);
+ Thread.sleep(1000);
+ assertEquals(rep.getText(), "helloffang");
+ }
+
+
public void testEndpointRPC() throws Exception {
CxfBcComponent comp = new CxfBcComponent();
CxfBcConsumer ep = new CxfBcConsumer();
Added:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/HelloPortTypeImpl.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/HelloPortTypeImpl.java?view=auto&rev=551139
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/HelloPortTypeImpl.java
(added)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/HelloPortTypeImpl.java
Wed Jun 27 05:26:21 2007
@@ -0,0 +1,17 @@
+package org.apache.servicemix.cxfbc;
+
+import uri.helloworld.HelloFault_Exception;
+import uri.helloworld.HelloHeader;
+import uri.helloworld.HelloPortType;
+import uri.helloworld.HelloRequest;
+import uri.helloworld.HelloResponse;
+
+public class HelloPortTypeImpl implements HelloPortType {
+
+ public HelloResponse hello(HelloRequest body, HelloHeader header1)
throws HelloFault_Exception {
+ HelloResponse rep = new HelloResponse();
+ rep.setText(body.getText() + header1.getId());
+ return rep;
+ }
+
+}
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/HelloWorld-DOC.wsdl
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/HelloWorld-DOC.wsdl?view=diff&rev=551139&r1=551138&r2=551139
==============================================================================
---
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/HelloWorld-DOC.wsdl
(original)
+++
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/HelloWorld-DOC.wsdl
Wed Jun 27 05:26:21 2007
@@ -25,7 +25,7 @@
<types>
<schema targetNamespace="uri:HelloWorld"
- xmlns="http://www.w3.org/2000/10/XMLSchema">
+ xmlns="http://www.w3.org/2001/XMLSchema">
<element name="HelloRequest">
<complexType>
<all>