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
dturkeldturkel 

Imported WSDL/Webservice callout emitting empty tags

I have a WSDL that I successfully imported into Salesforce that has a simple request structure containing:

 

 

....

<xsd:choice>

<xsd:element maxOccurs="1" minOccurs="1" name="ItemCode" type="tns:ItemCodeType" />

<xsd:element maxOccurs="1" minOccurs="1" name="FullSync" type="tns:FullSyncType" />

</xsd:choice>

.....

<xsd:simpleType name="ItemCodeType">

<xsd:restriction base="xsd:string">

<xsd:minLength value="1" />

<xsd:maxLength value="100" />

</xsd:restriction>

</xsd:simpleType>

<xsd:simpleType name="FullSyncType">

<xsd:restriction base="xsd:string">

<xsd:pattern value="((Y|y))" />

</xsd:restriction>

</xsd:simpleType>....

 

When we generate the request in our controller class, we populate a value for ItemCode, and pass null to FullSync, expecting that no tag will be emitted for FullSync.  Instead, we are seeing both the ItemCode and the FullSync tags, with FullSync being empty ("<ItemCode>ABCDEFG</ItemCode><FullSync/>").

 

I've tried adding "nillable=false" among other things -- what could possibly be going wrong??!!?? 

 

UPDATE 01/19/2010 - I've tried using simple xs:strings as the types for my elements within the <choice> above, but had the same problem.  SFDC says they support the choice element -- is there some quirk or exacting attributes that have to be provided on the elements within the choice? 

 

Message Edited by dturkel on 01-19-2010 07:22 AM
RohanRohan

The generated code can be edited to encode the choice by splitting the class.

wsdl2apex will have created something like:

public class Foo {
        public ItemCodeType ItemCode;
        public FullSyncType FullSync;
        private String[] ItemCode_type_info = new String[] {...};
        private String[] FullSync_type_info = new String[] {...};
        private String[] apex_schema_type_info = new String[]{...};
        private String[] field_order_type_info = new String[]{'ItemCode', 'FullSync'};
}

 Split this into a class per choice like so:

public abstract class Foo { }
public class FooItemCode extends Foo {
        public ItemCodeType ItemCode;
        private String[] ItemCode_type_info = new String[] {...};
        private String[] apex_schema_type_info = new String[]{...};
        private String[] field_order_type_info = new String[]{'ItemCode'};
}
public class FooFullSync extends Foo {
        public FullSyncType FullSync;
        private String[] FullSync_type_info = new String[] {...};
        private String[] apex_schema_type_info = new String[]{...};
        private String[] field_order_type_info = new String[]{'FullSync'};
}

 Most importantly the field_order_type_info must contain only the element being chosen.

 

 

dturkeldturkel

Thanks for your reply.

 

It's been some time since we had this issue, and I likely worked around it by adapting the implementation of the service using our middleware.

 

I *hate* the idea of manipulating the emitted WSDL code.  I don't understand why they (SFDC) doesn't create an abstract class set for the WSDL, with expectations that one then edits contract methods on an implementation class.

 

At some point I'll have to give this a try.  Thanks again.