webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Debugging java services - reusing server connection

    Posted Tue May 27, 2025 07:25 AM

    Hi everyone,

    On the matter of debugging Java services using a test harness, I am trying to find a way to use the Java API to reuse an existing session in order to avoid having to input the username and password repeatedly.

    I am trying to avoid the option of configuring a specific port with a certificate login.

    Furthermore, I'm trying to figure out more about how Designer connects to integration servers - how a connection is created, where it's stored at runtime, and what classes and methods I can use to retrieve active connections.

    My Java/Eclipse knowledge is, admittedly, quite lacking.

    If anyone has any resources that would be helpful in learning how I can navigate through Designer, the libraries used and configurations that they could share, I would be most grateful.

    All the best,
    Pedro Dinis Silva



    ------------------------------
    Pedro Dinis Silva
    Integration Engineer
    Nokia
    ------------------------------


  • 2.  RE: Debugging java services - reusing server connection

    Posted Tue May 27, 2025 09:19 AM

    Can you be a bit more specific and give an example that is concrete as possible?

    It seems your question is not about your goal (e.g. unit testing) but one possible way to achieve this goal (running some Java logic on IS from Designer). Is that impression correct?



    ------------------------------
    All the best,
    Christoph
    ------------------------------



  • 3.  RE: Debugging java services - reusing server connection

    Posted Tue June 03, 2025 07:31 AM

    Hello Christoph,

    Put in simple terms, my goal is to understand how designer manages and creates connections and sessions so that I can use that information to also make my life easier when I need to debug java programs using test harnesses.

    With that said, would appreciate any advice on changes I could make to the code in order to be able to connect securely to an IS, whilst protecting my credentials and avoiding the dreaded login prompt.

    I am in a team environment and hard-coding my credentials is not an option. I am still very green on eclipse and Java, sorry if my question is a little vague.

    Regards,
    Pedro



    ------------------------------
    Pedro Dinis Silva
    Integration Engineer
    Nokia
    ------------------------------



  • 4.  RE: Debugging java services - reusing server connection

    Posted Tue June 03, 2025 08:50 AM
    Edited by John Carter Tue June 03, 2025 08:51 AM

    Hi Pedro,

    You can make like much easier by simply moving your java code into a proper java project, then invoke it from your java services. In this way the java services just act as a very simply bridge between the service/pipeline world and that of java/objects. The jar for your java project should go into your package's code/jars directory. No need to restart, just reload the package.

    You can simply start your IS in debug mode and then connect the eclipse debugger via the port e.g.

    Then simply add a breakpoint to where you want to debug from within your java project. Just make sure to add your java project to the source tab (above) so that it will open the appropriate java file when the breakpoint gets hit.
    The nice thing about this approach is that you trigger the breakpoint by call any webMethods asset such as a flow service or API, from an external client and then watch your IDE switch to debug mode automatically. No need for remote sessions or any other complexity.
    all the best,
    John.



    ------------------------------
    John Carter
    ------------------------------



  • 5.  RE: Debugging java services - reusing server connection

    Posted Wed June 04, 2025 10:29 PM
    Edited by Akshith Arremreddy Wed June 04, 2025 10:30 PM

    I might have done this long time ago and there might be better ways to do this now. In the past I used a standard Java credentials file to pick the username\password from it and then edit the harness code to use it. You can easily edit this to use cert for auth from credentials file.

    public static ArrayList<String> getCredentials() {
        	ArrayList<String> creds=new ArrayList<String>();
        	Properties properties = new Properties();
            try (InputStream input = new FileInputStream("D:\\credentials.properties")) {
                properties.load(input);
    
                String username = properties.getProperty("username");
                String password = properties.getProperty("password");
                System.out.println("Username: " + username);
                System.out.println("Password: " + password);
                creds.add(username);
                creds.add(password);
            } catch (IOException e) {
                System.err.println("Error loading properties file: " + e.getMessage());
            }        
        	
        	return creds;
        }



    ------------------------------
    Akshith Arremreddy
    ------------------------------