You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ks...@apache.org on 2014/06/16 20:47:29 UTC
[1/2] git commit: SM-2313: Add error handling to camel-cxf-soap
example
Repository: servicemix
Updated Branches:
refs/heads/servicemix-5.1.x b51c2c4f2 -> 7fc9ff708
SM-2313: Add error handling to camel-cxf-soap example
Project: http://git-wip-us.apache.org/repos/asf/servicemix/repo
Commit: http://git-wip-us.apache.org/repos/asf/servicemix/commit/f88864d0
Tree: http://git-wip-us.apache.org/repos/asf/servicemix/tree/f88864d0
Diff: http://git-wip-us.apache.org/repos/asf/servicemix/diff/f88864d0
Branch: refs/heads/servicemix-5.1.x
Commit: f88864d0800d3daca44a30575711f78c7217dc65
Parents: b51c2c4
Author: Wim Verreydt <wi...@anova.be>
Authored: Mon Jun 16 10:53:45 2014 +0200
Committer: Krzysztof Sobkowiak <kr...@gmail.com>
Committed: Mon Jun 16 20:42:51 2014 +0200
----------------------------------------------------------------------
.../camel-cxf-soap-client/pom.xml | 12 ++++++
.../examples/camel/soap/client/Client.java | 4 +-
.../examples/camel/soap/PersonService.java | 5 ++-
.../camel-cxf-soap-service/pom.xml | 7 ++++
.../examples/camel/soap/ServiceHandler.java | 41 +++++++++-----------
.../camel/soap/model/PersonException.java | 21 ++++++++++
6 files changed, 64 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/servicemix/blob/f88864d0/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
index 3a71046..45af629 100644
--- a/examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml
+++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml
@@ -35,6 +35,18 @@
<groupId>org.apache.servicemix.examples</groupId>
<artifactId>camel-cxf-soap-service</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <!-- A dependency on a jaxb implementation will cause problems with the exec plugin classloader -->
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <artifactId>camel-cxf-soap-route</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.servicemix.examples</groupId>
http://git-wip-us.apache.org/repos/asf/servicemix/blob/f88864d0/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
index 05cfe1e..6e2fe2a 100644
--- 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
@@ -77,10 +77,10 @@ public class Client {
public void deletePerson(int id) throws Exception{
System.out.println("\n### DELETE PERSON WITH ID "+id);
- String result = personService.deletePerson(id);
+ Person result = personService.deletePerson(id);
System.out.println("\n### DELETE PERSON RESPONSE");
- System.out.println(result);
+ printPerson(result);
}
http://git-wip-us.apache.org/repos/asf/servicemix/blob/f88864d0/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
index ddf4315..96b3861 100644
--- 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
@@ -18,15 +18,16 @@
package org.apache.servicemix.examples.camel.soap;
import org.apache.servicemix.examples.camel.soap.model.Person;
+import org.apache.servicemix.examples.camel.soap.model.PersonException;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(serviceName = "PersonService")
public interface PersonService {
- Person getPerson(@WebParam(name="id")int id);
+ Person getPerson(@WebParam(name="id")int id) throws PersonException;
Person putPerson(Person person);
- String deletePerson(@WebParam(name="id")int id);
+ Person deletePerson(@WebParam(name="id")int id) throws PersonException;
}
http://git-wip-us.apache.org/repos/asf/servicemix/blob/f88864d0/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
index a5a8035..791cd6c 100644
--- a/examples/camel/camel-cxf-soap/camel-cxf-soap-service/pom.xml
+++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/pom.xml
@@ -30,6 +30,13 @@
<name>Apache ServiceMix :: Examples :: Camel CXF SOAP :: Service</name>
<packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ </dependencies>
+
<build>
<plugins>
<plugin>
http://git-wip-us.apache.org/repos/asf/servicemix/blob/f88864d0/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
index c7daf7f..e6393ac 100644
--- 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
@@ -17,54 +17,51 @@
package org.apache.servicemix.examples.camel.soap;
+import org.apache.camel.Body;
+import org.apache.camel.Exchange;
import org.apache.servicemix.examples.camel.soap.model.Person;
+import org.apache.servicemix.examples.camel.soap.model.PersonException;
import java.util.HashMap;
import java.util.Map;
public class ServiceHandler {
- public static final String ERROR = "error";
- public static final String OK = "ok";
+ public static final String ERR_PERSON_X_NOT_FOUND = "Person %s not found";
+
Map<Integer,Person> persons = new HashMap<Integer,Person>();
public void init(){
- add(new Person(0,"test",100));
- }
-
- private void add(Person person){
+ Person person = new Person(0,"test",100);
persons.put(person.getId(), person);
}
- private Person get(int id){
- return persons.get(id);
+ public void getPerson(@Body String id,Exchange exchange){
+ Person result = persons.get(Integer.parseInt(id));
+ checkResult(id, exchange, result);
}
- private Person delete(int id){
- return persons.remove(id);
+ public Person putPerson(Person person){
+ persons.put(person.getId(), person);
+ return person;
}
- public Person getPerson(String id){
- return get(Integer.parseInt(id));
+ public void deletePerson(@Body String id,Exchange exchange){
+ Person result = persons.remove(Integer.parseInt(id));
+ checkResult(id, exchange, result);
}
- public Person putPerson(Person person){
- add(person);
- return person;
- }
- public String deletePerson(String id){
- Person result = delete(Integer.parseInt(id));
+ private void checkResult(String id, Exchange exchange, Person result) {
if (result == null){
- return ERROR;
+ exchange.getOut().setFault(true);
+ exchange.getOut().setBody(new PersonException(String.format(ERR_PERSON_X_NOT_FOUND, id), id));
}else{
- return OK;
+ exchange.getOut().setBody(result);
}
}
-
-
}
http://git-wip-us.apache.org/repos/asf/servicemix/blob/f88864d0/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/model/PersonException.java
----------------------------------------------------------------------
diff --git a/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/model/PersonException.java b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/model/PersonException.java
new file mode 100644
index 0000000..725d7a3
--- /dev/null
+++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-service/src/main/java/org/apache/servicemix/examples/camel/soap/model/PersonException.java
@@ -0,0 +1,21 @@
+package org.apache.servicemix.examples.camel.soap.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.ws.WebFault;
+
+@WebFault(name="PersonException")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class PersonException extends RuntimeException {
+ private final String personid;
+ public PersonException(String message, String personId){
+ super(message);
+ this.personid = personId;
+ }
+
+ public String getPersonid(){
+ return this.personid;
+ }
+
+
+}
[2/2] git commit: SM-2313: Add error handling to camel-cxf-soap
example
Posted by ks...@apache.org.
SM-2313: Add error handling to camel-cxf-soap example
Project: http://git-wip-us.apache.org/repos/asf/servicemix/repo
Commit: http://git-wip-us.apache.org/repos/asf/servicemix/commit/7fc9ff70
Tree: http://git-wip-us.apache.org/repos/asf/servicemix/tree/7fc9ff70
Diff: http://git-wip-us.apache.org/repos/asf/servicemix/diff/7fc9ff70
Branch: refs/heads/servicemix-5.1.x
Commit: 7fc9ff70882e13cce67e510765f94595c6768485
Parents: f88864d
Author: Krzysztof Sobkowiak <kr...@gmail.com>
Authored: Mon Jun 16 20:43:37 2014 +0200
Committer: Krzysztof Sobkowiak <kr...@gmail.com>
Committed: Mon Jun 16 20:43:37 2014 +0200
----------------------------------------------------------------------
examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/servicemix/blob/7fc9ff70/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
index 45af629..842a1a7 100644
--- a/examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml
+++ b/examples/camel/camel-cxf-soap/camel-cxf-soap-client/pom.xml
@@ -48,11 +48,6 @@
<artifactId>camel-cxf-soap-route</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>
@@ -68,4 +63,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>