2012-05-10 11 views
2

Apache CXFクライアントでWSセキュリティを使用しようとしています。 WSS4Jインターセプタを追加できるように、クライアントエンドポイントを確保する必要があります。プロキシインスタンスCXF ClientProxy getClient "プロキシインスタンスではありません"

コードではない:私はClientProxy.getClient()を呼び出すときにしかし、私は次のメッセージをIllegalArgumentExceptionを取得

MailingService_ServiceLocator serviceLocator = new MailingService_ServiceLocator(); 
MailingService_PortType port = serviceLocator.getMailingServicePort(); 

Client client = ClientProxy.getClient(port); // throws exception 

... 

// Create client interceptor 
AuthenticationInterceptor authenticationInterceptor = 
    new AuthenticationInterceptor(schemaNS, outprops, organizationName, null); 

client.getEndpoint().getOutInterceptors().add(authenticationInterceptor); 

をトレース:

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) 

答えて

1

それ私は間違ったコード生成ツールを使用していたことが分かります。私はjava.rmi.Remoteを拡張するサービスを提供するorg.codehaus.mojo axistools-maven-pluginを使用していました。しかし、org.apache.cxf cxf-codegen-pluginを使用する必要がありました。これは、Proxyを実装するサービスを提供します。

新コード:

MailingService_Service mss = new MailingService_Service(); 
MailingService service = mss.getMailingServicePort(); 

ClientImpl client = (ClientImpl) ClientProxy.getClient(service); 

新ポンポン:

<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> 
関連する問題