java - 使用 wsimport 解析 Salesforce 合作伙伴 WSDL 时出错

标签 java web-services jaxb salesforce wsimport

我想使用 Java 连接到 Salesforce。但是,当我尝试使用 wsimport 解析partner.wsdl 时,出现以下错误:

parsing WSDL...
[WARNING] src-resolve: Cannot resolve the name 'tns:ID' to a(n) 'type definition' component.
  line 29 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl#types?schema1
[ERROR] A class/interface with the same name "com.sforce.soap.partner.DescribeGlobalTheme" is already in use. Use a class customization to resolve this conflict.
  line 1830 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] (Relevant to above error) another "DescribeGlobalTheme" is generated from here.
  line 759 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] A class/interface with the same name "com.sforce.soap.partner.DescribeApprovalLayout" is already in use. Use a class customization to resolve this conflict.
  line 2005 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] (Relevant to above error) another "DescribeApprovalLayout" is generated from here.
  line 1094 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] A class/interface with the same name "com.sforce.soap.partner.DescribeLayout" is already in use. Use a class customization to resolve this conflict.
  line 1954 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] (Relevant to above error) another "DescribeLayout" is generated from here.
  line 1112 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 1830 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] (Related to above error) This is the other declaration.
  line 759 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 2005 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] (Related to above error) This is the other declaration.
  line 1094 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 1954 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl
[ERROR] (Related to above error) This is the other declaration.
  line 1112 of file:/C:/Users/Rajasekhar/Desktop/partner.wsdl

此 WSDL 是由 Salesforce 本身生成的。我应该如何生成使用它所需的类?

最佳答案

这些问题是由 WSDL 使用仅大小写不同的重复名称引起的:

<complexType name="DescribeGlobalTheme">
<element name="describeGlobalTheme">

通过使用适当的 JAXB 扩展运行最容易解决这个问题:

wsimport -extension -B-XautoNameResolution ...

这将正确生成两个单独的类:

@XmlType(name = "DescribeGlobalTheme", propOrder = { "global", "theme" })
public class DescribeGlobalTheme {
@XmlRootElement(name = "describeGlobalTheme")
public class DescribeGlobalTheme2 {

或者,使用 Force.com Web Services Connector相反。

关于java - 使用 wsimport 解析 Salesforce 合作伙伴 WSDL 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28426614/

相关文章:

java - 需要一些帮助从并行数组/输出语句检索数据

java - 使用递归将二进制转换为 Int

rest - WCF、Web API、WCF REST 和 Web 服务之间的区别?

java - 用于 IIS 集成 Windows 身份验证 (NTLM) 的 JAX-WS 客户端

java - 如何使用 Jersey 1 进行 ChunkOutput?

java - 多个JTA事务: no session associated with the current transaction

java - 如何解决错误: cannot find symbol class Set

java - wsgen 引发 NoClassDefFoundError 异常

java - XJC 不生成带有命名空间的@XmlElement 吗?

java - 解码为soap webservice 中的通用类型 xml 中的任何类型