2010-12-10 43 views
3

我試圖將WSDL導入Salesforce,其中一個XML元素同時包含元素和字符串值,例如Salesforce WSDL import with simpleContent w/extension

<foo bar="bob">baz</foo> 

當我導入此使用WSDL到頂點工具,該字符串值不是在生成的類可用 - 只是屬性。

這裏是WSDL片段:

<xs:complexType name="password"> 
    <xs:simpleContent> 
    <xs:extension base="xs:string"> 
     <xs:attribute name="Type" type="xs:string"/> 
    </xs:extension> 
    </xs:simpleContent> 
</xs:complexType> 

生成的類是:

public class password { 
    public String Type_x; 
    private String[] Type_x_att_info = new String[]{'Type'}; 
    private String[] apex_schema_type_info = new String[]{'http://schema.test.org/1_0','false','false'}; 
    private String[] field_order_type_info = new String[]{}; 
} 

有一種方法我可以手動修改這個類,以提供一個值,而無需內部元件?

回答

2

正如您已經注意到的那樣,WSDL2Apex不能正確支持xs:擴展(它不在http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf的第201頁的支持的WSDL功能列表中)。

更改您的生成的類看起來是這樣的:

public class password { 
    public String input; 
    public String Type_x; 
    private String[] input_type_info = new String[]{'input','http://www.w3.org/2001/XMLSchema','string','1','1','false'}; // change 'input' to be the desired name of your element 
    private String[] Type_x_att_info = new String[]{'Type'}; 
    private String[] apex_schema_type_info = new String[]{'http://schema.test.org/1_0','false','false'}; 
    private String[] field_order_type_info = new String[]{}; 
} 

你也可能需要更改您的SOAP操作產生的,允許這些額外的參數的方法 - 這取決於你的WSDL的樣子。

0

底層WebServiceCallout.invoke不支持也具有屬性的簡單類型的擴展。你可以擁有一個或另一個,但不能同時擁有兩個。

我做了免費FuseIT SFDC Explorer工具,其中包括Wsdl2Apex的替代版本。這包括在Apex中生成原始HttpRequest和相應SOAP XML消息的選項。有了這個,你可以調用所需的網絡方法。

相關問題