There are three separate issues here:
- Is the Enterprise WSDL the right tool to call from Apex to achieve what you want to do.
- If you did proceed with the Enterprise WSDL, how would you call it to create the report folder.
- How can you generate Apex classes to call the Enterprise WSDL without getting the "Script too large" error message from wsdl2apex.
I'm going to largely skip over 1 and 2 for now other than saying that the Enterprise WSDL isn't really intended for consumption within Salesforce. This would be better addressed in the question Can we create report folders through Apex.
3. Generating minimal Apex for the Enterprise WSDL
I've been working with an intern on a tool that will generate Apex for calling a WSDL. Part of this process is giving you control over which methods from the web service ultimately get generated in Apex.
With the Enterprise WSDL, you may only want to generate several of the 45 available methods.
Reducing the number of methods reduces the size of the generated apex class and reduces the number of methods you need to have covered by test cases.
If you are keen to try it, download the latest version of the FuseIT SFDC Explorer. There is a tab along the top called WSDL2Apex that will start the process off.
After defining the Apex class names for each namespace in the WSDL, you can pick and choose which methods will be generated in Apex:
One other benefit here is that you can generate basic tests and mock classes to give you coverage for the generated code.
Note that you many still need to remove some of the generated inner classes that aren't required.
The Salesforce wsdl2apex tool does not support a number of WSDL features. See Supported WSDL Features
That section does say:
Apex also supports the following schema constructs:
- xsd:attribute, in Apex code saved using API version 15.0 and later
However, I've found in practice you usually get the
Unsupported Schema element found error message that you encountered.
I've been working with an intern on an alternative WSDL to Apex converter to try and overcome a number of the limitations. You can get it for free from WSDL Parser and Apex Generator. Ensure you get v1.6.0 or later for WSDLs with attributes. It currently only supports Windows. (Full disclosure: I currently work for the company that creates this tool).
In this case the unsupported
<xsd:attribute> elements will be skipped from the WSDL and warnings added to the resulting apex. You will need to manually enforce the 3 character limit on the
Note that the Salesforce wsdl2apex tool doesn't support
<xs:extension> either. We should be able to handle this by replicating the Apex members from the base class and extending the parameters passed to WebService.invoke.
If you do have further issues, can you share your WSDL via some other means (DropBox, Google Docs, etc...). It will be easier to check it as a whole.
if you have marked your method as webservice , then you can use the Generate WSDL option to get the wsdl for the APEX webservice
reference : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_web_services_methods.htm