Re: JPA component - Persist 1 record working but how to persist many records?

2013-10-26 Thread richie.rivi...@gmail.com
Hi All,

Well I spent a few hours on this today trying to understand how to do this.
What I did was to change my splitter to do this...

public List splitItemsRootDocuments(ItemRootDocument 
doc) {
List itemDocuments = doc.getItemDocumentsList();
return itemDocuments;
}

It returns both items 93501250080 and 93501250090.

Then I changed my converter...

 public class ItemTransformer {
@Converter
public ItemEntity toItem(ItemDocuments docs, Exchange exchange)
throws Exception {
  JpaTemplate template =
exchange.getIn().getHeader("CamelJpaTemplate", JpaTemplate.class);
  List items = new ArrayList();
  List itemDocs = docs.getItemDocumentList();
  for (Iterator i = itemDocs.iterator(); i.hasNext();){
  ItemDocument doc = (ItemDocument)i.next();
  String itemNo = doc.getItemNo(); 
  ItemEntity item = new ItemEntity();
  item.setItemNo(itemNo);
  item.setDescription(doc.getDescription());
  }
  return items;
} 

to return a list of ItemEntity's. (i.e. not just the one). Does this seem
like the right approach. I thinking it is. 

The only error I have now is ...

No type converter available to convert from type:
org.apache.camel.example.etl.ItemDocuments to the required type:
org.apache.camel.example.etl.ItemEntity

Because I'm now returning a list of ItemEntity objects instead of just the
single one. I don't know how to fix this yet but will try to find out.

Comments to tell me if I am heading down the right track would be much
appreciated.

thanks



--
View this message in context: 
http://camel.465427.n5.nabble.com/JPA-component-Persist-1-record-working-but-how-to-persist-many-records-tp5742267p5742269.html
Sent from the Camel - Users mailing list archive at Nabble.com.


JPA component - Persist 1 record working but how to persist many records?

2013-10-26 Thread richie.rivi...@gmail.com
Hi guys,

Fairly new to Apache Camel. I have a Camel program which parses some XML
using Jaxb and then inserts the parsed objects into the database using open
JPA. The example is very similar to the Camel ETL example. At the moment I
have the application persisting records from the XML however it is only
persisting the first record! 

I'm looking for some advice on how to change the application so that it
inserts all parsed objects (all items in my case).

My item XML looks like this...



 
   
 93501250080
 KHOMBU APFOOTA KOKO HIGH
   
 
 
   
 93501250090
 TEST
   
 


Here is what my route looks like...

from("file:src/data?fileName=FIT.XML&noop=true")
.convertBodyTo(ItemRootDocument.class)  
.split().method(ItemDocumentService.class,
"splitItemsDocuments")
.log("Split line ${body}")
.to("jpa:org.apache.camel.example.etl.ItemEntity");

Here is my Split...

public List splitItemsDocuments(ItemRootDocument doc) {
ItemDocuments itemDocuments = doc.getItemDocumentsList().get(0);
return itemDocuments.getItemDocumentList(); 
}

And my ItemTransformer to convert to an ItemEntity looks like this...

 public class ItemTransformer {

@Converter
public ItemEntity toItem(ItemDocument  doc, Exchange exchange)
throws Exception { 
  JpaTemplate template =
exchange.getIn().getHeader("CamelJpaTemplate", JpaTemplate.class);
  String itemNo = doc.getItemNo(); 
  ItemEntity item = new ItemEntity();
  item.setItemNo(itemNo);
  item.setDescription(doc.getDescription());
  return item;
}

So it splits the Items in the XML document and persists but only persists
the first one. How would I change this so that all parsed items are split?
Thanks







--
View this message in context: 
http://camel.465427.n5.nabble.com/JPA-component-Persist-1-record-working-but-how-to-persist-many-records-tp5742267.html
Sent from the Camel - Users mailing list archive at Nabble.com.


capacity of seda/vm with multipleConsumers=true?

2013-10-26 Thread Keith Freeman
My understanding is that using multipleConsumers=true on a seda:/vm: 
endpoint makes it behave more-or-less like a JMS topic.  Does it then 
have a capacity at which producers will throw/block (e.g. if there are 
no consumers), or does it behave more like an LRU ring buffer, writing 
new values on top of oldest ones?  Or something else?


The component page doesn't give much detail about this case.



Re: Send XML over HTTPS

2013-10-26 Thread Christian Müller
Can you share the route or an unit test with us?

Best,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Sat, Oct 26, 2013 at 10:48 PM, scottj  wrote:

> bumping this. Anyone know why http would works where http4 fails?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Send-XML-over-HTTPS-tp5741619p5742263.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Problems when using Spring DSL with the soap dataformat

2013-10-26 Thread Christian Müller
Could you please tell as on which page you found the outdated code snipped!?

Best,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Sat, Oct 26, 2013 at 5:54 PM, Julián Ignacio Gómez Arias <
jgo...@summan.com> wrote:

> Never Mind I fount that the documentation is outdated and the correct tag
> is: 
>
>
> Thanks
>
>
>
> El 26/10/2013, a las 9:25, Julián Ignacio Gómez Arias 
> escribió:
>
> > Hi to all,
> >
> > I’m having some problems when using the data format soap on a camel
> Spring XML.
> >
> >
> > I gave for example this:
> >
> >uri="cxf:bean:wsLocal?dataFormat=CXF_MESSAGE" />
> >   
> >contentPath="co.com.une.interfazhss.InterfazHSS" version="1.2"
> >   elementNameStrategyRef="soapST" />
> >   
> >
> >   
> >   
> >
> > The  tag its not recognized and says this:
> >
> > cvc-complex-type.2.4.a: Invalid content was found starting with element
> 'soap'. One of '{"http://
> > camel.apache.org/schema/spring":description, "
> http://camel.apache.org/schema/spring":avro, "http://
> > camel.apache.org/schema/spring":beanio, "
> http://camel.apache.org/schema/spring":bindy, "http://
> > camel.apache.org/schema/spring":c24io, "
> http://camel.apache.org/schema/spring":castor, "http://
> > camel.apache.org/schema/spring":crypto, "
> http://camel.apache.org/schema/spring":csv, "http://
> > camel.apache.org/schema/spring":custom, "
> http://camel.apache.org/schema/spring":flatpack, "http://
> > camel.apache.org/schema/spring":gzip, "
> http://camel.apache.org/schema/spring":hl7, "http://
> > camel.apache.org/schema/spring":jaxb, "
> http://camel.apache.org/schema/spring":jibx, "http://
> > camel.apache.org/schema/spring":json, "
> http://camel.apache.org/schema/spring":protobuf, "http://
> > camel.apache.org/schema/spring":rss, "
> http://camel.apache.org/schema/spring":secureXML, "http://
> > camel.apache.org/schema/spring":serialization, "
> http://camel.apache.org/schema/spring":soapjaxb,
> > "http://camel.apache.org/schema/spring":string, "
> http://camel.apache.org/schema/spring":syslog, "http://
> > camel.apache.org/schema/spring":tidyMarkup, "
> http://camel.apache.org/schema/spring":xmlBeans, "http://
> > camel.apache.org/schema/spring":xmljson, "
> http://camel.apache.org/schema/spring":xstream, "http://
> > camel.apache.org/schema/spring":pgp, "
> http://camel.apache.org/schema/spring":zip}' is expected.
> >
> >
> > For other data formats like JSON and others work well.
> >
> > Is there something I can do?
> >
> >
> > Best regards,
> >
> >
>
>


Re: Send XML over HTTPS

2013-10-26 Thread scottj
bumping this. Anyone know why http would works where http4 fails?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Send-XML-over-HTTPS-tp5741619p5742263.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Apache Camel 2.12.1 Components Poster Promotion

2013-10-26 Thread Robert James Liguori
Dear Apache Camel Users and Developers, 

Please
 consider attending the online Apache Camel Components Poster Promotion 
which starts next Tuesday, October 29th.  Once there, please consider 
asking questions and or assisting with answering them.

--> Apache Camel Components Poster Promotion @ JavaRanch
--> http://www.coderanch.com/how-to/java/BookPromotionsSchedule

Btw, here is a free PDF of the poster for 2.12.1: 
http://gliesian.com/camel/ApacheCamelComponents.pdf.


Today, I have just completed the poster for 2.12.2 and am preparing the 
updates for 2.13.0.  Note that for the 2.13.0 poster, the external 
components will be removed and the groupings will be improved. 


And if you don't mind, please send out a tweet with this URL: 
http://www.coderanch.com/how-to/java/BookPromotionsSchedule... so people can 
come and chat about the poster and the Camel components. :)


Sincerely,
Robert Liguori

any way to turn off a timer?

2013-10-26 Thread Keith Freeman
I have a route with 2 sources, a timer and a seda queue.  It uses the 
timer to poll a data source while it's getting data from the queue, and 
processes all of  the data identically later in the route.  But after a 
while, the polled data source is exhausted while the seda queue (and the 
route) will continue to run more-or-less forever.


So once I recognize that the polled data source is exhausted, I'd like 
to turn off the timer so I don't have to start ignoring the polls from 
it.  I realize I might be able to use 2 separate routes and just stop 
the timer route when it's done, but having only 1 route fits my design 
much better.


So is there any way to turn off the timer?  (BTW I don't know the number 
of polls in advance, otherwise I know I could use the repeatCount parameter)


Re: SAXParseException due to invalid characters in cxf endpoint response

2013-10-26 Thread bhushand
Hi Claus
   Thank for reply, i will keep in mind your suggestion. Please find my
comment,

Also your first post its not clear if the DB value and display value 
is different. Looking in the mail they look the same. -- While writting post
I had given different values but maybe due to IE it get displayed same. Our
main problem is ,in our response header content-type does not contains
UTF-8. We can see its there when response is coming from our local server
but not in response from different environment servers. As we are using
websphere, is there any property need to set because interceptor and other
things are not working for us.



Thanks
Bhushan



--
View this message in context: 
http://camel.465427.n5.nabble.com/SAXParseException-due-to-invalid-characters-in-cxf-endpoint-response-tp5742212p5742259.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Problems when using Spring DSL with the soap dataformat

2013-10-26 Thread Julián Ignacio Gómez Arias
Never Mind I fount that the documentation is outdated and the correct tag is: 



Thanks



El 26/10/2013, a las 9:25, Julián Ignacio Gómez Arias  
escribió:

> Hi to all,
> 
> I’m having some problems when using the data format soap on a camel Spring 
> XML.
> 
> 
> I gave for example this:
> 
>   
>   
>contentPath="co.com.une.interfazhss.InterfazHSS" version="1.2"
>   elementNameStrategyRef="soapST" />
>   
> 
>   
>   
> 
> The  tag its not recognized and says this:
> 
> cvc-complex-type.2.4.a: Invalid content was found starting with element 
> 'soap'. One of '{"http://
> camel.apache.org/schema/spring":description, 
> "http://camel.apache.org/schema/spring":avro, "http://
> camel.apache.org/schema/spring":beanio, 
> "http://camel.apache.org/schema/spring":bindy, "http://
> camel.apache.org/schema/spring":c24io, 
> "http://camel.apache.org/schema/spring":castor, "http://
> camel.apache.org/schema/spring":crypto, 
> "http://camel.apache.org/schema/spring":csv, "http://
> camel.apache.org/schema/spring":custom, 
> "http://camel.apache.org/schema/spring":flatpack, "http://
> camel.apache.org/schema/spring":gzip, 
> "http://camel.apache.org/schema/spring":hl7, "http://
> camel.apache.org/schema/spring":jaxb, 
> "http://camel.apache.org/schema/spring":jibx, "http://
> camel.apache.org/schema/spring":json, 
> "http://camel.apache.org/schema/spring":protobuf, "http://
> camel.apache.org/schema/spring":rss, 
> "http://camel.apache.org/schema/spring":secureXML, "http://
> camel.apache.org/schema/spring":serialization, 
> "http://camel.apache.org/schema/spring":soapjaxb, 
> "http://camel.apache.org/schema/spring":string, 
> "http://camel.apache.org/schema/spring":syslog, "http://
> camel.apache.org/schema/spring":tidyMarkup, 
> "http://camel.apache.org/schema/spring":xmlBeans, "http://
> camel.apache.org/schema/spring":xmljson, 
> "http://camel.apache.org/schema/spring":xstream, "http://
> camel.apache.org/schema/spring":pgp, 
> "http://camel.apache.org/schema/spring":zip}' is expected.
> 
> 
> For other data formats like JSON and others work well.
> 
> Is there something I can do?
> 
> 
> Best regards,
> 
> 



Problems when using Spring DSL with the soap dataformat

2013-10-26 Thread Julián Ignacio Gómez Arias
Hi to all,

I’m having some problems when using the data format soap on a camel Spring XML.


I gave for example this:









The  tag its not recognized and says this:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'soap'. 
One of '{"http://
 camel.apache.org/schema/spring":description, 
"http://camel.apache.org/schema/spring":avro, "http://
 camel.apache.org/schema/spring":beanio, 
"http://camel.apache.org/schema/spring":bindy, "http://
 camel.apache.org/schema/spring":c24io, 
"http://camel.apache.org/schema/spring":castor, "http://
 camel.apache.org/schema/spring":crypto, 
"http://camel.apache.org/schema/spring":csv, "http://
 camel.apache.org/schema/spring":custom, 
"http://camel.apache.org/schema/spring":flatpack, "http://
 camel.apache.org/schema/spring":gzip, 
"http://camel.apache.org/schema/spring":hl7, "http://
 camel.apache.org/schema/spring":jaxb, 
"http://camel.apache.org/schema/spring":jibx, "http://
 camel.apache.org/schema/spring":json, 
"http://camel.apache.org/schema/spring":protobuf, "http://
 camel.apache.org/schema/spring":rss, 
"http://camel.apache.org/schema/spring":secureXML, "http://
 camel.apache.org/schema/spring":serialization, 
"http://camel.apache.org/schema/spring":soapjaxb, 
 "http://camel.apache.org/schema/spring":string, 
"http://camel.apache.org/schema/spring":syslog, "http://
 camel.apache.org/schema/spring":tidyMarkup, 
"http://camel.apache.org/schema/spring":xmlBeans, "http://
 camel.apache.org/schema/spring":xmljson, 
"http://camel.apache.org/schema/spring":xstream, "http://
 camel.apache.org/schema/spring":pgp, 
"http://camel.apache.org/schema/spring":zip}' is expected.


For other data formats like JSON and others work well.

Is there something I can do?


Best regards,




Re: SAXParseException due to invalid characters in cxf endpoint response

2013-10-26 Thread Claus Ibsen
On Sat, Oct 26, 2013 at 8:25 AM, bhushand  wrote:
> Hello, can I get some help,please.
>

See this page
http://camel.apache.org/support

As said on the bottom of that page, the help on these user forums is
volunteer based, and many of us, are busy with our work et all.

So to get faster help, its often better to help yourself by diving
more into the problem, and isolating the problem as well.

And on the page: http://camel.apache.org/support
We have points what you can do to help yourself and what information
you should provide when asking for help etc.

Also your first post its not clear if the DB value and display value
is different. Looking in the mail they look the same.


>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/SAXParseException-due-to-invalid-characters-in-cxf-endpoint-response-tp5742212p5742243.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: SAXParseException due to invalid characters in cxf endpoint response

2013-10-26 Thread Christian Müller
Which Camel component do you use (We have multiple components which
supports "web services")?
Can you share your route with us?
Can you share a sample message with us?

The best would be if you can provide a unit test which show the issue.

Best,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Sat, Oct 26, 2013 at 8:25 AM, bhushand wrote:

> Hello, can I get some help,please.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/SAXParseException-due-to-invalid-characters-in-cxf-endpoint-response-tp5742212p5742243.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: HTTP Basic Authentication

2013-10-26 Thread Christian Müller
Martin is using the http component, not the CXF component...

Did you checked [1]? You can set the auth options per endpoint.

[1] http://camel.apache.org/http.html

Best,

Christian
-

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Sat, Oct 26, 2013 at 5:44 AM, contactreji  wrote:

> Hi
>
> I used a interceptor approach. The java code for interceptor is as follows
>
> *package outotec.com.mes.bw.copper_recovery_perc;*
> *import java.io.IOException;*
> *import java.io.OutputStream;*
> *import java.net.HttpURLConnection;*
> *import java.util.Arrays;*
> *import java.util.List;*
> *import java.util.Map;*
> *import org.apache.cxf.binding.soap.interceptor.SoapHeaderInterceptor;*
> *import org.apache.cxf.configuration.security.AuthorizationPolicy;*
> *import org.apache.cxf.endpoint.Endpoint;*
> *import org.apache.cxf.interceptor.Fault;*
> *import org.apache.cxf.message.Exchange;*
> *import org.apache.cxf.message.Message;*
> *import org.apache.cxf.transport.Conduit;*
> *import org.apache.cxf.ws.addressing.EndpointReferenceType;*
> *import org.apache.log4j.Logger;*
> *import org.springframework.beans.factory.annotation.Required;*
> *
> *
> */***
> * * CXF Interceptor that provides HTTP Basic Authentication validation.*
> * * *
> * * Based on the concepts outline here:*
> * *
> http://chrisdail.com/2008/03/31/apache-cxf-with-http-basic-authentication*
> * **
> * * @author CDail*
> * */*
> *public class BasicAuthAuthorizationInterceptor extends
> SoapHeaderInterceptor {*
> *
> *
> *protected Logger log = Logger.getLogger(getClass());*
> **
> */** Map of allowed users to this system with their corresponding
> passwords. */*
> *private Map users;*
> **
> *@Required*
> *public void setUsers(Map users) {*
> *this.users = users;*
> *}*
> **
> *@Override public void handleMessage(Message message) throws Fault {*
> *// This is set by CXF*
> *AuthorizationPolicy policy =
> message.get(AuthorizationPolicy.class);*
> **
> *// If the policy is not set, the user did not specify credentials*
> *// A 401 is sent to the client to indicate that authentication is
> required*
> *if (policy == null) {*
> *if (log.isDebugEnabled()) {*
> *log.debug("User attempted to log in with no
> credentials");*
> *}*
> *sendErrorResponse(message,
> HttpURLConnection.HTTP_UNAUTHORIZED);*
> *return;*
> *}*
> **
> *if (log.isDebugEnabled()) {*
> *log.debug("Logging in use: " + policy.getUserName());*
> *}*
> **
> *// Verify the password*
> *String realPassword = users.get(policy.getUserName());*
> *if (realPassword == null ||
> !realPassword.equals(policy.getPassword())) {*
> *log.error("Invalid username or password for user: " +
> policy.getUserName());*
> *   *
> *sendErrorResponse(message, HttpURLConnection.HTTP_FORBIDDEN);*
> *}*
> *}*
> **
> *private void sendErrorResponse(Message message, int responseCode) {*
> *Message outMessage = getOutMessage(message);*
> *outMessage.put(Message.RESPONSE_CODE, responseCode);*
> **
> *// Set the response headers*
> *Map> responseHeaders =*
> *(Map List>)message.get(Message.PROTOCOL_HEADERS);*
> *if (responseHeaders != null) {*
> *responseHeaders.put("WWW-Authenticate", Arrays.asList(new
> String[]{"Basic realm=realm"}));*
> *responseHeaders.put("Content-Length", Arrays.asList(new
> String[]{"0"}));*
> *}*
> *message.getInterceptorChain().abort();*
> *try {*
> *getConduit(message).prepare(outMessage);*
> *close(outMessage);*
> *} catch (IOException e) {*
> *log.warn(e.getMessage(), e);*
> *}*
> *}*
> **
> *private Message getOutMessage(Message inMessage) {*
> *Exchange exchange = inMessage.getExchange();*
> *Message outMessage = exchange.getOutMessage();*
> *if (outMessage == null) {*
> *Endpoint endpoint = exchange.get(Endpoint.class);*
> *outMessage = endpoint.getBinding().createMessage();*
> *exchange.setOutMessage(outMessage);*
> *}*
> *outMessage.putAll(inMessage);*
> *return outMessage;*
> *}*
> **
> *private Conduit getConduit(Message inMessage) throws IOException {*
> *Exchange exchange = inMessage.getExchange();*
> *EndpointReferenceType target =
> exchange.get(EndpointReferenceType.class);*
> *Conduit conduit =*
> *exchange.getDestination().getBackChannel(inMessage, null,
> target);*
> *exchange.setConduit(conduit);*
> *return con