调用soapkit流时MUnit 2测试中的Mule 4出错,说流不存在,即使它存在

Posted

技术标签:

【中文标题】调用soapkit流时MUnit 2测试中的Mule 4出错,说流不存在,即使它存在【英文标题】:Error in Mule 4 inside MUnit 2 test when calling soapkit flow saying the flow does not exist even if it is there 【发布时间】:2020-09-13 22:14:13 【问题描述】:

我有一个名为“api-main”的 API 主流,它是一个 SOAP-Kit 流,它有一个 SOAP 路由器,可以将消息分发到子流,监听器是用我的 WSDL 设置的,我可以完美地调用它使用 HTTP 客户端,例如 SOAP-UI。 但是,当我使用 MUnit 测试调用它时,它使用 SOAP-UI 上使用的相同有效负载:

    WARNING: Interceptor for http://xyz/QueryEngineService/QueryEngineV200606DotNetQueryEngineV200606DotNet#http://xyz/QueryEngineService/QueryEngineV200606DotNetGetTemplateResultAsXML has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Despite the given WSDL file configurated in configuration 'soapkit-config' does contains the name 'GetTemplateResultAsXML', there is no current flow that maps to it (the expected flow should be called 'GetTemplateResultAsXML:\soapkit-config')
    at org.mule.soapkit.soap.server.SoapCxfInvoker.invoke(SoapCxfInvoker.java:84)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInvokerInterceptor.java:126)
    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.mule.soapkit.soap.server.SoapCxfServer.sendThroughCxf(SoapCxfServer.java:200)
    at org.mule.soapkit.soap.server.SoapCxfServer.serve(SoapCxfServer.java:104)
    at org.mule.module.soapkit.internal.SoapkitRouterExecutor.execute(SoapkitRouterExecutor.java:73)
    at org.mule.runtime.module.extension.internal.runtime.execution.InterceptableOperationExecutorWrapper.execute(InterceptableOperationExecutorWrapper.java:60)
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$null$3(DefaultExecutionMediator.java:149)
    at org.mule.runtime.core.api.util.ExceptionUtils.tryExpecting(ExceptionUtils.java:227)
    at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:915)
    at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:879)
    at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$executeWithInterceptors$9(DefaultExecutionMediator.java:149)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
    at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:55)
    at reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3858)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:420)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmit(FluxFlatMap.java:532)
    at reactor.core.publisher.FluxFlatMap$FlatMapInner.onNext(FluxFlatMap.java:974)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2071)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162)
    at reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:964)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)
    at reactor.core.publisher.MonoCurrentContext.subscribe(MonoCurrentContext.java:35)
    at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3858)
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:420)
    at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$1.onNext(AbstractMessageProcessorChain.java:292)
    at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$1.onNext(AbstractMessageProcessorChain.java:285)
    at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204)
    at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:345)
    at reactor.core.publisher.FluxSubscribeOnValue$ScheduledScalar.run(FluxSubscribeOnValue.java:178)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111)
    at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.mule.module.soapkit.internal.exception.SoapkitRouterException: Despite the given WSDL file configurated in configuration 'soapkit-config' does contains the name 'GetTemplateResultAsXML', there is no current flow that maps to it (the expected flow should be called 'GetTemplateResultAsXML:\soapkit-config')
    at org.mule.module.soapkit.internal.DefaultSoapServerHandler.lambda$findFlow$0(DefaultSoapServerHandler.java:111)
    at java.util.Optional.orElseThrow(Optional.java:290)
    at org.mule.module.soapkit.internal.DefaultSoapServerHandler.findFlow(DefaultSoapServerHandler.java:111)
    at org.mule.module.soapkit.internal.DefaultSoapServerHandler.handle(DefaultSoapServerHandler.java:71)
    at org.mule.soapkit.soap.server.SoapCxfInvoker.invoke(SoapCxfInvoker.java:69)
    ... 50 more

也就是说,实际存在的子流程并不存在。有人知道为什么吗?

【问题讨论】:

【参考方案1】:

我刚刚发现为什么它没有找到子流,在 Anypoint Studio 中,我需要将它包含在我的测试套件的“启用流源”属性中。我选择了测试套件(双击它),在属性中,我将流程插入到列表中,如下图所示:

如您所见,我在单元测试场景中添加了名为“GetTemplateResultAsXML:\soapkit-config”的子流程,并且成功了。

【讨论】:

以上是关于调用soapkit流时MUnit 2测试中的Mule 4出错,说流不存在,即使它存在的主要内容,如果未能解决你的问题,请参考以下文章

如何禁用 Angular 服务工作者的预检缓存控制标头(调用事件流时)?

Web前端面试题:写一个mul函数

用户定义的 __mul__ 方法不可交换

哪位大侠知道fluent中用欧拉模型模拟固液两相流时,interaction中的drag coefficient怎么设置?

安装张量流时出错

PDF读取内容流时出错