Getting WSDL parse error while generating Apex cod

2019-08-05 08:04发布

问题:

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?

回答1:

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.



回答2:

So, you have tried to add that Web Service into Salesforce using some User Interface and it returned with that error, right?

If yes, then you can try save that wsdl locally - fix necessary node(s) and try for Salesforce upload your copy of wsdl file, or upload somewhere on internet host and give new address to Salesforce.

If no, then I need more information about how did you try to use that wsdl.