Pages

Thursday, October 23, 2014

Importing the Salesforce Winter 15 Partner API to .NET

After updating the Partner API to v32.0 from v31.0 I started getting the following SGEN compilation errors:

  1. System.InvalidOperationException: Unable to generate a temporary class (result=1).
  2. error CS0029: Cannot implicitly convert type 'XYZ.SalesforcePartner.ListViewRecordColumn' to 'XYZ.SalesforcePartner.ListViewRecordColumn[]'

The new ListViewRecord and ListViewRecordColumn complexTypes from the v32.0 wsdl:

            <complexType name="ListViewRecord">
                <sequence>
                    <element name="columns"                  type="tns:ListViewRecordColumn" maxOccurs="unbounded"/>
                </sequence>
            </complexType>

            <complexType name="ListViewRecordColumn">
                <sequence>
                    <element name="fieldNameOrPath"          type="xsd:string"/>
                    <element name="value"                    type="xsd:string" nillable="true"/>
                </sequence>
            </complexType>

The problem appears in the generated Reference.cs with the ExecuteListViewResult.records multidimensional array return type.

        /// 
        [System.Xml.Serialization.XmlArrayItemAttribute("columns", typeof(ListViewRecordColumn), IsNullable=false)]
        public ListViewRecordColumn[][] records {
            get {
                return this.recordsField;
            }
            set {
                this.recordsField = value;
            }
        }

The XmlArrayItemAttribute typeof(ListViewRecordColumn) should be typeof(ListViewRecordColumn[]). After changing this manually the web reference compiled again.

        /// 
        [System.Xml.Serialization.XmlArrayItemAttribute("columns", typeof(ListViewRecordColumn[]), IsNullable=false)]
        public ListViewRecordColumn[][] records {
            get {
                return this.recordsField;
            }
            set {
                this.recordsField = value;
            }
        }

See also:

2 comments:

  1. Should be use in case of VB.NET project.

    '''
    <System.Xml.Serialization.XmlArrayItemAttribute("columns", GetType(ListViewRecordColumn()), ...

    ReplyDelete
  2. It works. Thanks for the post!

    ReplyDelete