melohagan / budibase-datasource-soap

Performs a basic SOAP call to a web service
6 stars 2 forks source link

SOAP integration - assistance and feedback #1

Closed acseven closed 1 year ago

acseven commented 1 year ago

Hi,

Thank you very much for setting up the integration; I've tried to use it but I am a bit at a loss with creating a SOAP request.

https://github.com/Budibase/budibase/discussions/7807#discussioncomment-4119093

In any case, regarding your question for either using fields with a path or a JSON output, I would tend to say JSON would be more flexible to use but I can't say for sure.

I've tried using the integration with a SOAP API (with which I don't have prior experience), can you hint on how to do this with the integration? This API assumes you need to authenticate with an API_KEY first. An example:

Binding: KI_API3Binding
Endpoint: https://login.soapapiservice.com:443/API3_ws.php
SoapAction: urn:KI_API3#listClients
Style: rpc
Input:
  use: encoded
  namespace: urn:KI_API3
  encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
  message: listClientsRequest
  parts:
    sid: xsd:string
    offset: xsd:string
Output:
  use: encoded
  namespace: urn:KI_API3
  encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
  message: listClientsResponse
  parts:
    return: tns:PersonResponse
Namespace: urn:KI_API3
Transport: http://schemas.xmlsoap.org/soap/http
Documentation: Gest a list of (25) clients, starting with position indicated in «offset».

Thank you

melohagan commented 1 year ago

Hey @acseven

I've pushed some updates to the connector and added an example to the README of the repo. Could you try that and see if it works for you!

acseven commented 1 year ago

Hi, thank you, I will try it out!

I've tried to update it using the github url, or even uploading the tgz file directly but all failed (even after deleting the first release):

image

acseven commented 1 year ago

Also, I tried installing another of your plugins with the github repo URL and that worked fine; this one isn't installing unfortunately!

melohagan commented 1 year ago

Hey @acseven What version of Budibase are you running?

acseven commented 1 year ago

@melohagan My apologies, it was on 2.1.23. I updated to 2.1.28 and it's now installed.

acseven commented 1 year ago

Hi @melohagan,

The specific SOAP API I'm trying to use is even weirder than expected. In essence, it requires authentication which is not processed with a headers or URI parameter, but with a SOAP method/action which returns a session ID for the next 3600 seconds:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <authenticateRequest>
      <apikey>string</apikey>
    </authenticateRequest>
  </soap:Body>
</soap:Envelope>

Is there any viable way of using this on your extension?

acseven commented 1 year ago

Here's an example response:

<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
        <ns1:authenticateResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
            <return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[2]">
                <item xsi:type="xsd:string">1</item>
                <item xsi:type="xsd:string">eff9974d33c7----redacted---d9172d8b</item>
            </return>
        </ns1:authenticateResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
melohagan commented 1 year ago

Hey @acseven

You could do this through the app itself. So you would have one request that does the authentication and gets the key.

Then when that's done, you could possibly store that in App State, and pass it through as a binding to your other query that requires authentication. https://docs.budibase.com/docs/custom-queries

acseven commented 1 year ago

Thanks for the pointer; I think the query below is correct, at least it is working on postman:

image

Postman: image

melohagan commented 1 year ago

Ah it's because your response is returning SOAP-ENV:Body instead of soap:Body. Let me get a patch out for that

melohagan commented 1 year ago

@acseven Could you try version 1.1.1 please?

acseven commented 1 year ago

@acseven Could you try version 1.1.1 please?

Excellent, that worked. Now on to try and create that custom query you've suggested. Thanks!

SufiSR commented 1 year ago

Dear Melohagan,

i had the same challenge as @acseven however my responses return S:Envelope and S:Body instead of soap:Body. I tried forking and using my code instead - and failed miserably :D until i found out that i need to build the plugin first - and I don't have access to the CLI on my budibase instance. Could you incorporate the S:Envelope and S:Body return in your official plugin as well? Thanks so much!

melohagan commented 1 year ago

Hey @SufiSR

I won't likely get around to this anytime soon! You wouldn't mind firing up a PR yourself?

You can use this commit as an idea of what you'll need to do: https://github.com/melohagan/budibase-datasource-soap/commit/7a24072e7365403325d051a7afc16bddf3aee5e3

Basically it's an extra if statement to check for S:Envelope

SufiSR commented 1 year ago

Hope i did it correctly :)

melohagan commented 1 year ago

Hope i did it correctly :)

Code looks good, thanks! As mentioned, just need the version number to be incremented in the package.json file as well