我正在使用Java来实现.NET Web服务的客户端。我对正确的做法有一些疑问,也是我需要解决的问题。
这是POM中的插件:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>http://ServerNameA/FooService.svc?wsdl</wsdl>
<serviceName>FooService</serviceName>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
以下是我当前如何实例化服务对象:
FooService fooService = new FooService(new URL("http://ServerNameA/FooService.svc?wsdl"));
IFooService service = fooService.getWSHttpBindingIFooService();
service.getData(); // Calling one of the ports/service methods