我想使用 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/