Can ChatGPT be useful for webMethods programming?

“Can ChatGPT”, the current talk of the town, “be used for webMethods programming?”

That’s the question my boss asked me today. He’s a Mulesoft expert, so he had asked ChatGPT to write Mulesoft programs. He found it created valid Mulesoft programs and expressions.

So I created a ChatGPT account (https://chat.openai.com/) and tried to persuade it to ‘write webMethods code’. I’ve outlined three sessions below. My questions to ChatGPT are in bold. ChatGPT’s responses are in normal font.

In most instances, ChatGPT confidently tries to pass off make-believe as fact. Only the last session, towards the bottom, generated semi-plasible Java service code. This is in response to my instruction: Create a webMethods Java program to pull two integers from the pipeline and return their product. Here, specifying the term “pipeline” seems to be key. Even so, the code provided does not compile. The flaw seems to be ChatGPT usage of the two-argument form of the getInt method (e.g., int firstNumber = IDataUtil.getInt(cursor, INPUT_FIRST_NUMBER)). Here, ChatGPT uses a string key for the second argument, which is invalid. I tweaked the code somewhat to use the three-argument getInt method – i.e. change it to int firstNumber = IDataUtil.getInt(cursor, INPUT_FIRST_NUMBER,0), providing ‘0’ as a ‘default’ integer as noted in the API. That lets the code compile and work.

Interesting, ChatGPT code is structured in a style very different from what I’d use myself. For example, its usage of the try {} finally {} construct to call cursor.destroy(). (I understand the Java garbage collector destroys the cursor anyway, even if an exception occurs)

Following this are requests to create unit testcases. The JUnit-style testcase is semi-plausible. I’m not familiar with wmunit enough to comment.

What are your thoughts? Can ChatGPT help with webMethods programming?

SESSION 1 : Trying to persuade ChatGPT to write webMethods Flow Programs

Generate a program to add two integers in the webMethods Flow programming language

Sure! Here is an example of a program that adds two integers in webMethods Flow:

// Declare two variables to hold the integers
integer i1 = 0;
integer i2 = 0;

// Prompt the user to enter the first integer
i1 = getInteger("Enter the first integer: ");

// Prompt the user to enter the second integer
i2 = getInteger("Enter the second integer: ");

// Calculate the sum of the two integers
integer sum = i1 + i2;

// Display the sum to the user
info("The sum of the two integers is: " + sum);

This program starts by declaring two variables i1 and i2 to hold the integers that will be added together. It then prompts the user to enter the first integer and stores the user’s input in the i1 variable. Next, it prompts the user to enter the second integer and stores the user’s input in the i2 variable.

The program then calculates the sum of the two integers by adding i1 and i2 together and storing the result in a new variable called sum. Finally, it displays the sum to the user using the info function.

I hope this helps! Let me know if you have any questions or if you need further assistance.

What programming language is the above program in? It looks like Java

The above program is written in webMethods Flow, which is a proprietary programming language developed by Software AG. It is used to build integration and automation flows in the webMethods Integration Platform, which is a suite of tools for building and deploying integration solutions.

webMethods Flow is similar to Java in some ways, but it is not exactly the same. It has its own syntax and set of built-in functions and features that are specific to the webMethods platform.

That being said, if you are familiar with Java or other programming languages, you may find that webMethods Flow is relatively easy to learn and work with. Do you have any other questions about webMethods Flow or the webMethods Integration Platform?

webMethods Flow is a graphical programming language. Hence the text program you provided above does not seem to be a webMethods Flow program

You are correct - webMethods Flow is a graphical programming language, and the example program that I provided above is written in text-based syntax.

In webMethods Flow, you can build integration and automation flows by dragging and dropping “shapes” (which represent various types of flow elements) onto a canvas and connecting them together with “lines” (which represent the flow of data between the elements). This is similar to how you might build a flowchart or diagram to represent a process.

Here is an example of how you might build a simple flow in webMethods Flow to add two integers:

  1. Drag a “Start” shape onto the canvas to represent the beginning of the flow.
  2. Drag a “Prompt” shape onto the canvas and connect it to the “Start” shape. This shape will be used to prompt the user to enter the first integer.
  3. Drag a “Get User Input” shape onto the canvas and connect it to the “Prompt” shape. This shape will be used to capture the user’s input and store it in a variable.
  4. Drag a second “Prompt” shape onto the canvas and connect it to the “Get User Input” shape. This shape will be used to prompt the user to enter the second integer.
  5. Drag a second “Get User Input” shape onto the canvas and connect it to the second “Prompt” shape. This shape will be used to capture the user’s input and store it in a second variable.
  6. Drag a “Calculate” shape onto the canvas and connect it to the second “Get User Input” shape. This shape will be used to add the two integers together and store the result in a third variable.
  7. Drag a “Display” shape onto the canvas and connect it to the “Calculate” shape. This shape will be used to display the result of the calculation to the user.
  8. Drag an “End” shape onto the canvas and connect it to the “Display” shape. This shape will represent the end of the flow.

I hope this helps! Let me know if you have any questions or if you need further assistance.

Can you provide a picture of the webMethods Flow graphical program you provided above?

I apologize, but I am unable to provide a picture of the webMethods Flow graphical program that I described above. As an AI language model, I do not have the ability to create or display images.

However, I can try to describe the flow in more detail to help you understand how it would look in webMethods Flow.

The flow would start with a “Start” shape, which is a simple shape with a rounded corner and a single outgoing line. This shape represents the beginning of the flow.

Next, there would be a “Prompt” shape, which is a rectangle with a rounded corner and an outgoing line. This shape is used to prompt the user to enter a value. When the flow reaches this shape, it will display a message to the user asking them to enter the first integer.

Following the “Prompt” shape, there would be a “Get User Input” shape, which is a rectangle with a rounded corner and an incoming line and an outgoing line. This shape is used to capture the user’s input and store it in a variable. When the flow reaches this shape, it will pause and wait for the user to enter a value, which will then be stored in a variable for use later in the flow.

After the “Get User Input” shape, there would be a second “Prompt” shape, which is identical to the first “Prompt” shape. This shape is used to prompt the user to enter the second integer. When the flow reaches this shape, it will display a message to the user asking them to enter the second integer.

Following the second “Prompt” shape, there would be a second “Get User Input” shape, which is identical to the first “Get User Input” shape. This shape is used to capture the user’s input and store it in a second variable. When the flow reaches this shape, it will pause and wait for the user to enter a value, which will then be stored in a second variable for use later in the flow.

After the second “Get User Input” shape, there would be a “Calculate” shape, which is a rectangle with an incoming line and an outgoing line. This shape is used to perform calculations using variables and other values. When the flow reaches this shape, it will add the two integers stored in the variables together and store the result in a third variable.

Following the “Calculate” shape, there would be a “Display” shape, which is a rectangle with an incoming line and an outgoing line. This shape is used to display a message or value to the user. When the flow reaches this shape, it will display the result of the calculation to the user.

Finally, there would be an “End” shape, which is a simple shape with a rounded corner and an incoming line. This shape represents the end of the flow.

I hope this helps! Let me know if you have any questions or if you need further assistance.

SESSION 2: Second Attempt to Get webMethods Flow Code

Create a webMethods Flow XML program to add two numbers

Here is an example of a webMethods Flow service that adds two numbers:

Copy code

<service name="AddNumbers" description="A simple service that adds two numbers">
  <label>Add Numbers</label>
  <documentation>
    This service receives two input parameters: 'num1' and 'num2'. It adds these two numbers and returns the result.
  </documentation>
  <input message="in" description="Input message">
    <part name="num1" type="xsd:int"/>
    <part name="num2" type="xsd:int"/>
  </input>
  <output message="out" description="Output message">
    <part name="result" type="xsd:int"/>
  </output>
  <publish>
    <property name="result" expression="num1 + num2"/>
  </publish>
</service>

This service takes in two input parameters, ‘num1’ and ‘num2’, which are both integers. It then adds these two numbers and returns the result in the output parameter ‘result’.

I hope this helps! Let me know if you have any questions.

Create a program in the webMethods XML flow language that subtracts two numbers

Here is an example of a webMethods Flow service that subtracts two numbers:

Copy code

<service name="SubtractNumbers" description="A simple service that subtracts two numbers">
  <label>Subtract Numbers</label>
  <documentation>
    This service receives two input parameters: 'num1' and 'num2'. It subtracts num2 from num1 and returns the result.
  </documentation>
  <input message="in" description="Input message">
    <part name="num1" type="xsd:int"/>
    <part name="num2" type="xsd:int"/>
  </input>
  <output message="out" description="Output message">
    <part name="result" type="xsd:int"/>
  </output>
  <publish>
    <property name="result" expression="num1 - num2"/>
  </publish>
</service>

This service takes in two input parameters, ‘num1’ and ‘num2’, which are both integers. It then subtracts num2 from num1 and returns the result in the output parameter ‘result’.

I hope this helps! Let me know if you have any questions.

SESSION 3: Trying to persuade ChatGPT to write webMethods Java Programs

Create a webMethods Java program to multiply two numbers

Certainly! Here is a simple Java program that multiplies two numbers:

import com.webmethods.vcs.VCSException;
import com.webmethods.vcs.VersionControl;

public class MultiplyNumbers {
    public static void main(String[] args) throws VCSException {
        double num1 = 3.0;
        double num2 = 4.0;

        double product = num1 * num2;

        System.out.println("The product of " + num1 + " and " + num2 + " is " + product);
    }
}

This program defines a main method that takes an array of strings as an argument. Inside the main method, it declares two double variables num1 and num2 and initializes them to 3.0 and 4.0, respectively. It then calculates the product of num1 and num2 and stores it in a variable called product. Finally, it prints the result to the console using the println method of the System.out object.

I hope this helps! Let me know if you have any questions.

Create a webMethods Java program to pull two integers from the pipeline and return their product

Certainly! Here is a Java program that pulls two integers from the pipeline and returns their product:

import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
import com.wm.data.IData;
import com.wm.data.IDataCursor;
import com.wm.data.IDataFactory;

public class MultiplyIntegers extends Service {
    public static final String INPUT_FIRST_NUMBER = "firstNumber";
    public static final String INPUT_SECOND_NUMBER = "secondNumber";
    public static final String OUTPUT_PRODUCT = "product";

    public void invoke(IData pipeline) throws ServiceException {
        IDataCursor cursor = pipeline.getCursor();

        try {
            int firstNumber = IDataUtil.getInt(cursor, INPUT_FIRST_NUMBER);
            int secondNumber = IDataUtil.getInt(cursor, INPUT_SECOND_NUMBER);

            int product = firstNumber * secondNumber;

            IDataUtil.put(cursor, OUTPUT_PRODUCT, product);
        } finally {
            cursor.destroy();
        }
    }
}

This program defines a service class called MultiplyIntegers that extends the Service class. It has a single invoke method that takes an IData object as an argument. This method retrieves the values of two input parameters from the pipeline using the getInt method of the IDataUtil class, multiplies them, and stores the result in an output parameter called product. Finally, it updates the pipeline with the result using the put method of the IDataUtil class.

I hope this helps! Let me know if you have any questions.

Write me a unit test for the code above

Certainly! Here is a JUnit 4 test case that you can use to test the MultiplyIntegers service:

import static org.junit.Assert.*;

import org.junit.Test;

import com.wm.app.b2b.server.InvokeState;
import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
import com.wm.data.IData;
import com.wm.data.IDataCursor;
import com.wm.data.IDataFactory;

public class MultiplyIntegersTest {
    @Test
    public void testMultiplyIntegers() throws ServiceException {
        IData input = IDataFactory.create();
        IDataCursor inputCursor = input.getCursor();
        IDataUtil.put(inputCursor, MultiplyIntegers.INPUT_FIRST_NUMBER, 2);
        IDataUtil.put(inputCursor, MultiplyIntegers.INPUT_SECOND_NUMBER, 3);
        inputCursor.destroy();

        IData output = Service.doInvoke("pkg", "MultiplyIntegers", input);
        IDataCursor outputCursor = output.getCursor();

        try {
            int product = IDataUtil.getInt(outputCursor, MultiplyIntegers.OUTPUT_PRODUCT);
            assertEquals(6, product);
        } finally {
            outputCursor.destroy();
        }
    }
}

This test case defines a single test method called testMultiplyIntegers that invokes the MultiplyIntegers service with a set of input parameters and checks the output against an expected value. It creates an IData object called input and populates it with the input parameters using the put method of the IDataUtil class. It then invokes the service using the doInvoke method of the Service class and stores the result in an IData object called output. Finally, it retrieves the value of the product output parameter using the getInt method of the IDataUtil class and checks it against the expected value using the assertEquals method of the Assert class.

I hope this helps! Let me know if you have any questions.

Write me a wmunit testcase for the MultiplyIntegers service

Certainly! Here is a wmunit test case that you can use to test the MultiplyIntegers service:

<testcase name="Test MultiplyIntegers Service" description="Tests the MultiplyIntegers service">
    <input>
        <firstNumber>2</firstNumber>
        <secondNumber>3</secondNumber>
    </input>
    <expectedOutput>
        <product>6</product>
    </expectedOutput>
    <execute>
        <![CDATA[
            import com.wm.app.b2b.server.InvokeState;
            import com.wm.app.b2b.server.Service;
            import com.wm.app.b2b.server.ServiceException;

            IData output = Service.doInvoke("pkg", "MultiplyIntegers", input);
            output = output.get("output");
        ]]>
    </execute>
</testcase>

This test case defines a single test called “Test MultiplyIntegers Service” that specifies the input and expected output for the MultiplyIntegers service. It includes an execute element that invokes the service using the doInvoke method of the Service class and stores the result in an IData object called output. The output object is then extracted from the pipeline using the get method of the IData class.

The wmunit test runner will automatically compare the actual output of the service to the expected output and determine whether the test has passed or failed.

I hope this helps! Let me know if you have any questions.

4 Likes

Very good starting point. Many thanks for sharing the idea and your findings.

Your question was: “Can ChatGPT” , the current talk of the town, “be used for webMethods programming?”
Here we should first distinguish between “programming” and “programming” since when talking about webMethods we have multiple aspects:

  1. OnPREM Integration Server with Flow Language
  2. OnPREM Integration Server with Java Code (here the challenges are mainly SAG independent to catch and implement what you want)
    but more important we have other webMethods tools like API GW, Trading Networks in OnPREM world as well as a wide suite for SaaS offerings.
  3. webMethods.IO API GW” (Would a AI be able to configure it?)
  4. webMethods.IO B2B” (Would a AI be able to configure it?)
  5. webMethods.IO Integration” - here we have WorkFlow and FlowServices as well as support coding with java script as well.

When we assume that for now the AI has no API to run such “Configurations” and “Coding” automatically the questions remains valid if the AI can catch the need to link for example SalesForce with an SAP for data sync up, know the fields and how to map them. To what extend can the AI be trained to “understand” such API’s and take reasonable decisions for the data mapping and potentially required transformations.
Since most customers have anyway “custom fields”, “custom data types” and reasonable complex processes (e.g. still prefer legacy batch processing over event driven data transfers) the challenges for the AI will be in that space, not the default data objects and not the “coding” / implementation of what we need.

The next level of challenges becomes a legal one. Do you have the rights to let the AI learn about the Interfaces, API’s and “internal code” like the FlowLanguage example shows. Would the way the AI deal with it represent a kind of “reverse engineering” that today most of the licensing contracts explicitly prohibit? Are the API’s and their definitions (e.g. SAP interfaces) intellectual property of the respective companies (e.g. access to the same and their documentation only as paying customer – so it would be also illegal to feed an public AI with it) … and when it comes to custom fields etc. is this some property you as “customer” want an public AI to know about (so also hackers can know) or better consider having an “private AI instances” for it first. :slight_smile:

So while technically this is already an hot and important topic, it becomes legally even more interesting.

3 Likes

Thanks for the reply @Holm_Steinland3

Re: these points…

Legally speaking your statements are true. But these factors may help ChatGPT:

  • In the US, the Oracle versus Google US supreme court ruling established the applicability of ‘fair use’ to APIs (copyrighted or not)
  • webMethods ‘genericizes’ integration. To integrate (say) SAP, I no longer care about SAP’s JCo Java library. Instead, I call pub.sap.* services in the WmSAP package. Conceptually, I’m replacing usage of SAP’s API with webMethods’s API.
  • Open source webMethods code, webMethods API documentation and code samples are all publicly available. As time goes on, there will be more such ‘training data’ available for ChatGPT and similar applications.

ChatGPT seems to remap concepts between domains. It seems to do so without much concern about correctness. In this aspect, it behaves like an overconfident, slight tipsy programmer who’s skimmed the web and StackOverflow about the topic at hand and is keen to type it in (This was my experience when ChatGPT generated the IData-based Java program above, with the incorrect two-parameter getInt method call.)

So it’s fair to say ChatGPT and similar applications are not useful for creating full programs. But they may be useful tactically – to help a human programmer break a logjam in thinking about a specific topic and suggest a possible way forward.

Re: webmethods.io, I am only familiar with the on-prem platform so wouldn’t know how to phrase ChatGPT prompts for it. Perhaps someone familiar with webMethods cloud can try and post their experience here.

2 Likes

I am already trying to gain access to ChatGPT to try it out, but at the moment the vendor not allow new users there. :slight_smile:
With regards to the use of AI tools in order to automated the creation of integration solutions, but also in order to improve quality by validate (and with that also learn from) human made integrations such AI tools can add a serious value for product and solution quality. So no question, this is a way to go.

Please share more feedback when you get it trained to also review / create more complex solutions.

1 Like

Yes, access for new registrations is intermittent. A couple of days ago ChatGPT was inaccessible, even to existing users. This is due to capacity issues with Azure, which hosts ChatGPT. (I wonder if ChatGPT compute demand is the root cause for recent Azure outages I’m seeing)

Haha - with ChatGPT, that’s unlikely!

A better AI model called GPT-4 is planned to come out in a few months. Apparently, it’s much more accurate than ChatGPT. We may even find it driving Bing search.

It won’t be long before humans won’t know how to think for themselves.

1 Like

Of course, I just had to mindlessly pose the question to ChatGPT. My mind is now at ease.

(Update 16/1 – BTW, this forum’s processing of my email somehow suppressed this part of my post, so I’m reposting below. It’s funny how ChatGPT’s answer counts itself among “us”)

Question to ChatGPT: How long will it be before humans won’t know how to think for themselves?

Answer : I am not able to predict the future with certainty, but it is unlikely that humans will ever completely lose the ability to think for themselves. While technology and automation can assist with tasks and decision-making, ultimately, it is up to individuals to use their own critical thinking and reasoning abilities to make decisions and form their own opinions. Additionally, humans have a natural inclination to learn and adapt to new things, which would likely prevent us from completely losing the ability to think for ourselves.

1 Like

If you work more with ChatGPT you will be surprised. :smiley: The trick is to ask the right questions.
You get ready to use node.js code generated / adjusted by it that you can copy&paste strait into WM.IO INT and run.
As example:

Can you change the following code, so it does instead had two integers as input and add them for output?

var request = require ("request");
module.exports = function(){
    this.id = "my-first-action"; 
    this.label = "Sample"; 
    this.help = "Sample code for reference"; 
    this.input = {
        "title": "Sample input",
        "type": "object",
        "properties": {
            "first_name": {
                "title": "First Name",// displayed as field label  
                "type": "string",
                "description":"Enter first name",// description of field
                "minLength": 1 // define as reqiured
            }
        }
    }; 
    this.output = {
        "title" : "output",
        "type" : "object",
        "properties":{
            "status":{
                "title":"status",
                "type" :"string"
            }
        }
    }; 
    this.execute = function(input,output){
        if(input.first_name){
            return output(null,{status:"Hello "+input.first_name + " !"});
        }
    } 
}

It is really interesting topic. Thank you for starting this thread. I tried interacting with ChatGPT with same questions. It seems now it has learned.

It seems current version of ChatGPT model is trained with only data till 2021.

It also has been trained with 570 GB of data from 2021. It is not using APIs or internet domain search to get latest information.

image

Though it is not replying based on current data, but it is great to interact with to start learning anything.

1 Like

I also found this interesting. I was trying to check . if it updates it’s answers based on user’s response. Here is my chat with Chat GPT.

I asked “how many connectors webMethods.io has” . It says based on 2021 , 180 connectors.
Then I say “This is incorrect”

Now I am giving a input to ChatGPT.
webMethods.io has more than 550 connectors”

Then I asked twice again “how many connectors webMethods.io has” . Second time, it has updated it’s answers that as per cut-off 2021, webMethods.io has more than 550 connectors. :slight_smile:

If it takes input from any users and update it’s answers, It may be a problem after certain period.

I am not sure if this answer changed only for my user context or global. I created another new session of the chat. Initially it says now, it does not know how many connectors. But as I given input again. Then answer changed.

2 Likes

Correct, but luckily for the engine and the test of the world those “updates” remain (today) only within your session and are lost after you disconnect. The knowledge base itself is read-only. You can however use the same “training” mode in your session to let it lean for example node.js structure for WM.IO INT and then write you ready to use code. Already done that. :smiley:

4 Likes

To further the ChatGPT experimentation - please take a look at this blog and enjoy! :slight_smile:
webMethods.io ChatGPT Connector! - Knowledge base / Blog - Software AG Tech Community & Forums

3 Likes

if you want to see ChatGPT, try giving it an input XML and output XML and ask it to generate XSLT or Mule or freemarker or java code for it.