-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when compiling Tooling API Java Bindings (enum constant value starting with the number) #334
Comments
@bereg2k I am also seeing this issue. It is preventing me from generating new stub files for the tooling api >60.0. |
@bereg2k fyi, I've also reported this issue inside the partner community. I'm hoping this will get some movement. |
@CloudStudioInc they are available because you can clone this repo, make adjustments as you see fit, and build a project locally :) Then use it with your WSDL. I tried this route – worked for me. The easiest route though... make minor adjustments to the |
The tooling.xml (and strong typed) has always problems for the generation of the jar with wsc. https://mvnrepository.com/artifact/com.force.api/force-wsc : 62.0 (the jars above are always updated correctly) and https://mvnrepository.com/artifact/com.force.api/force-tooling-api : 32.0 (2018), for many years now, we had almost always problems for the generation of this jar. That seems deliberate given that it is a very complicated generation with maven that works fine for the other xml (mvnrepository ALWAYS updated including all the sub-versions). <xsd:simpleType name="CalculatedInsightPublishScheduleInterval"> Perplexity AI: You're right to point out this issue. The XML you've provided for the CalculatedInsightPublishScheduleInterval type is problematic because it uses numeric values as enumeration values within a string restriction. This can lead to issues with code generation and type safety in strongly-typed languages like Java. Here's how we can address this issue: Understand the Problem: Potential Solutions: <xsd:simpleType name="CalculatedInsightPublishScheduleInterval"> This would generate a proper integer-based enum in Java. Workaround for WSC: Since WSC doesn't provide built-in customization for this scenario, you have a few options: a) Manual Post-Processing: Generate the code using WSC, then manually modify the generated Java enum to use integers instead of strings. b) Custom Enum Wrapper: Create a custom enum that wraps the generated string-based enum: public enum CalculatedInsightPublishScheduleIntervalWrapper {
} c) Custom XmlAdapter: If you're using JAXB, you can create a custom XmlAdapter to convert between the string representation and an integer: public class CalculatedInsightPublishScheduleIntervalAdapter extends XmlAdapter<String, Integer> {
} Then use it in your generated or custom classes: @XmlJavaTypeAdapter(CalculatedInsightPublishScheduleIntervalAdapter.class) Report the Issue:
|
@alcabon My issue here is that |
@bereg2k I know that CalculatedInsightPublishScheduleInterval in question is a standard built-in type that's controlled by Salesforce and none of the AI potential solutions works (purely theoretical and it is intended for the Salesforce developers, AI can help them in order to understand their error that block the generation (it is not a major errror but a critical one)). - If this WSDL is provided by a third-party service, consider reporting this as an issue to them. That is the only possible action. Otherwise, I removed the wrong types many times (degraded versions but still working). We cannot "correct" these errors because it is controlled by Salesforce. |
Tooling API WSDL generates the XML file with the following element inside of it:
However, when compiling Java Bindings for the SOAP API for it, the execution fails:
Logs:
This is the underlying Java class which the script is trying to create from the XML element:
CalculatedInsightPublishScheduleInterval.java
Having enum values like this won't compile because it's incorrect Java syntax:
0("0")
,1("1")
Is it possible to work around this by compiling such enumerations using the
_
symbol in the beginning?Like this:
_0("0")
,_1("1")
Library version in Maven POM:
The text was updated successfully, but these errors were encountered: