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

SOAP handler not working for source with authentication. #5650

Open
4 tasks
narendravyas24 opened this issue Jul 7, 2023 · 12 comments
Open
4 tasks

SOAP handler not working for source with authentication. #5650

narendravyas24 opened this issue Jul 7, 2023 · 12 comments

Comments

@narendravyas24
Copy link

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug
We are creating a mesh with SOAP source that needs authentication to fetch the WSDL source.

We already tried on the latest version (0.94.6), but we are getting below mentioned error:

Failed to generate the schema TypeError: wsdlObject.definitions is not iterable
at SOAPLoader.loadWSDL

When we are on version 0.14.25 this works but on latest version it fails. So this seems to be a bug in @omnigraph/soap
node_modules/@omnigraph/soap/cjs/SOAPLoader.js

This is how my mesh looks like:

sources:
  - name: Source123
    handler:
      soap:
        source: <MY_SOURCE>
        operationHeaders:
          Authorization: <MY_TOKEN>
        schemaHeaders:
          Authorization: <MY_TOKEN>

This is how my <MY_TOKEN> looks like: "Bearer 123abcslkdjfks234234"

To Reproduce Steps to reproduce the behavior:
Provide a SOAP source that needs authentication to fetch WSDL and this fails with the error described above.

Expected behavior
SOAP source that needs authentication should also work. As it works in version 0.14.25 and not latest so this should not happen.

Environment:

  • OS:
  • @graphql-mesh/...:
  • NodeJS:

Additional context

@ardatan
Copy link
Owner

ardatan commented Jul 7, 2023

Thank you for creating the issue. In order to help us reproducing it, could you give more information? For example, does it work when you send a request for WSDL on some other client such as Postman, cURL etc?

@narendravyas24
Copy link
Author

narendravyas24 commented Jul 8, 2023

@ardatan - Thanks for reverting.
I am even not able to create the mesh. I am having .meshrc.yaml on root and when I run yarn mesh dev, command fails with error.

Failed to generate the schema TypeError: wsdlObject.definitions is not iterable
at SOAPLoader.loadWSDL (/home/n/projects/gql-mesh-core/node_modules/@omnigraph/soap/cjs/SOAPLoader.js:406:45)

My Mesh:

sources:
  - name: Source123
    handler:
      soap:
        source: <MY_SOURCE>
        operationHeaders:
          Authorization: <MY_TOKEN>
        schemaHeaders:
          Authorization: <MY_TOKEN>

This is how my <MY_TOKEN> looks like: "Bearer 123abcslkdjfks234234"

Their is no issue with the source because if I downgrade the @graphql-mesh/soap version to 0.14.25 it works.

The issue I think is when the source needs authentication to return WSDL resource.

This is how my projects package.json looks like:

{
  "name": "gql-mesh-core",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@graphql-mesh/cli": "^0.82.35",
    "@graphql-mesh/openapi": "^0.93.2",
    "@graphql-mesh/soap": "0.94.6",
    "graphql": "^16.6.0"
  }
}

Thanks.

@narendravyas24
Copy link
Author

Hi @ardatan ,
I can see that this issue has been mentioned and has been moved to project roadmap.
Just wondering if you were able to reproduce the issue and is there anything I can help in, please let me know.
Thanks.

@ardatan
Copy link
Owner

ardatan commented Jul 13, 2023

Sorry unfortunately I couldn't. I still need a reproduction :(

@narendravyas24
Copy link
Author

If you can get any source endpoint that need authentication to return WSDL that will be enough to reproduce. Unfortunately I can not get any such source openly available online.

@ardatan
Copy link
Owner

ardatan commented Jul 13, 2023

Sorry as I said I tried to reproduce it but couldn't.

@narendravyas24
Copy link
Author

Hi @ardatan ,
Please give this mesh a try:

sources:
  - name: CommerceSource
    handler:
      soap:
        source: https://jnz3dtiuj77ca.dummycachetest.com/soap/all?wsdl&services=catalogCategoryListV1
        wsdl: https://jnz3dtiuj77ca.dummycachetest.com/soap/all?wsdl&services=catalogCategoryListV1
        operationHeaders:
          Authorization: Bearer 123456789123456789123456789
        schemaHeaders:
          Authorization: Bearer 123456789123456789123456789

I got this source from: https://venia.magento.com/soap/all?wsdl_list=1

17_july

@ardatan
Copy link
Owner

ardatan commented Jul 17, 2023

Could you check if the given source has this structure?
https://www.tutorialspoint.com/wsdl/wsdl_example.htm

@ardatan
Copy link
Owner

ardatan commented Jul 17, 2023

#5689
Could you try with the alphas in this PR? It doesn't fix the issue but it will show better error messages to understand the problem.

@narendravyas24
Copy link
Author

@ardatan - actually we can only get the WSDL resource post authorization.

So, if you directly hit this URL in chrome-
https://jnz3dtiuj77ca.dummycachetest.com/soap/all?wsdl&services=catalogCategoryListV1

this shows the error "The consumer isn't authorized to access %resources."

image

This source that I provided above I do not know the actual Bearer token for that, but I have an exact same source that works in 0.14.25 and not in 0.94.6.

@ardatan
Copy link
Owner

ardatan commented Jul 17, 2023

Could you install the latest versions and try again?

@narendravyas24
Copy link
Author

@ardatan : I verified it against the latest version i.e. 0.94.8 and now the Authentication error that was coming in past is not coming but now we are not able to fetch data from the source (in case when authentication is needed).

So, there are two potential issues:

  1. For the source in which we get schema only post authentication returns null results.
    (I confirmed that the sku I am querying exists also tried with various other endpoints as well)
    example mesh for this case:
sources:
  - name: CommerceSource
    handler:
      soap:
        source: https://jnz3dtiuj77ca.dummycachetest.com/soap/default?wsdl&services=catalogProductRepositoryV1,catalogCategoryListV1
        operationHeaders:
          Authorization: Bearer 123456789123456789123456789
        schemaHeaders:
          Authorization: Bearer 123456789123456789123456789

image

  1. For the commerce endpoint there is all mutation and no query. [Note: this is only for commerce source]
    example mesh to reproduce point2:
sources:
  - name: VeniaCommerceSource
    handler:
      soap:
        source: https://jnz3dtiuj77ca.dummycachetest.com/soap/all?wsdl&services=directoryCurrencyInformationAcquirerV1

From this mesh we are only trying to get the currency information. But this is coming under mutation and not under query(same is for other endpoints as well)

mutation{
  MagentoWSDL_directoryCurrencyInformationAcquirerV1Service_directoryCurrencyInformationAcquirerV1Port_directoryCurrencyInformationAcquirerV1GetCurrencyInfo{
    result{
      baseCurrencyCode
    }
  }
}

This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants