我想在Fuse ESB的路线中拨打外部网络服务。根据事物的外观,你应该使用cxf来做到这一点。我有代码添加到我的POM文件,如下所示。 Maven不喜欢这个。它抱怨“生命周期配置未涵盖插件执行:org.apache.cxf:cxf-codegen-plugin:2.6.0:wsdl2java(执行:生成源,阶段:生成源)”。无论我使用什么版本都没关系 - 我已经尝试了所有版本。 Alos,当Maven构建我得到的错误时,“'UTF-8'每个字符使用1个字节;但物理编码似乎使用2”。有什么不对,但是什么? 此代码来自Fusesource作为示例。有人有这个工作吗?我的WSDL看起来很好。我想做的就是打电话给网络服务,这肯定不是那么难啊!
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.6.0</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<!-- Maven auto-compiles any source files under target/generated-sources/ -->
<sourceRoot>${basedir}/target/generated-sources/jaxws</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>C:/bolt-poc/src/main/resources/WSDL/esbWebService.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
答案 0 :(得分:0)
尝试使用此Maven插件从WSDL生成类:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.6.0</version>
<executions>
<execution>
<id>generate-jaxb</id>
<phase>generate-sources</phase>
<configuration>
<additionalJvmArgs>-Dfile.encoding=UTF8</additionalJvmArgs>
<wsdlOptions>
<wsdlOption>
<wsdl>src/main/resources/WSDL/esbWebService.wsdl</wsdl>
<extraargs>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
<extraarg>-p</extraarg>
<extraarg>your.pkg</extraarg>
<extraarg>-wsdlLocation</extraarg>
<extraarg></extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
然后使用Spring创建一个客户端。像这样:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:client id="yourService"
address="http://your/web/service/url"
serviceClass="your.generated.service.class.YourClass"
username="inCaseYouNeedUsername"
password="inCaseYouNeedPassword"/>
</beans>
然后创建一个类并注入您的服务客户端:
@Component
public class YourBean {
@Autowired
@Qualifier(value = "yourService")
private YourService service;
public void someMethod() {
service.doSmth();
}
}