使用apache Camel和WSDL公开SOAP服务

时间:2017-08-17 11:38:01

标签: soap wsdl apache-camel cxf weblogic12c

我有一个位于src \ main \ resources \ wsdl \文件夹下的WSDL文件,它在其中定义了多个操作。我的应用程序在Weblogic 12C服务器上运行。我正在尝试使用Apache Cammel(版本:2.18.3)和Java DSL公开SOAP Web服务 -

我在RouteBuilder类的配置方法下编写了下面的代码 -

CxfComponent cxfComponent = new CxfComponent(getContext());
        CxfEndpoint serviceEndpoint = new CxfEndpoint("/soap/Manage_Order", cxfComponent);
        serviceEndpoint.setAddress("http://<IP>:<PORT>/myproject/soap/ManageOrder_Details");
        serviceEndpoint.setServiceClass(
                "Fully qualified service interface name generated from WSDL file using maven with @WebService annotation");
        serviceEndpoint.setEndpointName(<end point name defined in the service class with @WebEndpoint annotation>);
        serviceEndpoint.setDataFormat(DataFormat.MESSAGE);
        serviceEndpoint.setDefaultOperationName("manageOrder");
        getContext().addEndpoint("myServiceEndPoint1", serviceEndpoint);

from("cxf:myServiceEndPoint1").log("Hi, I am here").end();

在我部署应用程序时,它会抛出异常 -

weblogic.application.ModuleException: java.lang.IllegalArgumentException: serviceClass must be specified
        at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
        Truncated. see log file for complete stacktrace
    Caused By: java.lang.IllegalArgumentException: serviceClass must be specified
        at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:311)
        at org.apache.camel.component.cxf.CxfEndpoint.createServerFactoryBean(CxfEndpoint.java:663)
        at org.apache.camel.component.cxf.CxfConsumer.createServer(CxfConsumer.java:70)
        at org.apache.camel.component.cxf.CxfConsumer.<init>(CxfConsumer.java:66)
        at org.apache.camel.component.cxf.CxfEndpoint.createConsumer(CxfEndpoint.java:252)
        Truncated. see log file for complete stacktrace

的pom.xml

<dependency>
   <groupId>org.apache.camel</groupId>
   <artifactId>camel-soap</artifactId>
   <version>2.18.3</version>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-cxf</artifactId>
    <version>2.18.3</version>
    <!-- use the same version as your Camel core version -->
</dependency>

1 个答案:

答案 0 :(得分:0)

如错误所示,您尚未提及服务类和端点名称。
serviceEndpoint.setServiceClass("Fully qualified service interface name generated from WSDL file using maven with @WebService annotation"); serviceEndpoint.setEndpointName(<end point name defined in the service class with @WebEndpoint annotation>); 步骤1:使用wsdl2java命令或您选择的IDE从wsdl生成服务。 第2步:在代码类路径中使用它 第3步:在上面的代码中提及类名和端点名称