Java CXF客户端代理getClient“;“不是代理实例”;
我正在尝试将WS-security与我的Apache CXF客户端一起使用。我需要掌握客户端端点,以便添加WSS4J拦截器。但是,当我调用Java CXF客户端代理getClient“;“不是代理实例”;,java,cxf,wsdl2java,Java,Cxf,Wsdl2java,我正在尝试将WS-security与我的Apache CXF客户端一起使用。我需要掌握客户端端点,以便添加WSS4J拦截器。但是,当我调用ClientProxy.getClient()时,我会得到一个带有以下消息的IllegalArgumentException: 不是代理实例 代码: 跟踪: java.lang.IllegalArgumentException: not a proxy instance at java.lang.reflect.Proxy.getInvocationH
ClientProxy.getClient()
时,我会得到一个带有以下消息的IllegalArgumentException
:
不是代理实例
代码:
跟踪:
java.lang.IllegalArgumentException: not a proxy instance
at java.lang.reflect.Proxy.getInvocationHandler(Unknown Source)
at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:93)
结果证明我使用了错误的代码生成工具。我使用的是org.codehaus.mojo AxistTools maven插件,它为您提供了一个扩展java.rmi.Remote的服务。但是,我需要使用org.apache.cxf cxf codegen插件,它为您提供了一个实现代理的服务 新代码:
MailingService_Service mss = new MailingService_Service();
MailingService service = mss.getMailingServicePort();
ClientImpl client = (ClientImpl) ClientProxy.getClient(service);
新pom:
<plugins>
<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>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/myWsdl.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
org.apache.cxf
cxf-codegen插件
2.6.0
生成源
生成源
${project.build.directory}/generated/cxf
${basedir}/src/main/wsdl/myWsdl.wsdl
wsdl2java
<plugins>
<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>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/myWsdl.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>