Salesforce WSDL 导入 simpleContent 和扩展

发布于 2024-10-07 02:03:57 字数 820 浏览 0 评论 0原文

我正在尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜光 2024-10-14 02:03:57

正如您所注意到的,WSDL2Apex 不正确支持 xs:extension(它不在 http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf)。

将生成的类更改为如下所示:

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 的外观。

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:

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[]{};
}

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.

杀お生予夺 2024-10-14 02:03:57

基础 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文