Call a webservice with WSS

0
Calling a DOT net webservice results a in message: javax.xml.ws.WebServiceException: java.lang.ClassCastException: com.sun.xml.ws.message.stream.StreamHeader11 cannot be cast to com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader the policy in the wsdl is; <wsdl:service name="MasterDataServiceInternal"> <wsdl:port name="BasicHttpBinding_MasterDataService" binding="tns:BasicHttpBinding_MasterDataService"> <soap:address location="http://tpcdegelder:8082/"/> </wsdl:port> </wsdl:service> <wsp:Policy wsu:Id="BasicHttpBinding_MasterDataService_policy"> <wsp:ExactlyOne> <wsp:All> <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> <wsp:Policy> <sp:TransportToken> <wsp:Policy> <sp:HttpsToken RequireClientCertificate="false"/> </wsp:Policy> </sp:TransportToken> <sp:AlgorithmSuite> <wsp:Policy> <sp:Basic256/> </wsp:Policy> </sp:AlgorithmSuite> <sp:Layout> <wsp:Policy> <sp:Lax/> </wsp:Policy> </sp:Layout> <sp:IncludeTimestamp/> </wsp:Policy> </sp:TransportBinding> <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> <wsp:Policy> <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> <wsp:Policy> <sp:WssUsernameToken10/> </wsp:Policy> </sp:UsernameToken> </wsp:Policy> </sp:SignedSupportingTokens> <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> <wsp:Policy/> </sp:Wss10> </wsp:All> </wsp:ExactlyOne> </wsp:Policy> Created SOAP message is correct, works in SOAPui. Validate against WSDL is off. Mendix does not call the webservice, error message is created before the webservice call. stacktrace: at MyFirstModule.Test_MasterDataServiceInternal_GetOrganizationUnit (CallWebservice : 'Call web service') Advanced stacktrace: at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:158) Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: javax.xml.ws.WebServiceException: java.lang.ClassCastException: com.sun.xml.ws.message.stream.StreamHeader11 cannot be cast to com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:43) Caused by: javax.xml.ws.WebServiceException: java.lang.ClassCastException: com.sun.xml.ws.message.stream.StreamHeader11 cannot be cast to com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processRequest(SecurityClientTube.java:250) at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:641) at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600) at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585) at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482) at com.sun.xml.ws.client.Stub.process(Stub.java:323) at com.sun.xml.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:192) at com.sun.xml.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:218) at com.mendix.integration.webservices.call.WebserviceCaller$3.run(WebserviceCaller.java:383) at com.mendix.integration.webservices.call.WebserviceCaller$3.run(WebserviceCaller.java:317) at java.security.AccessController.doPrivileged(Native Method) at com.mendix.integration.webservices.call.WebserviceCaller$2.execute(WebserviceCaller.java:302) at com.mendix.integration.webservices.call.WebserviceCaller$2.execute(WebserviceCaller.java:298) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:37) at com.mendix.util.classloading.Runner$1.run(Runner.java:24) at java.security.AccessController.doPrivileged(Native Method) at com.mendix.util.classloading.Runner.runUsingClassLoaderOf(Runner.java:19) at com.mendix.integration.webservices.call.WebserviceCaller.call(WebserviceCaller.java:297) at com.mendix.integration.webservices.call.WebserviceCaller.call(WebserviceCaller.java:141) at com.mendix.integration.webservices.WebserviceModule.callWebservice(WebserviceModule.java:202) at com.mendix.integration.internal.IntegrationImpl.callWebservice(IntegrationImpl.scala:173) at com.mendix.integration.actions.microflow.CallWebServiceAction.execute(CallWebServiceAction.scala:74) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:49) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:193) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:53) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:291) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:276) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:204) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:37) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:199) at com.mendix.core.component.InternalCore.execute(InternalCore.java:263) at com.mendix.webui.actions.client.ExecuteAction.execute(ExecuteAction.java:135) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:300) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:293) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:293) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:151) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:37) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:153) at scala.util.Try$.apply(Try.scala:191) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:147) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:140) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) 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.ClassCastException: com.sun.xml.ws.message.stream.StreamHeader11 cannot be cast to com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader at com.sun.xml.ws.security.opt.impl.JAXBFilterProcessingContext.setJAXWSMessage(JAXBFilterProcessingContext.java:166) at com.sun.xml.wss.jaxws.impl.SecurityTubeBase.secureOutboundMessage(SecurityTubeBase.java:381) at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processClientRequestPacket(SecurityClientTube.java:323) at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processRequest(SecurityClientTube.java:247) at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:641) at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600) at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585) at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482) at com.sun.xml.ws.client.Stub.process(Stub.java:323) at com.sun.xml.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:192) at com.sun.xml.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:218) at com.mendix.integration.webservices.call.WebserviceCaller$3.run(WebserviceCaller.java:383) at com.mendix.integration.webservices.call.WebserviceCaller$3.run(WebserviceCaller.java:317) at java.security.AccessController.doPrivileged(Native Method) at com.mendix.integration.webservices.call.WebserviceCaller$2.execute(WebserviceCaller.java:302) at com.mendix.integration.webservices.call.WebserviceCaller$2.execute(WebserviceCaller.java:298) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:37) at com.mendix.util.classloading.Runner$1.run(Runner.java:24) at java.security.AccessController.doPrivileged(Native Method) at com.mendix.util.classloading.Runner.runUsingClassLoaderOf(Runner.java:19) at com.mendix.integration.webservices.call.WebserviceCaller.call(WebserviceCaller.java:297) at com.mendix.integration.webservices.call.WebserviceCaller.call(WebserviceCaller.java:141) at com.mendix.integration.webservices.WebserviceModule.callWebservice(WebserviceModule.java:202) at com.mendix.integration.internal.IntegrationImpl.callWebservice(IntegrationImpl.scala:173) at com.mendix.integration.actions.microflow.CallWebServiceAction.execute(CallWebServiceAction.scala:74) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:49) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:193) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:53) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:291) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:276) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:204) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:37) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:199) at com.mendix.core.component.InternalCore.execute(InternalCore.java:263) at com.mendix.webui.actions.client.ExecuteAction.execute(ExecuteAction.java:135) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:300) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:293) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:293) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:151) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:37) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:153) at scala.util.Try$.apply(Try.scala:191) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:147) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:140) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) 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)
asked
2 answers
0

Is it possible that you have one of these jars: jaxb-core.jar, jaxb-impl.jar or jaxws-rt.jar/wsit-rt.jar inside your userlib directory? If this is the case, try to delete them and retry. My hunch is that you have a redundant (Metro) library on your classpath.

If this doesn't help and no other forum members have a solution, I suggest you file a ticket.

answered
0

I looked into the WSDL recently and I have a workaround for this issue in case someone else encounter this WS-Security error.

Background: When the WS Security policy exist, Metro library expect a SecurityHeader object containing the security information. In Mendix, WS Security is provided in custom template and send as is. Therefore, Metro library throws exception.

The workaround: Since we don't handle the policy. I suggest to remove the policy. The WS-Security will still work.

answered