简体   繁体   English

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

[英]Errors while parsing Salesforce Partner WSDL using wsimport

I want to connect to Salesforce using Java. 我想使用Java连接到Salesforce。 However, when I try to parse partner.wsdl using wsimport I get the following errors: 但是,当我尝试使用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

This WSDL was generated from Salesforce itself. 该WSDL是由Salesforce本身生成的。 How am I supposed to generate the classes needed to use it? 我应该如何生成使用它所需的类?

The problems are caused by the WSDL using duplicate names that differ only in casing: 这些问题是由WSDL使用重复的名称引起的,这些重复的名称仅在大小写上有所不同:

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

This is most easily solved by running with an appropriate JAXB extension: 通过使用适当的JAXB扩展名运行,最容易解决此问题:

wsimport -extension -B-XautoNameResolution ...

This will then correctly generate two separate classes: 然后,这将正确生成两个单独的类:

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

Alternatively, use the Force.com Web Services Connector instead. 或者,改用Force.com Web服务连接器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM