+ Start a Discussion
Camelia MuresanCamelia Muresan 

Error with .Net integration for ListViewRecord and ListViewRecordColumn from Salesforce API 32.0

After Winter release we encountered an issue for our .Net integration related to Soap API schema WSDL.
It is a known issue with the XML serialization class from .NET Framework all versions. The XMLSerializer code generation component cannot handle the XSD definitions that have only one element and the occurrence of the element is unbounded.
This is the case with the newly introduced classes ListViewRecord and ListViewRecordColumn from Salesforce API 32.0.
We had to manually modify the schema and altered the constructors for those 2 classes mentioned above by adding an extra dummy attribute.
This way the XMLSerializer code generator will use the proper XmlSerialization attributes for the constructor.

There should be a way to update WSDL from Salesforce to support .Net integration without manually update

Thank you! 

zettaneer1.3904945477293455E12zettaneer1.3904945477293455E12
Thank you for posting this. I'd like to add that we are encountering this same problem now as well... I have not yet tried your workaround to this, but for what it's worth, here are the details of the exception when trying to use API 32.0 .wsdl from our Sandbox...

Exception Details: System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'SalesforceService.ListViewRecordColumn[]' to 'SalesforceService.ListViewRecordColumn'
error CS0030: Cannot convert type 'SalesforceService.ListViewRecordColumn[]' to 'SalesforceService.ListViewRecordColumn'
error CS0029: Cannot implicitly convert type 'SalesforceService.ListViewRecordColumn' to SalesforceService.ListViewRecordColumn[]'
error CS0029: Cannot implicitly convert type 'SalesforceService.ListViewRecordColumn' to 'SalesforceService.ListViewRecordColumn[]'
Camelia MuresanCamelia Muresan
This is our work around: 

Before:

<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>


After:

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

<complexType name="ListViewRecordColumn">
<sequence>
  <element name="fieldNameOrPath" type="xsd:string"/>
  <element name="value" type="xsd:string" nillable="true"/>
</sequence>
<xsd:attribute name="tmp" type="xsd:string" />
</complexType>
Rob Waibel JrRob Waibel Jr
I followed the above example, still getting the error.  Exact code in the wsdl:
           <complexType name="ListViewRecord">
                <sequence>
                    <element name="columns" type="tns:ListViewRecordColumn" maxOccurs="unbounded"/>
                </sequence>
            <xsd:attribute name="none" type="xsd:string" />
            </complexType>

            <complexType name="ListViewRecordColumn">
                <sequence>
                    <element name="fieldNameOrPath" type="xsd:string"/>
                    <element name="value" type="xsd:string" nillable="true"/>
                </sequence>
            <xsd:attribute name="none2" type="xsd:string" />
            </complexType>
Still getting the errors.

Ideas?
jpgilbertjpgilbert
Hi Rob,

To get mine working I had to delete the extra [] from public ListViewRecordColumn[][] records in Reference.cs which is a file that is formed from the WSDL. I think that's a VS bug.

So that line should read
public ListViewRecordColumn[] records {
Rob DuffRob Duff
There are two lines I found that need to be changed:
line 105930: private ListViewRecordColumn[][] recordsField;
line 105987: public ListViewRecordColumn[][] records {
to
line 105930: private ListViewRecordColumn[] recordsField;
line 105987: public ListViewRecordColumn[] records {

After I updated the Reference.cs as stated I was able to create an instance of SforceService without an exception error.  I am using Visual Studio 2013 and .Net Framework 4.5.  I imported my WSDL as a Web Reference.
gbluesgblues
Thanks Camelia! That did the trick. For others: make sure you right-click your service reference in VS and choose "Update Service Reference" so that VS recompiles the SOAP client. If that doesn't work, then double-check that the service reference is pointing to the WSDL you edited.
Sonja ZinaiSonja Zinai
I have just updated the service reference to my enterprise wsdl. I am having the same issue. I have tried to find my Reference.cs file so that I can make the changes mentioned in this thread, but I cannot find where it is located. Can anyone help guide me to the right place?
louisa barrett 7louisa barrett 7
You need to ensure that "Show all files" is selected within Visual Studio, then expand the Service References/Connected Services node. Then expand the service object and then Reference.svcmap. It should then be listed.
yvk431yvk431
Can you try by changing ListViewRecordColumn[][] to ListViewRecordColumn[] in the reference class.

--yvk
Albert ParentAlbert Parent
Thanks to Camelia for the workaround.

Salesforce, this is three years old.  Why is there still a problem with the WSDL you generate not working for .NET?
Chandra Sekhar 176Chandra Sekhar 176
I'm having the same issue even now.. Should I still have to modify the svcmap?
Andrew MagruderAndrew Magruder
Camelia Muresan's fix worked for me.  You put the raw wsdl from SalesForce in a folder probably outside your Visual Studio project and make her suggested edits there.  I deleted the Web Reference in my VS project and created it new by pasting in the full path to the raw wsdl.