Search code examples
wsdlsalesforceapex-code

Getting WSDL parse error while generating Apex code from WSDL in Salesforce


Getting the following error while parsing the Amazon Product Advertising API.

Error: Failed to parse wsdl: simpleType->element Name can not be null. 1295

WSDL Link : http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl

Are there any workarounds?


Solution

  • I pulled the WSDL down and made the following changes on lines 1292 and 1295. Note the new name attributes on both the inner simpleTypes.

    <xs:simpleType name="positiveIntegerOrAll">
    <xs:union>
        <xs:simpleType name="positiveTestOne">
            <xs:restriction base="xs:positiveInteger"/>
        </xs:simpleType>
        <xs:simpleType name="positiveTestTwo">
            <xs:restriction base="xs:string">
            <xs:enumeration value="All"/>
        </xs:restriction>
        </xs:simpleType>
        </xs:union>
    </xs:simpleType>
    

    After this I was able to successfully create an Apex class using this modified file. I didn't test actually calling it, but there were no errors when generating it.

    Salesforce uses an internal wsdl2apex tool that doesn't support a number of WSDL features. There is a list of Supported WSDL Features. Beyond that you can often hack the source WSDL to get a reasonable level of support.