Repository: servicemix Updated Branches: refs/heads/servicemix-5.0.x cd5edd1cc -> a4e26654d
SM-2298: Add a CXF SOAP with Camel example (closes #11) Thanks to Wim Verreydt for the pull request Project: http://git-wip-us.apache.org/repos/asf/servicemix/repo Commit: http://git-wip-us.apache.org/repos/asf/servicemix/commit/a4e26654 Tree: http://git-wip-us.apache.org/repos/asf/servicemix/tree/a4e26654 Diff: http://git-wip-us.apache.org/repos/asf/servicemix/diff/a4e26654 Branch: refs/heads/servicemix-5.0.x Commit: a4e26654d44a95234637ce9ae54bcd1c0a99546e Parents: cd5edd1 Author: Wim Verreydt <[email protected]> Authored: Mon May 19 11:20:02 2014 +0200 Committer: Krzysztof Sobkowiak <[email protected]> Committed: Sat May 24 00:59:57 2014 +0200 ---------------------------------------------------------------------- .../src/main/filtered-resources/examples.xml | 5 + examples/camel/camel-cxf-soap/README.txt | 212 +++++++++++++++++++ .../camel-cxf-soap-client/pom.xml | 59 ++++++ .../examples/camel/soap/client/Client.java | 105 +++++++++ .../camel-cxf-soap/camel-cxf-soap-route/pom.xml | 59 ++++++ .../examples/camel/soap/PersonService.java | 32 +++ .../resources/OSGI-INF/blueprint/blueprint.xml | 51 +++++ .../camel-cxf-soap-service/pom.xml | 51 +++++ .../examples/camel/soap/ServiceHandler.java | 70 ++++++ .../examples/camel/soap/model/Person.java | 73 +++++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 50 +++++ examples/camel/camel-cxf-soap/pom.xml | 39 ++++ examples/camel/pom.xml | 1 + 13 files changed, 807 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/assembly/src/main/filtered-resources/examples.xml ---------------------------------------------------------------------- diff --git a/assembly/src/main/filtered-resources/examples.xml b/assembly/src/main/filtered-resources/examples.xml index bca2fe6..b915117 100644 --- a/assembly/src/main/filtered-resources/examples.xml +++ b/assembly/src/main/filtered-resources/examples.xml @@ -100,6 +100,11 @@ <bundle>mvn:org.apache.servicemix.examples/camel-cxf-rest-service/${version}</bundle> <bundle>mvn:org.apache.servicemix.examples/camel-cxf-rest-route/${version}</bundle> </feature> + <feature name="examples-camel-cxf-soap" version="${version}" resolver="(obr)"> + <feature version="${camel.version}">camel-jaxb</feature> + <bundle>mvn:org.apache.servicemix.examples/camel-cxf-soap-service/${version}</bundle> + <bundle>mvn:org.apache.servicemix.examples/camel-cxf-soap-route/${version}</bundle> + </feature> <feature name="examples-cxf-ws-addressing" version="${version}" resolver="(obr)"> <feature version="${cxf.version}">cxf</feature> <bundle dependency="true">mvn:org.springframework/org.springframework.beans/${spring.version}</bundle> http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/README.txt ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/README.txt b/examples/camel/camel-cxf-soap/README.txt new file mode 100644 index 0000000..c3d138b --- /dev/null +++ b/examples/camel/camel-cxf-soap/README.txt @@ -0,0 +1,212 @@ +/* + * 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. + */ + +CAMEL CXF SOAP EXAMPLE +====================== + +Purpose +------- +Create a SOAP JAX-WS web service using CXF and handle it using the +Camel-Cxf component consumer. + + +Explanation +----------- +The web service functions are defined in the PersonService.java file, +which is located in the camel-cxf-soap-route/src/main/java/org/apache/ +servicemix/examples/camel/soap directory of this example. It contains +annotations indicating what URI, parameters and actions to use when accessing +the resource. For information on how to write SOAP web services, +please refer to the Apache CXF documentation. + + +The blueprint.xml file located in the camel-cxf-soap-route/src/main/ +resources/OSGI-INF/blueprint folder: + +1. Configures the cxf endpoint: + + <camelcxf:cxfEndpoint id="personService" + address="${CXFserver}${service}" + serviceClass="org.apache.servicemix.examples.camel.soap.PersonService" + /> + +2. Initializes the Camel route PersonServiceRoute wich routes each +SOAP method call to a seperate endpoint: + + <route id="PersonServiceRoute"> + <from uri="cxf:bean:personService" /> + <recipientList> + <simple>direct-vm:${header.operationName}</simple> + </recipientList> + </route> + + +The blueprint.xml file located in the camel-cxf-soap-service/src/main/ +resources/OSGI-INF/blueprint folder: + +1. Initializes the ServiceHandler bean implemented in the +ServiceHandler.java file, located in the camel-cxf-soap-service/ +src/main/java/org/apache/servicemix/examples/camel/soap + +2. Defines several routes to consume the SOAP method endpoints +using the ServiceHandler bean. + + +The Client.java file located in the camel-cxf-soap-client/src/main/ +java/org/apache/servicemix/examples/camel/soap/client folder provides +a small test client that calls each provided SOAP method and displays +the result. + + +Prerequisites for Running the Example +------------------------------------- +1. You must have the following installed on your machine: + + - JDK 1.6 or higher + + - Maven 2.2.1 or higher + + For more information, see the README in the top-level examples + directory. + +2. Start ServiceMix by running the following command: + + <servicemix_home>/bin/servicemix (on UNIX) + <servicemix_home>\bin\servicemix (on Windows) + + +Running the Example +------------------- +You can run the example in two ways: + +- A. Using a Prebuilt Deployment Bundle: Quick and Easy +This option is useful if you want to see the example up and +running as quickly as possible. + +- B. Building the Example Bundle Yourself +This option is useful if you want to change the example in any +way. It tells you how to build and deploy the example. This +option might be slower than option A because, if you do not +already have the required bundles in your local Maven +repository, Maven will have to download the bundles it needs. + + +A. Using a Prebuilt Deployment Bundle: Quick and Easy +----------------------------------------------------- +To install and run a prebuilt version of this example, enter +the following command in the ServiceMix console: + + features:install examples-camel-cxf-soap + +This command makes use of the ServiceMix features facility. For +more information about the features facility, see the README.txt +file in the examples parent directory. + +Running the Client +------------------ +To run the java code client: + +1. Change to the <servicemix_home>/examples/camel/camel-cxf-soap/camel-cxf-soap-client + directory. + +2. Run the following command: + + mvn compile exec:java + + +B. Building the Example Bundle Yourself +--------------------------------------- +To install and run the example where you build the example bundle +yourself, complete the following steps: + +1. If you have already run the example using the prebuilt version as + described above, you must first uninstall the examples-camel-cxf-soap + feature by entering the following command in the ServiceMix console: + + features:uninstall examples-camel-cxf-soap + +2. Build the example by opening a command prompt, changing directory to + examples/camel/camel-cxf-soap (this example) and entering the following Maven + command: + + mvn install + + If all of the required OSGi bundles are available in your local Maven + repository, the example will build very quickly. Otherwise it may + take some time for Maven to download everything it needs. + + The mvn install command builds the example deployment bundle and + copies it to your local Maven repository and to the target directory + of this example. + +3. Install the example by entering the following command in + the ServiceMix console: + + features:install examples-camel-cxf-soap + + It makes use of the ServiceMix features facility. For more information + about the features facility, see the README.txt file in the examples + parent directory. + +See "Running the Client" above for information on how to make invocations +on the web service. + + +Stopping and Uninstalling the Example +------------------------------------- +To stop the example, you must first know the bundle IDs that ServiceMix +has assigned to the example bundels. To get the bundle IDs, enter the +following command in the ServiceMix console (Note, the text you are +typing will intermingle with the output being logged. This is nothing +to worry about.): + + osgi:list + +At the end of the listing, you should see an entry similar to the +following: + + [ 173] [Active ] [Created ] [ ] [ 80] Apache ServiceMix :: Examples :: Camel CXF SOAP :: Route (5.0.1.SNAPSHOT) + [ 175] [Active ] [Created ] [ ] [ 80] Apache ServiceMix :: Examples :: Camel CXF SOAP :: Service (5.0.1.SNAPSHOT) + +In this case, the bundle IDs are 173 and 175. + +To stop a bundle, enter the following command in the ServiceMix +console: + + osgi:stop <bundle_id> + +For example: + + osgi:stop 173 + +To uninstall the example, enter one of the following commands at +the ServiceMix console: + + features:uninstall examples-camel-cxf-soap + +or + + osgi:uninstall <bundle_id> + + +Viewing the Log Entries +----------------------- +You can view the entries in the log file in the data/log +directory of your ServiceMix installation, or by typing +the following command in the ServiceMix console: + + log:display http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml b/examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml new file mode 100644 index 0000000..9366fb2 --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <!-- + + 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. + --> + + <parent> + <groupId>org.apache.servicemix.examples</groupId> + <artifactId>camel-cxf-soap</artifactId> + <version>5.0.2-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-cxf-soap-client</artifactId> + <name>Apache ServiceMix :: Examples :: Camel CXF SOAP :: Client</name> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.servicemix.examples</groupId> + <artifactId>camel-cxf-soap-service</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.servicemix.examples</groupId> + <artifactId>camel-cxf-soap-route</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <configuration> + <mainClass>org.apache.servicemix.examples.camel.soap.client.Client</mainClass> + <includePluginDependencies>true</includePluginDependencies> + </configuration> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-client/src/main/java/org/apache/servicemix/examples/camel/soap/client/Client.java ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-client/src/main/java/org/apache/servicemix/examples/camel/soap/client/Client.java b/examples/camel/camel-cxf-soap/camel-cxf-soap-client/src/main/java/org/apache/servicemix/examples/camel/soap/client/Client.java new file mode 100644 index 0000000..de61063 --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-client/src/main/java/org/apache/servicemix/examples/camel/soap/client/Client.java @@ -0,0 +1,105 @@ +/** + * 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.examples.camel.soap.client; + +import org.apache.servicemix.examples.camel.soap.PersonService; +import org.apache.servicemix.examples.camel.soap.model.Person; + +import javax.xml.ws.Service; +import javax.xml.ws.soap.SOAPBinding; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.namespace.QName; +import java.net.MalformedURLException; +import java.net.URL; + +public class Client { + + + + + public static void main(String[] args) throws MalformedURLException { + Client client = new Client(); + try { + client.postPerson(new Person(1,"John Smith",21)); + client.getPerson(1); + client.deletePerson(1); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println(); + } + + + + private PersonService personService; + private static final QName SERVICE_NAME = new QName("http://soap.camel.examples.servicemix.apache.org/", "PersonService"); + private static final String wsdlLocation = "http://localhost:8989/soap/?wsdl"; + + public Client() throws MalformedURLException { + URL wsdlURL = new URL(wsdlLocation); + Service service = Service.create(wsdlURL,SERVICE_NAME); + personService = service.getPort(PersonService.class); + } + + public void postPerson(Person person) throws Exception{ + System.out.println("\n### PUT PERSON -> "); + printPerson(person); + + Person result = personService.putPerson(person); + + System.out.println("\n### PUT PERSON RESPONSE "); + printPerson(result); + } + + public void getPerson(int id) throws Exception{ + System.out.println("\n### GET PERSON WITH ID "+id); + Person result = personService.getPerson(id); + + System.out.println("\n### GET PERSON RESPONSE"); + printPerson(result); + } + + public void deletePerson(int id) throws Exception{ + System.out.println("\n### DELETE PERSON WITH ID "+id); + String result = personService.deletePerson(id); + + System.out.println("\n### DELETE PERSON RESPONSE"); + System.out.println(result); + } + + + + + private void printPerson(Person person){ + + try { + JAXBContext jaxbContext = JAXBContext.newInstance(Person.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); + + // pretty xml output + jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal(person, System.out); + } catch (JAXBException e) { + System.err.print(e); + } + + } + http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-route/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-route/pom.xml b/examples/camel/camel-cxf-soap/camel-cxf-soap-route/pom.xml new file mode 100644 index 0000000..451e01f --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-route/pom.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <!-- + + 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. + --> + + <parent> + <groupId>org.apache.servicemix.examples</groupId> + <artifactId>camel-cxf-soap</artifactId> + <version>5.0.2-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-cxf-soap-route</artifactId> + <name>Apache ServiceMix :: Examples :: Camel CXF SOAP :: Route</name> + <packaging>bundle</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.servicemix.examples</groupId> + <artifactId>camel-cxf-soap-service</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <configuration> + <instructions> + <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> + <Bundle-Description>${project.description}</Bundle-Description> + <Import-Package>*;resolution:=optional</Import-Package> + <Private-Package>org.apache.servicemix.examples.camel.soap</Private-Package> + <Export-Package></Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-route/src/main/java/org/apache/servicemix/examples/camel/soap/PersonService.java ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-route/src/main/java/org/apache/servicemix/examples/camel/soap/PersonService.java b/examples/camel/camel-cxf-soap/camel-cxf-soap-route/src/main/java/org/apache/servicemix/examples/camel/soap/PersonService.java new file mode 100644 index 0000000..ddf4315 --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-route/src/main/java/org/apache/servicemix/examples/camel/soap/PersonService.java @@ -0,0 +1,32 @@ +/** + * 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.examples.camel.soap; + +import org.apache.servicemix.examples.camel.soap.model.Person; + +import javax.jws.WebParam; +import javax.jws.WebService; + +@WebService(serviceName = "PersonService") +public interface PersonService { + Person getPerson(@WebParam(name="id")int id); + + Person putPerson(Person person); + + String deletePerson(@WebParam(name="id")int id); +} http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/examples/camel/camel-cxf-soap/camel-cxf-soap-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..ec554ac --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,51 @@ +<?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. + +--> + +<blueprint + xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jaxws="http://cxf.apache.org/jaxws" + xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" + xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf" + xsi:schemaLocation=" + http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.1/blueprint.xsd"> + + <cm:property-placeholder persistent-id="org.apache.servicemix.examples.cxf.receive" update-strategy="reload"> + <cm:default-properties> + <cm:property name="CXFserver" value="http://localhost:8989/"/> + <cm:property name="service" value="soap" /> + </cm:default-properties> + </cm:property-placeholder> + + <camelcxf:cxfEndpoint id="personService" + address="${CXFserver}${service}" + serviceClass="org.apache.servicemix.examples.camel.soap.PersonService" + /> + + <camelContext xmlns="http://camel.apache.org/schema/blueprint"> + <route id="PersonServiceRoute"> + <from uri="cxf:bean:personService" /> + <recipientList> + <simple>direct-vm:${header.operationName}</simple> + </recipientList> + </route> + </camelContext> +</blueprint> + http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-service/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-service/pom.xml b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/pom.xml new file mode 100644 index 0000000..319aa34 --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/pom.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <!-- + + 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. + --> + + <parent> + <groupId>org.apache.servicemix.examples</groupId> + <artifactId>camel-cxf-soap</artifactId> + <version>5.0.2-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-cxf-soap-service</artifactId> + <name>Apache ServiceMix :: Examples :: Camel CXF SOAP :: Service</name> + <packaging>bundle</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <configuration> + <instructions> + <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> + <Bundle-Description>${project.description}</Bundle-Description> + <Import-Package>*;resolution:=optional</Import-Package> + <Private-Package>org.apache.servicemix.examples.camel.soap</Private-Package> + <Export-Package>org.apache.servicemix.examples.camel.soap.model</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/ServiceHandler.java ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/ServiceHandler.java b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/ServiceHandler.java new file mode 100644 index 0000000..c7daf7f --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/ServiceHandler.java @@ -0,0 +1,70 @@ +/** + * 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.examples.camel.soap; + +import org.apache.servicemix.examples.camel.soap.model.Person; + +import java.util.HashMap; +import java.util.Map; + +public class ServiceHandler { + + public static final String ERROR = "error"; + public static final String OK = "ok"; + Map<Integer,Person> persons = new HashMap<Integer,Person>(); + + public void init(){ + add(new Person(0,"test",100)); + } + + private void add(Person person){ + persons.put(person.getId(), person); + } + + private Person get(int id){ + return persons.get(id); + } + + private Person delete(int id){ + return persons.remove(id); + } + + public Person getPerson(String id){ + return get(Integer.parseInt(id)); + } + + public Person putPerson(Person person){ + add(person); + return person; + } + + public String deletePerson(String id){ + Person result = delete(Integer.parseInt(id)); + if (result == null){ + return ERROR; + }else{ + return OK; + } + } + + + + + + +} http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/model/Person.java ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/model/Person.java b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/model/Person.java new file mode 100644 index 0000000..e78fa79 --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/model/Person.java @@ -0,0 +1,73 @@ +/** + * 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.examples.camel.soap.model; + +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement +public class Person { + private String name; + private int age; + private int id; + + public Person(int id, String name, int age) { + this.name = name; + this.age = age; + this.id = id; + } + + public Person() { + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Person person = (Person) o; + + if (id != person.id) return false; + + return true; + } +} http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000..80e079a --- /dev/null +++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,50 @@ +<?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. + +--> +<blueprint + xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd + http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> + + <bean id="serviceHandler" class="org.apache.servicemix.examples.camel.soap.ServiceHandler" init-method="init" /> + + + <camelContext xmlns="http://camel.apache.org/schema/blueprint" > + <route id="getPerson"> + <from uri="direct-vm:getPerson" /> + <log message="getPerson invocation with id: ${body}"/> + <bean method="getPerson" ref="serviceHandler"/> + </route> + <route id="putPerson" trace="true"> + <from uri="direct-vm:putPerson" /> + <!-- The message body gets passed as a org.apache.cxf.message.MessageContentsList. + We should take the first element of this list to log our person. --> + <log message="putPerson invocation with body: ${body[0]}"/> + <bean method="putPerson" ref="serviceHandler"/> + </route> + <route id="deletePerson"> + <from uri="direct-vm:deletePerson" /> + <log message="deletePerson invocation with id: ${body}"/> + <bean method="deletePerson" ref="serviceHandler"/> + </route> + </camelContext> + +</blueprint> http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/camel-cxf-soap/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-cxf-soap/pom.xml b/examples/camel/camel-cxf-soap/pom.xml new file mode 100644 index 0000000..637f6af --- /dev/null +++ b/examples/camel/camel-cxf-soap/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <!-- + + 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. + --> + + <parent> + <groupId>org.apache.servicemix.examples</groupId> + <artifactId>camel-examples</artifactId> + <version>5.0.2-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>camel-cxf-soap</artifactId> + <name>Apache ServiceMix :: Examples :: Camel CXF SOAP</name> + <packaging>pom</packaging> + + <modules> + <module>camel-cxf-soap-route</module> + <module>camel-cxf-soap-service</module> + <module>camel-cxf-soap-client</module> + </modules> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/servicemix/blob/a4e26654/examples/camel/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel/pom.xml b/examples/camel/pom.xml index c0863b2..d3e5ff4 100644 --- a/examples/camel/pom.xml +++ b/examples/camel/pom.xml @@ -39,6 +39,7 @@ <module>camel-drools-blueprint</module> <module>camel-sql</module> <module>camel-cxf-rest</module> + <module>camel-cxf-soap</module> </modules> </project>
