JSantosP / akka-camel-cxf-weather

Example of how to use akka-camel and cxf in order to connect with Weather web services
Other
6 stars 0 forks source link

soap 1.2 support on akka-camel-cxf-weather #1

Open xray1111 opened 8 years ago

xray1111 commented 8 years ago

I wonder how to switch to soap 1.2 binding: changing the uri in MyProducerActor? or modify params in the test unit? I just have no clue on where can I put this soap version related information in the code or in the wsdl file.

JSantosP commented 8 years ago

Maybe you probable have to generate a new WSDL that allows binding to SOAP 1.2. I'm not an expert on soap stuff, but I would try to generate a new WSDL using this tool, and then generate again the Java classes with wsdl2java.

xray1111 commented 8 years ago

Hi, Javier

I tried to regenerate the java code after using wsdl2soap, but it still didn't work.

But I found some round ways to make it, I append a bindingId property to the uri value, such as:

val uri = "cxf:http://192.168.0.104:8888/?" + "serviceClass=org.onvif.devicemgmt.Device&bindingId= http://www.w3.org/2003/05/soap/bindings/HTTP/"

And it works!

ren xiao

2016-07-31 19:41 GMT+08:00 Javier Santos notifications@github.com:

Maybe you probable have to generate a new WSDL that allows binding to SOAP 1.2. I'm not an expert on soap stuff, but I would try to generate a new WSDL using this tool http://cxf.apache.org/docs/soap-12.html, and then generate again the Java classes with wsdl2java.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JSantosP/akka-camel-cxf-weather/issues/1#issuecomment-236425465, or mute the thread https://github.com/notifications/unsubscribe-auth/AMx26KgmQ-LAxq68yf-xKYEXzd9Uq90hks5qbIoGgaJpZM4JY9tL .

JSantosP commented 8 years ago

Glad to hear so! If I you need help with anything, please feel free to ask :-)

Regards,

Javier

xray1111 commented 8 years ago

Hi, Javier

I encountered another problem, also related with soap, maybe you can help :)

in the java interface file generated from onvif org wsdl, there are some methods which return "void", such as:

@WebMethod(operationName = "GetDeviceInformation", action = "

http://www.onvif.org/ver10/device/wsdl/GetDeviceInformation") @RequestWrapper(localName = "GetDeviceInformation", targetNamespace = " http://www.onvif.org/ver10/device/wsdl", className = "org.onvif.devicemgmt.GetDeviceInformation") @ResponseWrapper(localName = "GetDeviceInformationResponse", targetNamespace = "http://www.onvif.org/ver10/device/wsdl", className = "org.onvif.devicemgmt.GetDeviceInformationResponse") public void getDeviceInformation( @WebParam(mode = WebParam.Mode.OUT, name = "Manufacturer", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder manufacturer, @WebParam(mode = WebParam.Mode.OUT, name = "Model", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder model, @WebParam(mode = WebParam.Mode.OUT, name = "FirmwareVersion", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder firmwareVersion, @WebParam(mode = WebParam.Mode.OUT, name = "SerialNumber", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder serialNumber, @WebParam(mode = WebParam.Mode.OUT, name = "HardwareId", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder hardwareId );

you can see that it only has @ResponseWrapper annotation but without @WebResult, and the actual output parameters are annotated by @WebParam. Because of this, when I call camel.template.requestBodyAndHeaders(uri, body, headers) in program, exceptions would be thrown as below. Should I call another api but of this "requestBodyAndHeaders"?

[MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 210 type converters [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.17.2 (CamelContext: MyActorSystem) is starting [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - StreamCaching is enabled on CamelContext: MyActorSystem [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.management.DefaultManagementStrategy - JMX is disabled [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultStreamCachingStrategy - StreamCaching in use with spool directory: C:\Users\XRay\AppData\Local\Temp\camel\camel-tmp-1549f71d-a3c5-49dd-bd01-e2d10f1cb0db and rules: [Spool > 128K body size] [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - Total 0 routes, of which 0 are started. [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.17.2 (CamelContext: MyActorSystem) started in 1 minute [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean - Creating Service {http://www.onvif.org/ver10/device/wsdl}DeviceService from class org.onvif.devicemgmt.Device [default-workqueue-1] WARN org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for { http://www.onvif.org/ver10/device/wsdl}DeviceService#{http://www.onvif.org/ver10/device/wsdl}GetDeviceInformation has thrown exception, unwinding now java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:653) at java.util.ArrayList.get(ArrayList.java:429) at org.apache.cxf.jaxws.interceptors.HolderInInterceptor.handleMessage(HolderInInterceptor.java:67) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:780) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1670) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1168) at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353) at java.lang.Thread.run(Thread.java:745) [MyActorSystem-akka.actor.default-dispatcher-2] ERROR akka.actor.OneForOneStrategy - Exception occurred during execution on the exchange: Exchange[ID-XRay-PC-50851-1470028286205-0-2] org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-XRay-PC-50851-1470028286205-0-2] at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706) at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:660) at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471) at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:264) at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:313) at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:309) at weatherws.MyProducerActor$$anonfun$receive$1.applyOrElse(MyProducerActor.scala:34) at akka.actor.Actor$class.aroundReceive(Actor.scala:484) at weatherws.MyProducerActor.aroundReceive(MyProducerActor.scala:18) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526) at akka.actor.ActorCell.invoke(ActorCell.scala:495) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) at akka.dispatch.Mailbox.run(Mailbox.scala:224) at akka.dispatch.Mailbox.exec(Mailbox.scala:234) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:653) at java.util.ArrayList.get(ArrayList.java:429) at org.apache.cxf.jaxws.interceptors.HolderInInterceptor.handleMessage(HolderInInterceptor.java:67) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:780) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1670) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1168) at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353) at java.lang.Thread.run(Thread.java:745)

2016-07-31 23:21 GMT+08:00 Javier Santos notifications@github.com:

Glad to hear so! If I you need help with anything, please feel free to ask :-)

Regards,

Javier

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JSantosP/akka-camel-cxf-weather/issues/1#issuecomment-236435864, or mute the thread https://github.com/notifications/unsubscribe-auth/AMx26OjUBmYdFiHDNBPoThRi_RuWNVVnks5qbL2MgaJpZM4JY9tL .

xray1111 commented 8 years ago

btw, I also used wireshark and observed that the soap server got the request and gave an correct answer. So it seems that the client didn't parse the result successfully cause the problem

thanks in advance!

2016-08-01 13:41 GMT+08:00 ren xiao renxiao5@gmail.com:

Hi, Javier

I encountered another problem, also related with soap, maybe you can help :)

in the java interface file generated from onvif org wsdl, there are some methods which return "void", such as:

@WebMethod(operationName = "GetDeviceInformation", action = "

http://www.onvif.org/ver10/device/wsdl/GetDeviceInformation") @RequestWrapper(localName = "GetDeviceInformation", targetNamespace = " http://www.onvif.org/ver10/device/wsdl", className = "org.onvif.devicemgmt.GetDeviceInformation") @ResponseWrapper(localName = "GetDeviceInformationResponse", targetNamespace = "http://www.onvif.org/ver10/device/wsdl", className = "org.onvif.devicemgmt.GetDeviceInformationResponse") public void getDeviceInformation( @WebParam(mode = WebParam.Mode.OUT, name = "Manufacturer", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder manufacturer, @WebParam(mode = WebParam.Mode.OUT, name = "Model", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder model, @WebParam(mode = WebParam.Mode.OUT, name = "FirmwareVersion", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder firmwareVersion, @WebParam(mode = WebParam.Mode.OUT, name = "SerialNumber", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder serialNumber, @WebParam(mode = WebParam.Mode.OUT, name = "HardwareId", targetNamespace = "http://www.onvif.org/ver10/device/wsdl") javax.xml.ws.Holder hardwareId );

you can see that it only has @ResponseWrapper annotation but without @WebResult, and the actual output parameters are annotated by @WebParam. Because of this, when I call camel.template.requestBodyAndHeaders(uri, body, headers) in program, exceptions would be thrown as below. Should I call another api but of this "requestBodyAndHeaders"?

[MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 210 type converters [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.17.2 (CamelContext: MyActorSystem) is starting [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - StreamCaching is enabled on CamelContext: MyActorSystem [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.management.DefaultManagementStrategy - JMX is disabled [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultStreamCachingStrategy - StreamCaching in use with spool directory: C:\Users\XRay\AppData\Local\Temp\camel\camel-tmp-1549f71d-a3c5-49dd-bd01-e2d10f1cb0db and rules: [Spool > 128K body size] [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - Total 0 routes, of which 0 are started. [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.17.2 (CamelContext: MyActorSystem) started in 1 minute [MyActorSystem-akka.actor.default-dispatcher-2] INFO org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean - Creating Service {http://www.onvif.org/ver10/device/wsdl}DeviceService from class org.onvif.devicemgmt.Device [default-workqueue-1] WARN org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for { http://www.onvif.org/ver10/device/wsdl}DeviceService#{http://www.onvif.org/ver10/device/wsdl}GetDeviceInformation has thrown exception, unwinding now java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:653) at java.util.ArrayList.get(ArrayList.java:429) at org.apache.cxf.jaxws.interceptors.HolderInInterceptor.handleMessage(HolderInInterceptor.java:67) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:780) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1670) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1168) at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353) at java.lang.Thread.run(Thread.java:745) [MyActorSystem-akka.actor.default-dispatcher-2] ERROR akka.actor.OneForOneStrategy - Exception occurred during execution on the exchange: Exchange[ID-XRay-PC-50851-1470028286205-0-2] org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-XRay-PC-50851-1470028286205-0-2] at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706) at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:660) at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471) at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:264) at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:313) at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:309) at weatherws.MyProducerActor$$anonfun$receive$1.applyOrElse(MyProducerActor.scala:34) at akka.actor.Actor$class.aroundReceive(Actor.scala:484) at weatherws.MyProducerActor.aroundReceive(MyProducerActor.scala:18) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526) at akka.actor.ActorCell.invoke(ActorCell.scala:495) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) at akka.dispatch.Mailbox.run(Mailbox.scala:224) at akka.dispatch.Mailbox.exec(Mailbox.scala:234) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:653) at java.util.ArrayList.get(ArrayList.java:429) at org.apache.cxf.jaxws.interceptors.HolderInInterceptor.handleMessage(HolderInInterceptor.java:67) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:780) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1670) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1168) at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353) at java.lang.Thread.run(Thread.java:745)

2016-07-31 23:21 GMT+08:00 Javier Santos notifications@github.com:

Glad to hear so! If I you need help with anything, please feel free to ask :-)

Regards,

Javier

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JSantosP/akka-camel-cxf-weather/issues/1#issuecomment-236435864, or mute the thread https://github.com/notifications/unsubscribe-auth/AMx26OjUBmYdFiHDNBPoThRi_RuWNVVnks5qbL2MgaJpZM4JY9tL .