Salesforce WSDL导入带有扩展名的simpleContent [英] Salesforce WSDL import of simpleContent w/extension

查看:83
本文介绍了Salesforce WSDL导入带有扩展名的simpleContent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将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到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代码段:

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

有没有一种方法可以手动修改此类以提供没有内部元素的值?

Is there a way I can manually modify this class to provide a value without an inner element?

推荐答案

您已经注意到,WSDL2Apex不正确地支持xs:extension(它不在 http://www.salesforce.com/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.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[]{};
}

您可能还必须更改为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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆