You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jipchix <m_...@yahoo.com> on 2013/01/03 01:02:53 UTC

Read web service msg and encrypt some data

Hi - I'm new to Camel and Spring. I'm using Camel in ServiceMix.
For my learning practice, I did some simple things like routing web service
messages around, created queues, consume messages (no action aside from
setup blueprint) from existing code and files.  Now I have to make another
small step where I have to encrypt a field of the XML message using an
internal encryption algorithm.  Currently 
My plan is to reference a bean in my consumer blueprint, create a java class
to match the bean (called manipulator), generate java object from the
message WSDL, and somehow link the manipulator bean to the java object.   I
had created the java object  using wsdl2java, and created the "manipulator"
class.  I have the blueprint file that reference the bean like:
...
   <route id="jms-to-person">
        <from uri="jms:queue:in-person"/>
        <to uri="bean:manipulator"/>
...
The manipulator seems to be called (I saw my debugged message), but it
doesn't seem to pass anything to the java object.  All fields are null.
Is there a full-fledge sample code that can guide me to see how this should
be done properly?  I read some Camel & JAXB marshal/unmarshal stuff and
could not get this to work properly.  Not even sure if I need to do this to
get to the 1 field and manipulate it.

Thanks




--
View this message in context: http://camel.465427.n5.nabble.com/Read-web-service-msg-and-encrypt-some-data-tp5724807.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Read web service msg and encrypt some data

Posted by jipchix <m_...@yahoo.com>.
I have a POJO that was generated using wsdl2java - let's call this Person
class. This class was generated 

Then in my Manipulator class, I have an input parameter - (String xml).  I
write this 'xml' to the log and see that it contains some header and the
message body.  In the Manipulator class then I attempt to instantiate
"Person" thinking somehow it would magically contains fields parsed out from
my XML.  There is no link between them I can see.  Here are the snippets
from the 2 classes:
// MyManipulator.java file
public class MyManipulator {

   @Converter
   public Person Manipulator (String xml) {
   
   Person p = new Person();
 ...      encryptme(p.ssn);
 }
}

//Person.java file
...

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "emplID",
    "firstName",
    "lastName",
    "empType",
    "empClass",
    "ssn",
    "location"
})
@XmlRootElement(name = "Person")
public class Person {

    @XmlElement(required = true)
    protected String emplID;
    @XmlElement(required = true)
    protected String firstName;
    @XmlElement(required = true)
    protected String lastName;
    @XmlElement(required = true)
    protected String empType;
    @XmlElement(required = true)
    protected String empClass;
    @XmlElement(required = true)
    protected String ssn;
   ...
    public String getEmplID() {
        return emplID;
    }
 // Other getters & setters
..

--------------------
As mentioned: I could see the message and header in 'xml' var.  However, if
I try to output p.ssn, p.empID, etc., they all showed null.  So I have
message in the 'xml' but I can't get it mapped to "Person" object to
manipulate ssn.

Thanks

 




--
View this message in context: http://camel.465427.n5.nabble.com/Read-web-service-msg-and-encrypt-some-data-tp5724807p5724857.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Read web service msg and encrypt some data

Posted by Willem jiang <wi...@gmail.com>.
How did you access the PAYLOAD message in your manipulator bean?
I think it should be easy to do some transformation there.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, January 3, 2013 at 11:31 PM, jipchix wrote:

> I forgot to say that after encrypting 1 field of the message, I'll forward
> the modified message to another queue.
>  
> Thanks
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Read-web-service-msg-and-encrypt-some-data-tp5724807p5724838.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Read web service msg and encrypt some data

Posted by jipchix <m_...@yahoo.com>.
I forgot to say that after encrypting 1 field of the message, I'll forward
the modified message to another queue.

Thanks



--
View this message in context: http://camel.465427.n5.nabble.com/Read-web-service-msg-and-encrypt-some-data-tp5724807p5724838.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Read web service msg and encrypt some data

Posted by jipchix <m_...@yahoo.com>.
If I understand your question correctly - I'm using dataFormat=PAYLOAD.
   <route id="employee-listener">
   <from uri="cxf:bean:employee-ws?dataFormat=PAYLOAD"/>




--
View this message in context: http://camel.465427.n5.nabble.com/Read-web-service-msg-and-encrypt-some-data-tp5724807p5724812.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Read web service msg and encrypt some data

Posted by Willem Jiang <wi...@gmail.com>.
Hi 
What data format are you using with you camel cxf endpoint.
As you just want to change one field.  It could be more easy for you to use the POJO data format.

发自我的 iPhone

在 2013-1-3,上午8:02,jipchix <m_...@yahoo.com> 写道:

> Hi - I'm new to Camel and Spring. I'm using Camel in ServiceMix.
> For my learning practice, I did some simple things like routing web service
> messages around, created queues, consume messages (no action aside from
> setup blueprint) from existing code and files.  Now I have to make another
> small step where I have to encrypt a field of the XML message using an
> internal encryption algorithm.  Currently 
> My plan is to reference a bean in my consumer blueprint, create a java class
> to match the bean (called manipulator), generate java object from the
> message WSDL, and somehow link the manipulator bean to the java object.   I
> had created the java object  using wsdl2java, and created the "manipulator"
> class.  I have the blueprint file that reference the bean like:
> ...
>   <route id="jms-to-person">
>        <from uri="jms:queue:in-person"/>
>        <to uri="bean:manipulator"/>
> ...
> The manipulator seems to be called (I saw my debugged message), but it
> doesn't seem to pass anything to the java object.  All fields are null.
> Is there a full-fledge sample code that can guide me to see how this should
> be done properly?  I read some Camel & JAXB marshal/unmarshal stuff and
> could not get this to work properly.  Not even sure if I need to do this to
> get to the 1 field and manipulate it.
> 
> Thanks
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Read-web-service-msg-and-encrypt-some-data-tp5724807.html
> Sent from the Camel - Users mailing list archive at Nabble.com.