1

I am using WSDL2Apex tool in FuseIT Explorer to generate Apex classes. After tweaking my wsdl file a bit in order to get it to parse with the tool, all the classes are generated properly with the SOAP option. The only thing that is not properly generated are the property type_info variables that the Apex WebServiceCallout class uses in order to create the http request and parse the response.

I tried it with the original wsdl also with the same results (plus the thousand plus other problems that are generated due to unknown types).

Here you can see that all of the type info variables for the class properties are empty.

Property:

        // This type_info property should have a string array with the name, namespace, type, minOccur, maxOccur, and nillable attributes. Instead it empty besides the values you see here.
    private String[] PartyKeys_type_info = new String[]{'','','','0','1','false'};

Class:

    // Warning: AddrKeys_Type - All the XmlSchemaElements in '<xsd:choice>' element are added as members of the class. Choice Members: PartyKeys AcctKeys
// Warning: AddrKeys_Type - All the XmlSchemaElements in '<xsd:choice>' element are added as members of the class. Choice Members: AddrId PartyKeys AcctKeys AddressIdent AddrFormatType AddrType
public class AddrKeys_Type {
    public String AddrId;
    public Com_addr_xsd.PartyKeys_Type PartyKeys;
    public Com_addr_xsd.AcctKeys_Type AcctKeys;
    public String AddressIdent;
    public String AddrFormatType;
    public String AddrType;
    private String[] PartyKeys_type_info = new String[]{'','','','0','1','false'};
    private String[] AcctKeys_type_info = new String[]{'','','','0','1','false'};
    private String[] AddressIdent_type_info = new String[]{'','','','0','1','false'};
    private String[] AddrFormatType_type_info = new String[]{'','','','0','1','false'};
    private String[] AddrType_type_info = new String[]{'','','','0','1','false'};
    private String[] AddrId_type_info = new String[]{'','','','0','1','false'};
    private String[] apex_schema_type_info = new String[]{'http://namespace/V1_0','true','false'};
    private String[] field_order_type_info = new String[]{'AddrId','PartyKeys','AcctKeys','AddressIdent','AddrFormatType','AddrType'};
}

Here is the XML in the .xsd file:

  <xsd:complexType name="AddrKeys_Type">
<xsd:sequence>
  <xsd:choice>
    <xsd:element ref="AddrId">
      <xsd:annotation>
        <xsd:documentation>Address Identifier.</xsd:documentation>
      </xsd:annotation>
    </xsd:element>
    <xsd:sequence>
      <xsd:choice minOccurs="0">
        <xsd:element minOccurs="0" ref="PartyKeys">
          <xsd:annotation>
            <xsd:documentation>Party Keys. </xsd:documentation>
          </xsd:annotation>
        </xsd:element>
        <xsd:element minOccurs="0" ref="AcctKeys">
          <xsd:annotation>
            <xsd:documentation>Account Keys. </xsd:documentation>
          </xsd:annotation>
        </xsd:element>
      </xsd:choice>
      <xsd:element minOccurs="0" ref="AddressIdent">
        <xsd:annotation>
          <xsd:documentation>Address Identification.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element minOccurs="0" ref="AddrFormatType">
        <xsd:annotation>
          <xsd:documentation>Address Format Type.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element minOccurs="0" ref="AddrType">
        <xsd:annotation>
          <xsd:documentation>Address Type. Indicates if the address is primary or secondary.</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
    </xsd:sequence>
  </xsd:choice>
</xsd:sequence>

I did find that the parser picks up the minOccurs, maxOccurs, and nillable attributes. However the name is not picked up which is the most important in my situation. I do see that if i remove the referenced elements and declare them under the complex type then the name is picked up.

The referenced elements are declared properly:

  <xsd:element name="AddrId" type="Identifier_Type">
<xsd:annotation>
  <xsd:documentation>Address Identifier.</xsd:documentation>
</xsd:annotation>

 <xsd:simpleType name="Identifier_Type">
<xsd:annotation>
  <xsd:documentation>This is a Narrow Character data type with a maximum length of 36.</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
  <xsd:maxLength value="36" />
</xsd:restriction>

It seems like the "ref" attribute is not supported properly by WSDL2Apex. I say this because the following works:

  <xsd:complexType name="AddrDelRs_Type">
<xsd:sequence>
  <xsd:sequence>
    <xsd:element minOccurs="0" nillable="true" name="Statusxx" type="Status_Type">
      <xsd:annotation>
        <xsd:documentation>Status. </xsd:documentation>
      </xsd:annotation>
    </xsd:element>
  </xsd:sequence>
</xsd:sequence>

But using the ref attribute to reference another element does not work.

  • Can you share the complete WSDL in question? – Daniel Ballinger Feb 20 at 19:24
  • Unfortunately I can't. But I did find that the parser picks up the minOccurs, maxOccurs, and nillable attributes. However the name is not picked up which is the most important in my situation. I do see that if i remove the referenced elements and declare them under the complex type then the name is picked up. The referenced elements are declared correctly though. – FernandoG Feb 20 at 20:12
0

The problem I faced when implementing the FuseIT SFDC Explorer WSDL2Apex implementation was that the underlying WebServiceCallout.invoke() method in Apex doesn't handle xsd:choice in a WSDL.

Rather than blow up spectacularly and prevent any Apex code being generated when encountering an xsd:choice I opted to output what I could and append a warning to the generated code.

Consider the structure of the AddrKeys_Type complexType:

  1. AddrKeys_Type
    1. choice
      • AddrId
      • inner sequence

Where the inner sequence is another choice, followed by some fixed elements.

  1. choice
    1. PartyKeys
    2. AcctKeys
  2. AddressIdent
  3. AddrFormatType
  4. AddrType

You will need to manually modify the class to suit how you want to call it.

E.g. You could have:

  • just the AddrId member.
  • PartyKeys, AddressIdent, AddrFormatType, AddrType members.
  • Or AcctKeys, AddressIdent, AddrFormatType, AddrType

Beyond that, it is difficult to determine why the XML Element Name, Schema Namespace, and XML Type couldn't be determined. Actually, maybe it isn't. They are all ref="X" elements. They don't have a specific name attribute that can be assigned.

  • I see. Looking at the source code for WSDL2Apex I had the understanding that it was supposed to look at the referenced element and get the name. Because it gets the referenced element type, so I thought the name would be gathered also. – FernandoG Feb 21 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.