问题描述
限时送ChatGPT账号..我正在尝试将 WSDL 导入 Salesforce,其中一个 XML 元素同时包含一个元素和一个字符串值,例如
I am attempting to import a WSDL into Salesforce where one of the XML elements contains both an element and a string value e.g.
<foo bar="bob">baz</foo>
当我使用 WSDL to Apex 工具将其导入时,字符串值在生成的类中不可用——只是属性.
When I import this using the WSDL to Apex tool, the string value is not available in the generated class--just the attribute.
这是 WSDL 片段:
Here is the WSDL snippet:
<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/1_0','false','false'};
private String[] field_order_type_info = new String[]{};
}
有没有办法可以手动修改这个类来提供一个没有内部元素的值?
Is there a way I can manually modify this class to provide a value without an inner element?
推荐答案
正如您所注意到的,WSDL2Apex 不正确支持 xs:extension(它不在 http://www.salesforce/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf).
As you've noticed, WSDL2Apex doesn't support xs:extension correctly (it's not in the list of supported WSDL features on page 201 of http://www.salesforce/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf).
将生成的类更改为如下所示:
Change your generated class to look something like:
public class password {
public String input;
public String Type_x;
private String[] input_type_info = new String[]{'input','http://www.w3/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/1_0','false','false'};
private String[] field_order_type_info = new String[]{};
}
您可能还需要更改为 SOAP 操作生成的方法以允许使用此额外参数 - 这取决于您的 WSDL 是什么样的.
You may also have to change the method generated for your SOAP operation to allow for this extra parameter - it depends on what your WSDL looks like.
这篇关于Salesforce WSDL 导入 simpleContent w/extension的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论