Reputation: 151
I would like to call an external web service within a route in Fuse ESB. By the looks of things you should use cxf to do this. I have code to add to my POM file, as follows. Maven does not like this. It complains that "Plugin execution not covered by lifecycle configuration: org.apache.cxf:cxf-codegen-plugin:2.6.0:wsdl2java (execution: generate-sources, phase: generate-sources)". And it does not matter what version I use - I have tried them all. Alos, when Maven builds the error I get is "'UTF-8' uses 1 bytes per character; but physical encoding appeared to use 2". Something is wrong, but what? This code is from Fusesource as an example. Has anyone got this working? My WSDL looks fine. All I want to do is call a webservice, it cannot be this hard, surely!!!
<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>
Upvotes: 0
Views: 1398
Reputation: 23413
Try this Maven plugin to generate classes from 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>
Then use Spring to create a client. Something like this:
<?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>
Then create a class and inject your service client:
@Component
public class YourBean {
@Autowired
@Qualifier(value = "yourService")
private YourService service;
public void someMethod() {
service.doSmth();
}
}
Upvotes: 0