You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by miri eyni <mi...@sapiens.com> on 2016/05/16 06:22:26 UTC
rest to soap
public void configure() throws Exception {
from("jetty:http://localhost:8080/json?matchOnUriPrefix=true").process(new
Processor() {
@Override
public void process(Exchange exchange) throws Exception {
BeanInvocation beanInvocation = new BeanInvocation();
beanInvocation.setMethod(PolicySOAPServices.class.getMethod("findPolicy",
RequestPolicyView.class));
RequestPolicyView requestPolicyView = new RequestPolicyView();
requestPolicyView.setPolicyNo(1079);
Object[] args = new Object[] {requestPolicyView};
beanInvocation.setArgs(args);
exchange.getIn().setBody(beanInvocation);
}
}).to("http://localhost:9060/ws/policyServices/findPolicy?bridgeEndpoint=true");
i got the following error :
016-05-16 09:13:19.359 ERROR 19624 --- [qtp302783055-16]
o.a.camel.processor.DefaultErrorHandler : Failed delivery for (MessageId:
ID-HLLT-PC0A4F7B-50009-1463379165007-0-2 on ExchangeId:
ID-HLLT-PC0A4F7B-50009-1463379165007-0-1). Exhausted after delivery attempt:
1 caught: org.apache.camel.InvalidPayloadException: No body available of
type: java.io.InputStream but has value: BeanInvocation public abstract
com.sapiens.alis.foundation.external.model.entities.dto.policy.ResponsePolicyView
com.sapiens.alis.foundation.soap.interfaces.policy.PolicySOAPServices.findPolicy(com.sapiens.alis.foundation.external.model.entities.dto.policy.RequestPolicyView)
with
[com.sapiens.alis.foundation.external.model.entities.dto.policy.RequestPolicyView@5796fabe]]
of type: org.apache.camel.component.bean.BeanInvocation on:
HttpMessage@0x7927fcde. Caused by: No type converter available to convert
from type: org.apache.camel.component.bean.BeanInvocation to the required
type: java.io.InputStream with value BeanInvocation public abstract
com.sapiens.alis.foundation.external.model.entities.dto.policy.ResponsePolicyView
com.sapiens.alis.foundation.soap.interfaces.policy.PolicySOAPServices.findPolicy(com.sapiens.alis.foundation.external.model.entities.dto.policy.RequestPolicyView)
with
[com.sapiens.alis.foundation.external.model.entities.dto.policy.RequestPolicyView@5796fabe]].
Exchange[ID-HLLT-PC0A4F7B-50009-1463379165007-0-1]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type:
org.apache.camel.component.bean.BeanInvocation to the required type:
java.io.InputStream with value BeanInvocation public abstract
com.sapiens.alis.foundation.external.model.entities.dto.policy.ResponsePolicyView
com.sapiens.alis.foundation.soap.interfaces.policy.PolicySOAPServices.findPolicy(com.sapiens.alis.foundation.external.model.entities.dto.policy.RequestPolicyView)
with
[com.sapiens.alis.foundation.external.model.entities.dto.policy.RequestPolicyView@5796fabe]]]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor
Elapsed (ms)
[route1 ] [route1 ]
[jetty:http://localhost:8080/json?matchOnUriPrefix=true
] [ 189]
[route1 ] [process1 ] [Processor@0x6f08589b
] [ 26]
[route1 ] [to1 ]
[http://localhost:9060/ws/policyServices/findPolicy?bridgeEndpoin] [
160]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.InvalidPayloadException: No body available of type:
java.io.InputStream but has value: BeanInvocation public abstract
com.camel.policy.ResponsePolicyView
com.camel.soap.interfaces.policy.PolicySOAPServices.findPolicy(com.camel.policy.RequestPolicyView)
with [com.camel.policy.RequestPolicyView@5796fabe]] of type:
org.apache.camel.component.bean.BeanInvocation on: HttpMessage@0x7927fcde.
Caused by: No type converter available to convert from type:
org.apache.camel.component.bean.BeanInvocation to the required type:*
java.io.InputStream* with value BeanInvocation public abstract
com.camel.policy.ResponsePolicyView
com.camel.policy.PolicySOAPServices.findPolicy(com.camel.policy.RequestPolicyView)
with [com.camel.policy.RequestPolicyView@5796fabe]].
Exchange[ID-HLLT-PC0A4F7B-50009-1463379165007-0-1]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type:
org.apache.camel.component.bean.BeanInvocation to the required type:
java.io.InputStream with value BeanInvocation public abstract
com.camel.policy.ResponsePolicyView
com.camel.policy.PolicySOAPServices.findPolicy(com.camel.policy.RequestPolicyView)
with [com.camel.policy.RequestPolicyView@5796fabe]]]
at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:107)
~[camel-core-2.17.0.jar:2.17.0]
at
org.apache.camel.component.http.HttpProducer.createRequestEntity(HttpProducer.java:460)
~[camel-http-2.17.0.jar:2.17.0]
why is expected to get java.io.InputStream ?
what i did wrong?
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by yogu13 <yo...@gmail.com>.
A simpler way would be to use camel-cxf see if your can use this
http://camel.apache.org/cxf.html
Regards,
-Yogesh
On Mon, May 16, 2016 at 5:14 PM, miri eyni [via Camel] <
ml-node+s465427n5782665h44@n5.nabble.com> wrote:
> i converted the json to xml
> i try to send soap request from rest , on the process method i converted
> the body to xml
> but i think i am missing somethings ,
>
> from - is rest url
> to - is webService url (soap)
>
>
> from("jetty:http://localhost:8080/json?matchOnUriPrefix=true")
>
> public void process(Exchange exchange) throws Exception {
> String payload =
> exchange.getIn().getBody(String.class);
> JSONObject jsonObj =
> JSONObject.fromObject(payload);
> BeanInvocation beanInvocation = new
> BeanInvocation();
>
> beanInvocation.setMethod(PolicySOAPServices.class.getMethod("findPolicy",
> RequestPolicyView.class));
> RequestPolicyView requestPolicyView = new
> RequestPolicyView();
> requestPolicyView.setPolicyNo(
> (Integer)jsonObj.get("policyNo"));
> Object[] args = new Object[]
> {requestPolicyView};
> beanInvocation.setArgs(args);
> exchange.getIn().setBody(beanInvocation);
> }
> }).marshal().xstream().to("
> http://localhost:6090/ws/policyServices?bridgeEndpoint=true&soapAction=http://policy.camel.com&wsAddressingAction=http://policy.camel.com");
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782665.html
> To unsubscribe from rest to soap, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5782601&code=eW9ndTEzQGdtYWlsLmNvbXw1NzgyNjAxfC04ODQzODQxMjM=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782666.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by miri eyni <mi...@sapiens.com>.
i converted the json to xml
i try to send soap request from rest , on the process method i converted the
body to xml
but i think i am missing somethings ,
from - is rest url
to - is webService url (soap)
from("jetty:http://localhost:8080/json?matchOnUriPrefix=true")
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
JSONObject jsonObj = JSONObject.fromObject(payload);
BeanInvocation beanInvocation = new BeanInvocation();
beanInvocation.setMethod(PolicySOAPServices.class.getMethod("findPolicy",
RequestPolicyView.class));
RequestPolicyView requestPolicyView = new RequestPolicyView();
requestPolicyView.setPolicyNo( (Integer)jsonObj.get("policyNo"));
Object[] args = new Object[] {requestPolicyView};
beanInvocation.setArgs(args);
exchange.getIn().setBody(beanInvocation);
}
}).marshal().xstream().to("http://localhost:6090/ws/policyServices?bridgeEndpoint=true&soapAction=http://policy.camel.com&wsAddressingAction=http://policy.camel.com");
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782665.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by yogu13 <yo...@gmail.com>.
You need to transform the data which your SOAP endpoint can understand.
Looks like you are missing that piece of code.
BTW I see your payload is XML instead of JSON from the logs you added.
Regards,
-Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782663.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by miri eyni <mi...@sapiens.com>.
thanks, i fixed the url
but now i got status code :500
i check the server.log
and its look like the request is a rest request instead of soap.request
Content-Type: application/soap+xml
Headers: {alis-datasource-key=[1],
breadcrumbId=[ID-HLLT-PC0A4F7B-53348-1463390080537-0-2],
Content-Length=[686], content-type=[application/soap+xml],
Host=[localhost:8888], User-Agent=[Jakarta Commons-HttpClient/3.1]}
Payload: <?xml version='1.0'
encoding='UTF-8'?><org.apache.camel.component.bean.BeanInvocation><org.apache.camel.component.bean.MethodBean><name>findPolicy</name><type>com.camel.policy.PolicySOAPServices</type><parameterTypes><java-class>com.camel.policy.RequestPolicyView</java-class></parameterTypes></org.apache.camel.component.bean.MethodBean><object-array><com.camel.policy.RequestPolicyView><policyNo>1079</policyNo></com.sapiens.alis.foundation.external.model.entities.dto.policy.RequestPolicyView></object-array></org.apache.camel.component.bean.BeanInvocation>
--------------------------------------
[2016-05-16 12:14:49.114],[WARN ],[LogUtils.java:452],[],Interceptor for
{http://policy.camel.com/}PolicyGenericServicesImplService has thrown
exception, unwinding now
org.apache.cxf.interceptor.Fault: HTTP verb was not GET or POST
Do you know what is wrong ?
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782661.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by yogu13 <yo...@gmail.com>.
Status code 403 means its forbidden to access the url.
is the url protected ? if yes then you might have to provide authentication
details
Regards,
-Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782609.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by miri eyni <mi...@sapiens.com>.
the same error.
i am also tested :
from("jetty:http://localhost:8080/json?matchOnUriPrefix=true").
process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
JSONObject jsonObj = JSONObject.fromObject(payload);
BeanInvocation beanInvocation = new BeanInvocation();
beanInvocation.setMethod(PolicySOAPServices.class.getMethod("findPolicy",
RequestPolicyView.class));
RequestPolicyView requestPolicyView = new RequestPolicyView();
requestPolicyView.setPolicyNo( (Integer)jsonObj.get("policyNo"));
Object[] args = new Object[] {requestPolicyView};
beanInvocation.setArgs(args);
exchange.getIn().setBody(beanInvocation);
}
}).marshal().xstream().to("localhost:9060/ws/policyServices/findPolicy?bridgeEndpoint=true");
and i got :
HTTP operation failed invoking
http://localhost:9060/ws/policyServices/findPolicy with statusCode: 403
i try to routing from rest to soap ,
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782608.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by yogu13 <yo...@gmail.com>.
try setting the body of in message with the jsonObj
exchange.getIn().setBody(jsonObj);
and set the bean invocation to out as follows
exchange.getOut.setBody(beanInvocation)
Regards,
-Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782607.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by miri eyni <mi...@sapiens.com>.
now i process the request :
public void process(Exchange exchange) throws Exception {
* String payload = exchange.getIn().getBody(String.class);
JSONObject jsonObj = JSONObject.fromObject(payload);*
BeanInvocation beanInvocation = new BeanInvocation();
beanInvocation.setMethod(PolicySOAPServices.class.getMethod("findPolicy",
RequestPolicyView.class));
RequestPolicyView requestPolicyView = new RequestPolicyView();
requestPolicyView.setPolicyNo( (Integer)jsonObj.get("policyNo"));
Object[] args = new Object[] {requestPolicyView};
beanInvocation.setArgs(args);
exchange.getIn().setBody(beanInvocation);
}
}).to("http://alis-dps-bl:8085/dps_sl_env3/ws/policyServices/findPolicy?bridgeEndpoint=true");
but i still get the same error ,what i did wrong?
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782606.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: rest to soap
Posted by yogu13 <yo...@gmail.com>.
Looks like you are not reading the request body which has come in as part of
the from("jetty:http://localhost:8080/json?matchOnUriPrefix=true")
try reading it and convert it to the datatype that the route would use.
Regards,
-Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/rest-to-soap-tp5782601p5782602.html
Sent from the Camel - Users mailing list archive at Nabble.com.