Using Camel and trying to create a route where I want to consume a web service where the vendor has implemented several steps.
The vendor wants any client to first call a Login endpoint and then after successful login any other call will succeed.
http://edw.morningstar.com/webservice/edw.asmx?wsdl
I've been trying several ways but always end up with the return string:
<StatusCode>1003</StatusCode><StatusMessage>You need call Login() or LoginAndGetClientId() first</StatusMessage>
What I'd like to do is to get files from a directory and then send it as binary(base64) to the web service.
EDIT: malformed example, fixed the example… Here's one version of my code:
final ModelCamelContext camCtx = getContext();
camCtx.setTracing(true);
final CxfComponent cxf = new CxfComponent(getContext());
final CxfEndpoint endLogin = new CxfEndpoint(
"http://edw.morningstar.com/webservice/edw.asmx?Login&email=<nnn>&password=<nnn>&clientid=<nnn>",
cxf);
endLogin.setServiceClass(EDWSoap.class);
endLogin.setDataFormat(org.apache.camel.component.cxf.DataFormat.CXF_MESSAGE);
endLogin.setWsdlURL("http://edw.morningstar.com/webservice/edw.asmx?wsdl");
final CxfEndpoint endGetUploadList = new CxfEndpoint(
"http://edw.morningstar.com/webservice/edw.asmx?UploadPrivateList&ClientId=<nnn>&flag=ISIN&filename=filename.txt&fs=",
cxf);
endGetUploadList.setServiceClass(EDWSoap.class);
endGetUploadList.setDataFormat(org.apache.camel.component.cxf.DataFormat.CXF_MESSAGE);
endGetUploadList.setWsdlURL("http://edw.morningstar.com/webservice/edw.asmx?wsdl");
from("file:data/inbox").marshal().base64().to(endLogin).to(endGetUploadList).log("MyLogg: ${body}").stop();
Here's the trace:
2015-12-14 14:38:24:463 o.a.camel.spring.SpringCamelContext INFO - Route: route2 started and consuming from: Endpoint[file://data/inbox]
2015-12-14 14:38:25:513 o.a.c.processor.interceptor.Tracer INFO - ID-Grevens-MBP-local-50361-1450100301592-0-2 >>> (route2) from(file://data/inbox) --> marshal[org.apache.camel.dataformat.base64.Base64DataFormat@2b289ac9] <<< Pattern:InOnly, Headers:{breadcrumbId=ID-Grevens-MBP-local-50361-1450100301592-0-1, CamelFileAbsolute=false, CamelFileAbsolutePath=/Users/mgr/git/FundDecomposition/FundDecomposition/data/inbox/kaka.txt, CamelFileContentType=null, CamelFileLastModified=1449815386000, CamelFileLength=5, CamelFileName=kaka.txt, CamelFileNameConsumed=kaka.txt, CamelFileNameOnly=kaka.txt, CamelFileParent=data/inbox, CamelFilePath=data/inbox/kaka.txt, CamelFileRelativePath=kaka.txt}, BodyType:org.apache.camel.component.file.GenericFile, Body:[Body is file based: GenericFile[kaka.txt]]
2015-12-14 14:38:25:523 o.a.c.processor.interceptor.Tracer INFO - ID-Grevens-MBP-local-50361-1450100301592-0-2 >>> (route2) marshal[org.apache.camel.dataformat.base64.Base64DataFormat@2b289ac9] --> http://edw.morningstar.com/webservice/edw.asmx?UploadPrivateList&ClientId=<nnn>&flag=ISIN&filename=gegga.txt&fs= <<< Pattern:InOnly, Headers:{breadcrumbId=ID-Grevens-MBP-local-50361-1450100301592-0-1, CamelFileAbsolute=false, CamelFileAbsolutePath=/Users/mgr/git/FundDecomposition/FundDecomposition/data/inbox/kaka.txt, CamelFileContentType=null, CamelFileLastModified=1449815386000, CamelFileLength=5, CamelFileName=kaka.txt, CamelFileNameConsumed=kaka.txt, CamelFileNameOnly=kaka.txt, CamelFileParent=data/inbox, CamelFilePath=data/inbox/kaka.txt, CamelFileRelativePath=kaka.txt}, BodyType:byte[], Body:Z2VnZ2E=
2015-12-14 14:38:25:805 route2 INFO - MyLogg: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope"/><soap:Body><GetUniverseXMLResponse xmlns="http://tempuri.org/"><GetUniverseXMLResult><XOIException xmlns=""><StatusCode>1003</StatusCode><StatusMessage>You need call Login() or LoginAndGetClientId() first</StatusMessage></XOIException></GetUniverseXMLResult></GetUniverseXMLResponse></soap:Body></soap:Envelope>
If endGetUploadList
and endLogin
work as expected, I would try something like this:
from("file:data/inbox")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
ProducerTemplate producer=exchange.getContext().createProducerTemplate();
producer.requestBody("direct:mock", new Object());
}
})
.marshal()
.base64()
.to(endGetUploadList)
.log("MyLogg: ${body}")
.stop();
(ProducerTemplate will call you mock route before calling main webservice)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.