We could store some options parameter into the message header, such as the user 
id or other description.
Normally, we could override the URI options by setting a new value on the 
message header.
The message body could be a single simple object or a complex object which 
contains all the parameters.


--  
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 Tuesday, February 26, 2013 at 5:22 PM, Joe San wrote:

> Willem,
>  
> Did you mean message header or message body?
>  
> Regards,
> Jothi
>  
>  
> On Tue, Feb 26, 2013 at 8:41 AM, Willem jiang <willem.ji...@gmail.com 
> (mailto:willem.ji...@gmail.com)>wrote:
>  
> > Yes,and we normally put the parameters into the message header.
> >  
> >  
> > --
> > 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 Tuesday, February 26, 2013 at 1:58 PM, Joe San wrote:
> >  
> > > So you mean to say that in my Producer, I can get all the properties
> > that I
> > > need to use to connect to the service from the Message body. I'm just
> > > wondering how. Just for me to be clear, here is a scenario wherein the
> > > paypal call is made based on the result of a http call
> >  
> >  
> > from(httpCallWithPayPalParametersSetByTheUser).to(paypal://adaptivepayments?operation=pay)
> > >  
> > > So if I understand this correctly, the result of the from(...) operation
> > > will have the parameters set in the Message's body and I can get that
> >  
> >  
> > form
> > > there are create the PayPal type objects and call the PayPal API?
> > >  
> > > Regrds,
> > > Jothi
> > >  
> > >  
> > > On Mon, Feb 25, 2013 at 10:59 PM, Christian Müller <
> > > christian.muel...@gmail.com (mailto:christian.muel...@gmail.com)> wrote:
> > >  
> > > > A few comments:
> > > > The AdaptivePaymentsService should be created once (in the doStart()
> > > > method).
> > > > You can look up the parameter from the in message header. You can also
> > >  
> >  
> >  
> > use
> > > > a map as body and look up the properties from there. You can also let
> > >  
> >  
> >  
> > the
> > > > user configure its own binding...
> > > >  
> > > > Best,
> > > > Christian
> > > >  
> > > > Sent from a mobile device
> > > > Am 24.02.2013 02:16 schrieb "Joe San" <codeintheo...@gmail.com 
> > > > (mailto:codeintheo...@gmail.com)(mailto:
> > >  
> >  
> >  
> > codeintheo...@gmail.com (mailto:codeintheo...@gmail.com))>:
> > > >  
> > > > > Camel Riders,
> > > > >  
> > > > > Out of interest and with advice from Christian Müller, I took up the
> > task
> > > > > of writing this component. I created the stubs and I'm trying now to
> > > >  
> > >  
> >  
> >  
> > get
> > > > > the Producer written.
> > > > >  
> > > > > On a high level, PayPay adaptive payments API has different
> > operations
> > > > > (Pay, PaymentDetails and many more....).
> > > >  
> > >  
> >  
> >  
> > https://www.x.com/developers/paypal/documentation-tools/adaptive-payments/integration-guide/APIntro
> > > > >  
> > > > > So the goal is to provide integration to all those API operations. I
> > > > > downloaded the API from x.com (http://x.com) and the API comes with
> > > >  
> > >  
> >  
> >  
> > a sample web
> > > > > application that has an example to all those API operations. There
> > > >  
> > >  
> >  
> >  
> > is a
> > > > > PayRequest type object which must be sent as a parameter to all the
> > > >  
> > > >  
> > > >  
> > > >  
> > > > service
> > > > > calls to the API. So I'm currently stuck with how to stuff the values
> > > >  
> > > >  
> > > >  
> > > >  
> > > > into
> > > > > the PayRequest type object.
> > > > >  
> > > > > Here is a snippet from my implementation so far.... This is actually
> > a
> > > > > snippet from my Producer
> > > > >  
> > > > > @Override
> > > > > public void doRequest(final Exchange exchange) throws Exception {
> > > > > final PayRequest req = populatePayRequest(exchange);
> > > > >  
> > > > > try {
> > > > > final PayRequest request = this.populatePayRequest(exchange);
> > > > > PayResponse resp = this.sendPayRequest(request);
> > > > >  
> > > > > }
> > > > > catch (Exception ex) {
> > > > >  
> > > > > }
> > > > > }
> > > > >  
> > > > > /**
> > > > > *
> > > > > * @param req
> > > > > * @return
> > > > > */
> > > > > private PayResponse sendPayRequest(final PayRequest req) throws
> > > > > PayPalException {
> > > > > PayResponse resp = null;
> > > > >  
> > > > > try {
> > > > > // TODO... Get the properties from a Properties file
> > > > > AdaptivePaymentsService service = new
> > > > > AdaptivePaymentsService(this
> > > > >  
> > > > > .getClass().getResourceAsStream("/sdk_config.properties"));
> > > > > PayResponse resp = service.pay(req);
> > > > >  
> > > > > } catch (IOException ex) {
> > > > >  
> > > > > } catch (MissingCredentialException e) {
> > > > > e.printStackTrace(); //To change body of catch statement use
> > > > > File | Settings | File Templates.
> > > > > } catch (InterruptedException e) {
> > > > > e.printStackTrace(); //To change body of catch statement use
> > > > > File | Settings | File Templates.
> > > > > } catch (ClientActionRequiredException e) {
> > > > > e.printStackTrace(); //To change body of catch statement use
> > > > > File | Settings | File Templates.
> > > > > } catch (SSLConfigurationException e) {
> > > > > e.printStackTrace(); //To change body of catch statement use
> > > > > File | Settings | File Templates.
> > > > > } catch (OAuthException e) {
> > > > > e.printStackTrace(); //To change body of catch statement use
> > > > > File | Settings | File Templates.
> > > > > } catch (HttpErrorException e) {
> > > > > e.printStackTrace(); //To change body of catch statement use
> > > > > File | Settings | File Templates.
> > > > > } catch (InvalidCredentialException e) {
> > > > > e.printStackTrace(); //To change body of catch statement use
> > > > > File | Settings | File Templates.
> > > > > } catch (InvalidResponseDataException e) {
> > > > > e.printStackTrace(); //To change body of catch statement use
> > > > > File | Settings | File Templates.
> > > > > } finally {
> > > > > // Do some cleanup if necessary...
> > > > > }
> > > > >  
> > > > > return resp;
> > > > > }
> > > > >  
> > > > > /**
> > > > > * Populate the pay request
> > > > > * @param exchange
> > > > > * @return
> > > > > */
> > > > > private PayRequest populatePayRequest(Exchange exchange) {
> > > > >  
> > > > > //final PayRequest req = (PayRequest) exchange.getIn().getBody();
> > > > >  
> > > > > Map < String, Object > headers = exchange.getIn().getHeaders();
> > > > >  
> > > > > final PayRequest req = new PayRequest();
> > > > >  
> > > > > final String currencyCode =
> > > > > headers.get(PayPalConstants.PAYPAL_CURRENCY_CODE) != null
> > > > > ? (String)
> > > > > headers.get(PayPalConstants.PAYPAL_CURRENCY_CODE)
> > > > > : config.getCurrencyCode();
> > > > > req.setCurrencyCode(currencyCode);
> > > > >  
> > > > >  
> > > > >  
> > > > > final RequestEnvelope envelop =
> > > > > headers.get(PayPalConstants.PAYPAL_REQUEST_ENVELOP) != null
> > > > > ? new
> > > >  
> > >  
> >  
> >  
> > RequestEnvelope((String)headers.get(PayPalConstants.PAYPAL_REQUEST_ENVELOP))
> > > > > : new
> > > >  
> > > >  
> > > >  
> > > >  
> > > > RequestEnvelope(config.getRequestEnvelopErrorLang());
> > > > >  
> > > > > final List < Receiver > receiver = populateReceiver(headers);
> > > > > final ClientDetailsType clientDetails =
> > > > > populateClientDetails(headers);
> > > > >  
> > > > >  
> > > > > return req;
> > > > > }
> > > > >  
> > > > > Given below is a snippet from the sample web application that came
> > with
> > > > the
> > > > > API that I downloaded. All I want to know is of an elegant way to
> > > >  
> > >  
> >  
> >  
> > create
> > > > > the PayRequest object for the API call. What I want to avoid is to
> > > >  
> > > >  
> > > >  
> > > >  
> > > > provide
> > > > > the user with a whole bunch of parameters that he has to set in the
> > > >  
> > > >  
> > > >  
> > > >  
> > > > header
> > > > > to make the PayPal API call.
> > > > >  
> > > > > protected void doPost(HttpServletRequest request,
> > > > > HttpServletResponse response) throws
> > > > > ServletException, IOException {
> > > > > // TODO Auto-generated method stub
> > > > > HttpSession session = request.getSession();
> > > > > session.setAttribute("url", request.getRequestURI());
> > > > > session.setAttribute(
> > > > > "relatedUrl",
> > > > > "<ul><li><a href='Pay'>Pay</a></li><li><a
> > > > > href='PaymentDetails'>PaymentDetails</a></li><li><a
> > > > > href='Refund'>Refund</a></li><li><a
> > > > > href='GetPaymentOptions'>GetPaymentOptions</a></li><li><a
> > > > > href='ExecutePayment'>ExecutePayment</a></li><li><a
> > > > > href='SetPaymentOptions'>SetPaymentOptions</a></li></ul>");
> > > > > RequestEnvelope requestEnvelope = new RequestEnvelope("en_US");
> > > > >  
> > > > > com.paypal.svcs.types.ap.PayRequest req = new
> > > > > com.paypal.svcs.types.ap.PayRequest();
> > > > >  
> > > > > List<com.paypal.svcs.types.ap.Receiver> receiver = new
> > > > > ArrayList<com.paypal.svcs.types.ap.Receiver>();
> > > > >  
> > > > > com.paypal.svcs.types.ap.Receiver rec = new
> > > > > com.paypal.svcs.types.ap.Receiver();
> > > > > if (request.getParameter("amount") != "")
> > > > >  
> > > > > rec.setAmount(Double.parseDouble(request.getParameter("amount")));
> > > > > if (request.getParameter("mail") != "")
> > > > > rec.setEmail(request.getParameter("mail"));
> > > > > if (request.getParameter("invoiceID") != "")
> > > > > rec.setInvoiceId(request.getParameter("invoiceID"));
> > > > > if (request.getParameter("paymentSubType") != "")
> > > >  
> > > >  
> > > >  
> > > >  
> > > > rec.setPaymentSubType(request.getParameter("paymentSubType"));
> > > > > if (request.getParameter("paymentType") != "")
> > > > > rec.setPaymentType(request.getParameter("paymentType"));
> > > > > if (request.getParameter("phoneNumber") != "") {
> > > > > PhoneNumberType phone = new PhoneNumberType(
> > > > > request.getParameter("countryCode"),
> > > > > request.getParameter("phoneNumber"));
> > > > > phone.setExtension(request.getParameter("extension"));
> > > > > rec.setPhone(phone);
> > > > > }
> > > > > if (request.getParameter("setPrimary") != "")
> > > > > rec.setPrimary(Boolean.parseBoolean(request
> > > > > .getParameter("setPrimary")));
> > > > > receiver.add(rec);
> > > > > ReceiverList receiverlst = new ReceiverList(receiver);
> > > > > req.setReceiverList(receiverlst);
> > > > > req.setRequestEnvelope(requestEnvelope);
> > > > > ClientDetailsType clientDetails = new ClientDetailsType();
> > > > > if (request.getParameter("applicationID") != "")
> > > > > clientDetails.setApplicationId(request
> > > > > .getParameter("applicationID"));
> > > > > if (request.getParameter("customerID") != "")
> > > > >  
> > > > > clientDetails.setCustomerId(request.getParameter("customerID"));
> > > > > if (request.getParameter("customerType") != "")
> > > > >  
> > > > > clientDetails.setCustomerType(request.getParameter("customerType"));
> > > > > if (request.getParameter("deviceID") != "")
> > > > > clientDetails.setDeviceId(request.getParameter("deviceID"));
> > > > > if (request.getParameter("location") != "")
> > > >  
> > > >  
> > > >  
> > > >  
> > > > clientDetails.setGeoLocation(request.getParameter("location"));
> > > > > if (request.getParameter("ipAddress") != "")
> > > >  
> > > >  
> > > >  
> > > >  
> > > > clientDetails.setIpAddress(request.getParameter("ipAddress"));
> > > > > if (request.getParameter("model") != "")
> > > > > clientDetails.setModel(request.getParameter("model"));
> > > > > if (request.getParameter("partnerName") != "")
> > > > >  
> > > > > clientDetails.setPartnerName(request.getParameter("partnerName"));
> > > > > req.setClientDetails(clientDetails);
> > > > > if (request.getParameter("ipnNotificationURL") != "")
> > > > > req.setIpnNotificationUrl(request
> > > > > .getParameter("ipnNotificationURL"));
> > > > > if (request.getParameter("memo") != "")
> > > > > req.setMemo(request.getParameter("memo"));
> > > > > if (request.getParameter("pin") != "")
> > > > > req.setPin(request.getParameter("pin"));
> > > > > if (request.getParameter("senderEmail") != "")
> > > > > req.setSenderEmail(request.getParameter("senderEmail"));
> > > > > if (request.getParameter("feesPayer") != "")
> > > > > req.setFeesPayer(request.getParameter("feesPayer"));
> > > > > FundingConstraint fundingConstraint = new FundingConstraint();
> > > > > List<FundingTypeInfo> fundingTypeInfoList = new
> > > > > ArrayList<FundingTypeInfo>();
> > > > > if (request.getParameter("fundingType") != "") {
> > > > > FundingTypeInfo fundingTypeInfo = new FundingTypeInfo(
> > > > > request.getParameter("fundingType"));
> > > > > fundingTypeInfoList.add(fundingTypeInfo);
> > > > > }
> > > > > FundingTypeList fundingTypeList = new FundingTypeList(
> > > > > fundingTypeInfoList);
> > > > > fundingConstraint.setAllowedFundingType(fundingTypeList);
> > > > > req.setFundingConstraint(fundingConstraint);
> > > > > if (request.getParameter("preapprovalKey") != "")
> > > >  
> > > >  
> > > >  
> > > >  
> > > > req.setPreapprovalKey(request.getParameter("preapprovalKey"));
> > > > > if (request.getParameter("reverseAllPaymentsOnError") != "")
> > > > > req.setReverseAllParallelPaymentsOnError(Boolean
> > > > > .parseBoolean(request
> > > > > .getParameter("reverseAllPaymentsOnError")));
> > > > >  
> > > > > SenderIdentifier senderIdentifier = new SenderIdentifier();
> > > > > if (request.getParameter("senderIdentifierEmail") != "")
> > > > > senderIdentifier.setEmail(request
> > > > > .getParameter("senderIdentifierEmail"));
> > > > > if (request.getParameter("senderCountryCode") != ""
> > > > > && request.getParameter("senderPhoneNumber") != "") {
> > > > > PhoneNumberType senderPhone = new PhoneNumberType(
> > > > > request.getParameter("senderCountryCode"),
> > > > > request.getParameter("senderPhoneNumber"));
> > > > > if (request.getParameter("senderExtension") != "")
> > > > > senderPhone.setExtension(request
> > > > > .getParameter("senderExtension"));
> > > > > senderIdentifier.setPhone(senderPhone);
> > > > > }
> > > > > if (request.getParameter("useCredentials") != "")
> > > >  
> > > >  
> > > >  
> > > >  
> > > > senderIdentifier.setUseCredentials(Boolean.parseBoolean(request
> > > > > .getParameter("useCredentials")));
> > > > > req.setSender(senderIdentifier);
> > > > >  
> > > > > if (request.getParameter("trackingID") != "")
> > > > > req.setTrackingId(request.getParameter("trackingID"));
> > > > > if (request.getParameter("actionType") != "")
> > > > > req.setActionType(request.getParameter("actionType"));
> > > > > if (request.getParameter("cancelURL") != "")
> > > > > req.setCancelUrl(request.getParameter("cancelURL"));
> > > > > if (request.getParameter("currencyCode") != "")
> > > > > req.setCurrencyCode(request.getParameter("currencyCode"));
> > > > > if (request.getParameter("returnURL") != "")
> > > > > req.setReturnUrl(request.getParameter("returnURL"));
> > > > > AdaptivePaymentsService service = new
> > > >  
> > > >  
> > > >  
> > > >  
> > > > AdaptivePaymentsService(this
> > > >  
> > > >  
> > > > .getClass().getResourceAsStream("/sdk_config.properties"));
> > > > > try {
> > > > > com.paypal.svcs.types.ap.PayResponse resp = service.pay(req);
> > > > > response.setContentType("text/html");
> > > > > if (resp != null) {
> > > > > session.setAttribute("RESPONSE_OBJECT", resp);
> > > > > session.setAttribute("lastReq",
> > > >  
> > > >  
> > > >  
> > > >  
> > > > service.getLastRequest());
> > > > > session.setAttribute("lastResp",
> > > > > service.getLastResponse());
> > > > > if (resp.getResponseEnvelope().getAck().toString()
> > > > > .equalsIgnoreCase("SUCCESS")) {
> > > > > Map<Object, Object> map = new LinkedHashMap<Object,
> > > > > Object>();
> > > > > map.put("Ack", resp.getResponseEnvelope().getAck());
> > > > > map.put("Correlation ID", resp.getResponseEnvelope()
> > > > > .getCorrelationId());
> > > > > map.put("Time Stamp", resp.getResponseEnvelope()
> > > > > .getTimestamp());
> > > > > map.put("Pay Key", resp.getPayKey());
> > > > > map.put("Payment Execution Status",
> > > > > resp.getPaymentExecStatus());
> > > > > if (resp.getDefaultFundingPlan() != null)
> > > > > map.put("Default Funding Plan", resp
> > > > >  
> > > > > .getDefaultFundingPlan().getFundingPlanId());
> > > > > map.put("Redirect URL",
> > > > > "<a href=
> > > >  
> > >  
> >  
> >  
> > https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=";
> > > > > + resp.getPayKey()
> > > > > + ">
> > > >  
> > >  
> >  
> >  
> > https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=";
> > > > > + resp.getPayKey() + "</a>");
> > > > > session.setAttribute("map", map);
> > > > > response.sendRedirect("Response.jsp");
> > > > > } else {
> > > > > session.setAttribute("Error", resp.getError());
> > > > > response.sendRedirect("Error.jsp");
> > > > > }
> > > > > }
> > > > > } catch (SSLConfigurationException e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > } catch (InvalidCredentialException e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > } catch (HttpErrorException e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > } catch (InvalidResponseDataException e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > } catch (ClientActionRequiredException e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > } catch (MissingCredentialException e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > } catch (OAuthException e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > } catch (InterruptedException e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > }
> > > > >  
> > > > > }
> > > > >  
> > > > > Thanks for going through such a long post.
> > > > >  
> > > > > Regards,
> > > > > Jothi
> > > >  
> > >  
> >  
>  



Reply via email to