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[]{'http://xxx.com/','true','false'};        

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

}

 

The problem is when the Apex code is generated, there is no way for me to set the param "element" content.  I can set the attribute "name" no problem.  I.e., in the XML example above, how do I set the "11" or "abc123"?  Any suggestiongs greatly appreciated.  

JackOdellJackOdell

I just ran into a similar issue processing a WSDL file with WSDL2Apex.

 

Apparently, the object model does not allow you to define a value for an element that also has an attribute.  I first ran into this issue while reading a thread where someone was trying to document the behavior of the WebServiceCallout.invoke method.  But someone else posted the question more directly as well.  

 

I haven't found an answer as of yet (although I'm not quite done looking).