Skip to content
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

[BUG] Error while parsing Subdefinition #16

Closed
starsoccer opened this issue Jun 24, 2021 · 13 comments
Closed

[BUG] Error while parsing Subdefinition #16

starsoccer opened this issue Jun 24, 2021 · 13 comments
Labels
bug Something isn't working

Comments

@starsoccer
Copy link

I am trying to use the workday API and when trying to autogenerate code for the Human Resources service I get the below error.

Error occured while generating client "Human_Resources.wsdl"
        Error: Error while parsing Subdefinition for wd:Get_Political_Affiliations_ResponseType.wd:Get_Political_Affiliations_ResponseType
1 Errors occured!

WSDL File: https://community.workday.com/sites/default/files/file-hosting/productionapi/Human_Resources/v36.1/Human_Resources.wsdl

@dderevjanik
Copy link
Owner

Hi,
I tried to parse that wsdl file and it works, when I increased limit of max maxRecursiveDefinitionName to 85. It happens when there are a lot of definitions with same name. Then new option maxRecursiveDefinitionName will be available in next release (currently available in master branch).

@dderevjanik dderevjanik added the bug Something isn't working label Jun 25, 2021
@starsoccer
Copy link
Author

thanks is there an ETA on when this fix will be released in a tagged version?

@dderevjanik
Copy link
Owner

@starsoccer new version 1.2.0 is released https://github.com/dderevjanik/wsdl-tsclient/releases/tag/1.2.0

Update your package and pass --maxRecursiveDefinitionName=90 argument to CLI, like wsdl-tsclient ./Human_Resources.wsdl --maxRecursiveDefinitionName=90 -o ./generated

@starsoccer
Copy link
Author

thanks that seems to have worked. I had to bump it to 180 though as some other files were having issues.

On an unrelated note it would be nice if there was a way to merge multiple wsdl files. In the case of workday there are 10+ different wsdl files and ideally I could just make one client with a shared authentication and endpoint rather then have to do so for each resource. But I can make another issue for that if you think its an idea worth exploring.

@dderevjanik
Copy link
Owner

dderevjanik commented Jun 27, 2021

I see your point, but IMO it isn't good idea to merge multiple files.... instead of merging several wsdl files into one, you can generate several wsdl clients at once (wsdl-tsclient ./path/to/*.wsdl -o ./generated) and then in your code create one access point to your APIs (Google is doing same thing with google-api, where you initialize one class with several APIs at once and shared auth).

// api/commnuityworkday.ts
import soap from "soap";
import { createClientAsync as createHumanResourceClient, HumanResourceClient } from "../generated/humanresources";
import { createClientAsync as createCompanyServiceClient, CompanyServiceClient } from "../generated/companyservice";
import { createClientAsync as createFileShareClient, FileshareClient } from "../generated/fileshare";

interface CommunityWorkdayAuth {
    username: string;
    password: string;
}

class CommunityWorkdayAPI {
  
  private _humanResourceClient: HumanResourceClient;
  private _companyServiceClient: CompanyServiceClient;
  private _fileshareClient: FileshareClient;

  async init(auth: CommunityWorkdayAuth) {
      const basicAuth = new soap.BasicAuthSecurity(auth.username, auth.password);
      
      this._humanResourceClient = createHumanResourceClient("./resources/Human_Resources.wsdl");
      this._humanResourceClient.setSecurity(basicAuth);
      
      this._companyServiceClient = createCompanyServiceClient("./resources/CompanyService.wsdl");
      this._companyServiceClient.setSecurity(basicAuth);
      
      this._fileshareClient = createFileShareClient("./resources/FileShare.wsdl");
      this._fileshareClient.setSecurity(basicAuth);
  }

  humanResource() {
      return this._humanResourceClient;
  }

  company() {
      return this._companyServiceClient;
  }

  fileShare() {
      return this._fileshareClient;
  }

}

Then you can use it as module in your project (I'm used to create NPM library from code above to avoid generating client everytime).

// main.ts
const communityWorkday = new CommunityWorkdayAPI();
await communityWorkday.init({ username: "admin", password: "adminpwd" });

await communityWorkday.fileShare().sendFileAsync({ path: "path/to/file" });

I hope this may help you

@starsoccer
Copy link
Author

yeah that is similar to what I was planning I was just hoping to have it automatically generated is all.

Also rather then exposing each individual service I was hoping it would auto generate pass through functions so I could just have one top level client and call all functions and have them simply passed through to the needed service/resource path.

@starsoccer
Copy link
Author

There also seems to be an issue with some of the auto generated function and parameter names that include a dash which isnt allowed and causes typings to break. I think a simple fix for this is to just replace all - with a underscore instead

@dderevjanik
Copy link
Owner

Sure, I forget about those... We already have changeCase function, which replaces all ., so we can extend that...

@starsoccer
Copy link
Author

It may be worth using a package that checks to ensure the string used is a valid java script variable name: https://www.npmjs.com/search?q=valid%20variable%20name

@dderevjanik
Copy link
Owner

Yeah, it would be great to find good library for making sure the variable name is valid javascript varname.

Please, is your issue with - similar to #18 ?
I just published dev version npm i wsdl-tsclient@dev, so you could try if the issue with wrong property names persists.

@starsoccer
Copy link
Author

Yes I think its similar. Sadly the dev version doesnt fully resolve the issue. I still have cases like Put_User-Based_Security_Group_AssignmentAsync that is invalid

@dderevjanik
Copy link
Owner

Oh, now I see similar problem. I only fixed definitions, not Ports nor Services. I'm going to fix it.

Besides that, I created PR to make sure all generated wsdl-tsclient are compile-time valid #19

@starsoccer
Copy link
Author

Awesome well if you need me to try anything else just let me know. Otherwise I think atleast for now this can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants