如何使用cxf-codegen-plugin和Apache Camel

时间:2018-06-27 09:05:55

标签: java jaxb apache-camel cxf cxf-codegen-plugin

我想创建一条通往Soap Endpoint的骆驼路线。我使用Eclipse。 第一步是将此代码插入pom.xml:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>http://localhost:8088/mockHello_Binding?wsdl</wsdl>
                        <wsdlLocation>classpath:wsdl/hello.wsdl</wsdlLocation>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

然后我创建一条新路线:

SoapJaxbDataFormat soap = new SoapJaxbDataFormat("com.examples.wsdl.helloservice.HelloPortType", new ServiceInterfaceStrategy(HelloPortType.class, false));
soap.setVersion("1.2");

from("direct:start")
  .onException(Exception.class)
    .handled(true)
    .unmarshal(soap)
  .end()
  .marshal(soap)
  .to("file:C:\\ATemp\\")
  .unmarshal(soap);

我也对此进行了测试:

from("file:C:\\ATemp")
    .setHeader("Content-Type", simple("text/xml;charset=UTF-8"))
    .setHeader("SOAPAction", simple("http://example.com//sayHello"))
    .to("cxf://http://localhost:8088/mockHello_Binding"
            +"?wsdlURL=http://localhost:8088/mockHello_Binding?wsdl"
            +"&serviceName={http://example.com/}Hello_Service"
            +"&portName={http://example.com/}Hello_Port"
            +"&defaultOperationName=sayHello"
            +"&dataFormat=POJO"
            +"&serviceClass=com.examples.wsdl.helloservice.HelloPortType"
        );

但是在两种情况下都无济于事:

Class Not Found

我必须做什么才能使其运行?

0 个答案:

没有答案