我是网络服务的新手,我有一个场景。
CXF客户端存根无法在其父wsdl中找到导入的wsdl。我的意思是我有A.wsdl,它有wsdl:import
的B.wsdl。我使用maven cxf插件为A.wsdl生成了客户端存根。
当我创建传递A.wsdl的服务对象时,我得到B.wsdl的文件未找到异常。
如何使这项工作?
[Maven conf]
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<defaultOptions>
<frontEnd>jaxws21</frontEnd>
<validateWsdl>true</validateWsdl>
<faultSerialVersionUID>1</faultSerialVersionUID>
<allowElementRefs>true</allowElementRefs>
<bindingFiles>
<bindingFile>src/main/resources/binding/ESB-BSSAPI/Common_JAXB_binding.xjb</bindingFile>
<bindingFile>src/main/resources/binding/ESB-BSSAPI/Common_JAXWS_binding.xjb</bindingFile>
</bindingFiles>
<autoNameResolution>true</autoNameResolution>
</defaultOptions>
<sourceRoot>src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>src/main/resources/wsdl/provider/ESB-BSSAPI/Accounts.wsdl</wsdl>
<packagenames>
<packagename>com.company.platform.il.esb.accounts</packagename>
</packagenames>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-jaxb</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
<artifactId>cxf-xjc-ts</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-fluent-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.4</version>
</dependency>
</dependencies>
</plugin>
所有wsdl都位于 src / main / resources / wsdl / provider / ESB-BSSAPI / 文件夹下
在Accounts.wsdl文件中,我有wsdl:imports
<wsdl:import namespace="http://soap.crmapi.util.company.com/common/xsd/Common-v1.1" location="Common_interface_1_1.wsdl" />
<wsdl:import namespace="http://soap.crmapi.util.company.com/common/xsd/Common-v2.0" location="Common_interface_2_0.wsdl" />
<wsdl:import namespace="http://soap.crmapi.util.company.com/common/exception/xsd/2008/08" location="Common_faults_1_0.wsdl" />
<wsdl:import namespace="http://soap.crmapi.util.company.com/accounts/xsd/Accounts-v1.0" location="Accounts_interface_1_0.wsdl" />
<wsdl:import namespace="http://soap.crmapi.util.company.com/accounts/xsd/Accounts-v1.1" location="Accounts_interface_1_1.wsdl" />
<wsdl:import namespace="http://soap.crmapi.util.company.com/accounts/xsd/Accounts-v1.2" location="Accounts_interface_1_2.wsdl" />
<wsdl:import namespace="http://soap.crmapi.util.company.com/accounts/xsd/Accounts-v2.0" location="Accounts_interface_2_0.wsdl" />
在Java中,我正在创建Service对象并尝试调用getAccountProfileV2操作
ClassPathResource classPathResource = new ClassPathResource("wsdl/provider/ESB-BSSAPI/Accounts.wsdl");
File wsdlLocation = classPathResource.getFile();
com.company.platform.il.esb.accounts.AccountService managementService =
new com.company.platform.il.esb.accounts.AccountService(wsdlLocation.toURL());
AccountsPortTypeV20 service = managementService.getAccountsSOAP11PortHttp();
//.....
GetAccountProfileV2Response accountProfileQueryResult = service.getAccountProfileV2(accountProfileV2);
调用操作后,我得到FileNotFoundException for Common_interface_1_1.wsdl
它实际上是在Wildfly/bin
文件夹中搜索
提前致谢 拉吉