У меня очень простая служба Soap с параметром String и возвращает строку.
С Maven я сгенерировал соответствующие классы из WSDL. Я импортировал wsdl в SOAP -UI и сделал издевательство. Я запустил макет и сделал тестовый пример, который правильно отправляет и получает ответ.
Я создал тест junit с верблюжьим маршрутом, и вот тут возникают проблемы. Я не могу создать URL-адрес, который позволил бы мне вызывать мой макет. Сначала я просто безуспешно помещал "cxf://http://localhost:8088/mockws_traca?DefaultOperationName=MajTracaDMI&wsdlURL=ws_traca.wsdl"
. Я добавил класс сервиса "&serviceClass="+WsTraca.class.getName()
, который вызывает неверную ошибку сервиса {http://localhost/ws_traca/wsdl/}WsTraca
, после отладки шаг за шагом я нашел имя сгенерированного сервиса, который я добавил "&serviceName={http://localhost/ws_traca/wsdl/}ws_traca"
, он допустил ту же ошибку с типом порта, который я не нашел параметр для указания типа порта, поэтому я добавил его имя "&portName={http://localhost/ws_traca/wsdl/}ws_tracaSoapPort"
Мой routeBuilder
protected final RouteBuilder createRouteBuilder() throws Exception{
return new RouteBuilder() {
@Override
public void configure() throws Exception{
from("direct:start")
.setHeader(CxfConstants.OPERATION_NAME, constant("MajTracaDMI"))
.to("cxf://http://localhost:8088/mockws_traca"
+ "?serviceClass="+WsTraca.class.getName()
+ "&portName={http://localhost/ws_traca/wsdl/}ws_tracaSoapPort"
+ "&serviceName={http://localhost/ws_traca/wsdl/}ws_traca"
+ "&wsdlURL=ws_traca.wsdl"
);
}
};
}
wsdl:
<?xml version='1.0' encoding='UTF-8' ?>
<!-- Generated 05/15/19 by Microsoft SOAP Toolkit WSDL File Generator, Version 3.00.1325.0 -->
<definitions
name='ws_traca'
targetNamespace='http://localhost/ws_traca/wsdl/'
xmlns:wsdlns='http://localhost/ws_traca/wsdl/'
xmlns:typens='http://localhost/ws_traca/type/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
xmlns:dime='http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'
xmlns:ref='http://schemas.xmlsoap.org/ws/2002/04/reference/'
xmlns:content='http://schemas.xmlsoap.org/ws/2002/04/content-type/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<types>
<schema
targetNamespace='http://localhost/ws_traca/type/'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
elementFormDefault='qualified'>
<import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
<import namespace='http://schemas.xmlsoap.org/wsdl/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/reference/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/content-type/'/>
</schema>
</types>
<message name='ws_traca.MajTracaDMI'>
<part name='c_xml' type='xsd:string'/>
</message>
<message name='ws_traca.MajTracaDMIResponse'>
<part name='Result' type='xsd:string'/>
</message>
<message name='ws_traca.GetTracaDMI'>
<part name='c_xml' type='xsd:string'/>
</message>
<message name='ws_traca.GetTracaDMIResponse'>
<part name='Result' type='xsd:string'/>
</message>
<message name='ws_traca.Ping'>
<part name='c_chaine' type='xsd:string'/>
</message>
<message name='ws_traca.PingResponse'>
<part name='Result' type='xsd:string'/>
</message>
<message name='ws_traca.InfoDll'>
<part name='cXml' type='xsd:string'/>
</message>
<message name='ws_traca.InfoDllResponse'>
<part name='Result' type='xsd:string'/>
</message>
<portType name='ws_tracaSoapPort'>
<operation name='MajTracaDMI' parameterOrder='c_xml'>
<input message='wsdlns:ws_traca.MajTracaDMI'/>
<output message='wsdlns:ws_traca.MajTracaDMIResponse'/>
</operation>
<operation name='GetTracaDMI' parameterOrder='c_xml'>
<input message='wsdlns:ws_traca.GetTracaDMI'/>
<output message='wsdlns:ws_traca.GetTracaDMIResponse'/>
</operation>
<operation name='Ping' parameterOrder='c_chaine'>
<input message='wsdlns:ws_traca.Ping'/>
<output message='wsdlns:ws_traca.PingResponse'/>
</operation>
<operation name='InfoDll' parameterOrder='cXml'>
<input message='wsdlns:ws_traca.InfoDll'/>
<output message='wsdlns:ws_traca.InfoDllResponse'/>
</operation>
</portType>
<binding name='ws_tracaSoapBinding' type='wsdlns:ws_tracaSoapPort' >
<stk:binding preferredEncoding='UTF-8'/>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='MajTracaDMI'>
<soap:operation soapAction='http://localhost/ws_traca/action/ws_traca.MajTracaDMI'/>
<input>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='c_xml'/>
</input>
<output>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='Result'/>
</output>
</operation>
<operation name='GetTracaDMI'>
<soap:operation soapAction='http://localhost/ws_traca/action/ws_traca.GetTracaDMI'/>
<input>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='c_xml'/>
</input>
<output>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='Result'/>
</output>
</operation>
<operation name='Ping'>
<soap:operation soapAction='http://localhost/ws_traca/action/ws_traca.Ping'/>
<input>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='c_chaine'/>
</input>
<output>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='Result'/>
</output>
</operation>
<operation name='InfoDll'>
<soap:operation soapAction='http://localhost/ws_traca/action/ws_traca.InfoDll'/>
<input>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='cXml'/>
</input>
<output>
<soap:body
namespace='http://localhost/ws_traca/message/'
parts='Result'/>
</output>
</operation>
</binding>
<service name='ws_traca' >
<port name='ws_tracaSoapPort' binding='wsdlns:ws_tracaSoapBinding' >
<soap:address location='http://localhost/ws_trunk/ws_traca.WSDL'/>
</port>
</service>
</definitions>
У меня сейчас есть ошибка на WsTraca, что не интерфейс
org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[cxf://http://SAP5223897:8088/mockws_traca?portName=%7Bhttp%3A%2F%2Flocalhost%2Fws_traca%2Fwsdl%2F%7Dws_tracaSoapPort&serviceClass=localhost.ws_traca.wsdl.WsTraca&serviceName=%7Bhttp%3A%2F%2Flocalhost%2Fws_traca%2Fwsdl%2F%7Dws_traca&wsdlURL=ws_traca.wsdl]. Reason: java.lang.IllegalArgumentException: localhost.ws_traca.wsdl.WsTraca is not an interface
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:380)
at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:107)
at org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:138)
at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:163)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
at org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:444)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:982)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DefaultChannel.doStart(DefaultChannel.java:149)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:82)
at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:920)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:56)
at org.apache.camel.impl.RouteService.startChildService(RouteService.java:245)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:142)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:1843)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1771)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1556)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1448)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1338)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1316)
at org.apache.camel.test.junit4.CamelTestSupport.startCamelContext(CamelTestSupport.java:344)
at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:228)
at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47)
at org.junit.rules.RunRules.evaluate(RunRules.java:18)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.IllegalArgumentException: localhost.ws_traca.wsdl.WsTraca is not an interface
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:470)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:690)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:171)
at org.apache.camel.component.cxf.CxfEndpoint.createClient(CxfEndpoint.java:455)
at org.apache.camel.component.cxf.CxfProducer.<init>(CxfProducer.java:71)
at org.apache.camel.component.cxf.CxfEndpoint.createProducer(CxfEndpoint.java:153)
at org.apache.camel.impl.InterceptSendToEndpoint.createProducer(InterceptSendToEndpoint.java:93)
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:376)
... 83 more