camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Shaw <Matthew.S...@ambulance.qld.gov.au>
Subject RE: Consuming Web Services
Date Tue, 05 Sep 2017 21:08:21 GMT
Hi Carlos,

There are a number of camel components to use for consuming web services, I assume you mean
SOAP, although the url does not look SOAP like, do you require REST?

Either way, I've been using the camel cxf component. 

Step1: Create a CxfEndpoint in your camel route like the following:
CxfEndpoint toEndpoint = new CxfEndpoint();
            toEndpoint.setCamelContext(getContext());
            toEndpoint.setWsdlURL("wsdl/PaymentTimesheetService.wsdl");
            toEndpoint.setAddress(System.getProperty("mtaworkflow.address.absolute"));
            toEndpoint.setDataFormat(DataFormat.PAYLOAD);

Note, I use PAYLOAD data format, which means you'll need to unmarshal / marshal your messages
bodies before sending / consuming using the jaxbdataformat. See below
// setup jaxb formatters
            org.apache.camel.converter.jaxb.JaxbDataFormat etsEntityDataFormat = new org.apache.camel.converter.jaxb.JaxbDataFormat(
                    "au.gov.qld.ambulance.services.data.messaging.entity.services.corporate.hri.mta"
            );
            org.apache.camel.converter.jaxb.JaxbDataFormat mtaEntityDataFormat = new org.apache.camel.converter.jaxb.JaxbDataFormat(
                    "au.gov.qld.ambulance.services.data.mtaworkflow"
            );

Then in your route do the following
.process(new Processor() {
                            @SuppressWarnings("unchecked")
                            public void process(final Exchange exchange) throws Exception
{
                                TimesheetRequest timesheetRequest = (TimesheetRequest) exchange.getIn().getBody();
                                ETimesheetRequest eTimesheetRequest = new ETimesheetRequest();
                                eTimesheetRequest.setHeader(timesheetRequest.getHeader());
                                eTimesheetRequest.setTimesheetId(timesheetRequest.getTimesheetId());
                                exchange.getIn().setBody(eTimesheetRequest);


                            }
                        })
                        .marshal(etsEntityDataFormat)
.setHeader("operationName", simple("create"))
                            .setHeader("operationNamespace", simple("http://services.ambulance.qld.gov.au/mtaworkflow")
)
                            .to(toEndpoint)

There's many ways of doing it in camel as you've probably noticed, this works best for me,
as I use karaf as my runtime and I wanted one Cxf server running in my container (ie. Once
instance running on same host/port for multiple endpoints that I provide).

If you want consume RESTful services, I use the caml-http component, which makes things very
easy just do the following in java dsl
.to("http://pc003142:8983/solr/QASCostCode/select?bridgeEndpoint=true")

Hope this helps you.

Cheers,
Matt.


-----Original Message-----
From: Carlos Cruz [mailto:carlos@ccradius.com] 
Sent: Wednesday, 6 September 2017 4:46 AM
To: users@camel.apache.org
Subject: Consuming Web Services

I'm new to Camel, I'm evaluating it to see if I can use it for a new application. 
I'm trying to consume a web service like : as url.com/account/login?USERNAME=username&PASSWORD=password
A string with a session ID is returned which I need to assign to a variable.


My question is which component would be recommend for this particular type
of use. And is there a Pure Java example?

At the risk of sounding obtuse, I have gone through the examples and online
reference and a book I purchased... but I'm still a bit confused. 

Thanks for any help!!
Carlos 


This email, including any attachments sent with it, is confidential and for the sole use of
the intended recipient(s). This confidentiality is not waived or lost, if you receive it and
you are not the intended recipient(s), or if it is transmitted/received in error.

Any unauthorised use, alteration, disclosure, distribution or review of this email is strictly
prohibited. The information contained in this email, including any attachment sent with it,
may be subject to a statutory duty of confidentiality if it relates to health service matters.

If you are not the intended recipient(s), or if you have received this email in error, you
are asked to immediately notify the sender. You should also delete this email, and any copies,
from your computer system network and destroy any hard copies produced.

If not an intended recipient of this email, you must not copy, distribute or take any action(s)
that relies on it; any form of disclosure, modification, distribution and/or publication of
this email is also prohibited.

Although the Queensland Ambulance Service takes all reasonable steps to ensure this email
does not contain malicious software, the Queensland Ambulance Service does not accept responsibility
for the consequences if any person's computer inadvertently suffers any disruption to services,
loss of information, harm or is infected with a virus, other malicious computer programme
or code that may occur as a consequence of receiving this email.

Unless stated otherwise, this email represents only the views of the sender and not the views
of the Queensland Government.

********************************************************************************

The content presented in this publication is distributed by the Queensland Government as an
information source only. The State of Queensland makes no statements, representations or warranties
about the accuracy, completeness or reliability of any information contained in this publication.
The State of Queensland disclaims all responsibility and all liability (including without
limitation for liability in negligence) for all expenses, losses, damages and costs you might
incur as a result of the information being inaccurate or incomplete in any way, and for any
reason reliance was placed on such information.


Mime
View raw message