function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kdolankdolan 

wsdl2apex - How do I set element data?

I have a very simple XSD that I'm trying to include in my WSDL to alllow the Apex code to be generated.  The XML here is this:

<GetJurisdictions>
    <params>
      <param name="contactNo">11</param>
      <param name="loginGuid">abc123</param>
   </params>
</GetJurisdictions>

 

We could write the inline XSD a number of ways.  Here is one way:

<s:schema xmlns:s="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified">
<s:element name="GetJurisdictions">
<s:complexType>
<s:sequence>
<s:element ref="params"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="param">
<s:complexType id="val1" mixed="true">
<s:simpleContent>
<s:extension base="s:string">
<s:attribute name="name" type="s:string"/>
</s:extension>
</s:simpleContent>
</s:complexType>
</s:element>
<s:element name="params">
<s:complexType>
<s:sequence>
<s:element ref="param" maxOccurs="unbounded"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>

 

Here is the Apex code generated for the "param" element:


public class param_element {        

public String name;        

private String[] name_att_info = new String[]{'name'};        

private String[] apex_schema_type_info = new String[]{<URL Here>};        

private String[] field_order_type_info = new String[]{};    

}

 

The Apex class allows me to set the public variable "name", so setting the attribute value is no problem.  The problem is when the Apex code is generated, there is no way for me to set the "element" content.  If you look at the XML above, I have both element content (e.g., "abc123") and attribute content.  Since there are no public variables for the element data, I don't know how I would set the element data.  Any suggestions here?