1

CXFは初めてです。Web サービスを使用するクライアントを作成しています。私の要件は、クライアントを作成し、ロギング インターセプターも追加することです。WSDL残念ながら、サービス プロバイダーはを介し​​て を利用できるようにしていませんURL?wsdl。サービス プロバイダーから必要なものはすべてWSDLs and XSDszip ファイルに含まれており、このバージョンのファイルを使用してクライアントを構築する必要があります。CXFこれまでにいくつかの例をたどり、クライアントについてかなり読んできました。クライアントを実行するための次のアプローチが正しいようです。ただし、ここでは機能しません。これを解決するには助けが必要です。

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(<SERVICE_CLASS_NAME>.class); <<I have the ".class for service here>>
QName SERVICE_NAME = new QName(<<namespaceURI>>, <<ServiceName>>);
factory.setServiceName(SERVICE_NAME);
factory.setAddress(SERVICE_URL);
factory.setWsdlLocation(localWSDLAddress);
portType = factory.create();

これはスタンドアロンのクライアント プログラムであり、このプログラムを実行するためにいくつかの jar ファイルの組み合わせを試しました (詳細は後述)。プログラムは、上記のコード スニペットに記載されている最後の行を超えて実行されません。例外トレースは次のとおりです。

Exception in thread "main" java.lang.AbstractMethodError: org.apache.cxf.binding.soap.SoapTransportFactory.createEndpointInfo(Lorg/apache/cxf/service/model/ServiceInfo;Lorg/apache/cxf/service/model/BindingInfo;Ljava/util/List;)Lorg/apache/cxf/service/model/EndpointInfo;
 at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildEndpoint(WSDLServiceBuilder.java:459)
 at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:356)
 at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:203)
 at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:175)
 at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:408)

上記のコード スニペットを含むクライアント プログラムを実行するために使用されるコマンド ライン。試行錯誤の結果、この jar ファイルのリストにたどり着きました。

java -cp %CLASSPATH%;.;./cxf-core-3.0.2.jar;./cxf-rt-bindings-soap-3.0.2.jar;./cxf-rt-bindings-xml-3.0.2.jar;./cxf-rt-core-2.7.11.jar;./cxf-rt-frontend-simple-3.0.2.jar;./cxf-rt-ws-addr-3.0.2.jar;./cxf-rt-ws-policy-3.0.2.jar;./neethi-3.0.2.jar;./wsdl4j-1.6.3.jar;./xmlschema-core-2.1.0.jar;./cxf-rt-frontend-jaxws-3.0.2.jar;./cxf-bundle-3.0.0-milestone2.jar;./cxf-bundle-jaxrs-2.7.12.jar;./woodstox-core-asl-4.4.1.jar;./stax2-api-3.1.4.jar;./cxf-rt-databinding-jaxb-3.0.2.jar;./cxf-common-utilities-2.5.11.jar;./cxf-rt-transports-http-3.0.2.jar javaclass
4

1 に答える 1

0

プロジェクトの一部として WSDL を含め、クライアント/サーバーの Java コードを生成します。

コードを生成するには、cxf maven プラグインを使用します。

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/ws/booking-v1.wsdl</wsdl>
                        <wsdlLocation>classpath:ws/booking-v1.wsdl</wsdlLocation>
                        <bindingFiles>
                            <bindingFile>${basedir}/src/main/resources/bindings.xml</bindingFile>
                        </bindingFiles>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>
于 2015-04-30T11:41:36.567 に答える