Salesforce WSDL 导入 simpleContent 和扩展
我正在尝试将 WSDL 导入 Salesforce,其中一个 XML 元素同时包含元素和字符串值,例如,
<foo bar="bob">baz</foo>
当我使用 WSDL to Apex 工具导入它时,生成的类中不提供字符串值 - 只是属性。
下面是 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[]{};
}
有没有办法可以手动修改此类以提供没有内部元素的值?
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>
When I import this using the WSDL to Apex tool, the string value is not available in the generated class--just the attribute.
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>
The generated class is:
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[]{};
}
Is there a way I can manually modify this class to provide a value without an inner element?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您所注意到的,WSDL2Apex 不正确支持 xs:extension(它不在 http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf)。
将生成的类更改为如下所示:
您可能还必须更改为 SOAP 操作生成的方法以允许此额外参数 - 这取决于 WSDL 的外观。
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.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf).
Change your generated class to look something like:
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.
基础
WebServiceCallout.invoke
不支持也具有属性的简单类型的扩展。您可以选择其中之一,但不能同时拥有两者。我制作了免费的 FuseIT SFDC Explorer 工具,其中包括 Wsdl2Apex 的替代版本。这包括在 Apex 中生成原始 HttpRequest 和相应 SOAP XML 消息的选项。这样您就可以调用所需的 Web 方法。
The underlying
WebServiceCallout.invoke
doesn't support extensions of simple types that also have attributes. You can have one or the other, but not both.I've made the free FuseIT SFDC Explorer tool, which includes an alternative version of Wsdl2Apex. This includes an option to generate the raw HttpRequest and corresponding SOAP XML message in Apex. With this you can call the required web method.