Highlighted
Respected Contributor.
Respected Contributor.
522 views

Issue with integrating IBM Web Sphere with UFT.

As part of my requirement, I need to read the message from "IBM Web Sphere" using UFT. As UFT can't parse the received message (we can get the message using default options of UFT), I've added C# code to read the message and below is the code.

 

namespace Script
    {        using System;        using System.Xml;        using System.Xml.Schema;        using HP.ST.Ext.BasicActivities;        using HP.ST.Fwk.RunTimeFWK;        using HP.ST.Fwk.RunTimeFWK.ActivityFWK;        using HP.ST.Fwk.RunTimeFWK.Utilities;        using HP.ST.Fwk.RunTimeFWK.CompositeActivities;        using HP.ST.Ext.CustomDataProviders.Extensions;        using HP.ST.Ext.CustomDataProviders.ExcelFileArguments;

        [Serializable()]
    public class MQRead
    {

        public MQQueueManager _queueManager = null;
        public int port = portNumber;
        public string hostname = Host;
        public string channel = Channel;
        public string qManager = qMgr;
        public string inputQName = qName;
        public string outputQName = oqn;
        public string userID = un;
        public string password = pw;



        private void init(string[] args)
        {

            // Set up MQ environment

            MQEnvironment.hostname = hostname;
            MQEnvironment.channel = channel;
            MQEnvironment.port = port;
            MQEnvironment.userID = userID;
            MQEnvironment.password = password;

        }

        public static void Main(string[] args)
        {

            MQRead readQ = new MQRead();

            try
            {                readQ.init(args);                readQ.selectQMgr();                readQ.read();

            }
            catch (System.ArgumentException e)
            {
            //  System.out.println("Usage: java MQRead <-h host> <-p port> <-c channel> <-m QueueManagerName> <-q QueueName>");
                Console.WriteLine(e);
                Environment.Exit(1);
            }
            catch (MQException e)
            {
                Console.WriteLine(e);
                Environment.Exit(1);
            }
        }


        private void read()
        {
            int openOptions = MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INPUT_SHARED;

            MQQueue queue = _queueManager.accessQueue(inputQName, openOptions, null, null, null); // no alternate user id -  no dynamic q name -  default q manager

            Console.WriteLine("MQRead v1.0 connected.\n");

            int depth = queue.CurrentDepth;
            Console.WriteLine("Current depth: " + depth + "\n");
            if (depth == 0)
            {
                return;
            }

            MQGetMessageOptions getOptions = new MQGetMessageOptions();

            //getOptions.options = MQC.MQGMO_NO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_CONVERT ;
            //getOptions.matchOptions = MQC.MQFMT_STRING;
            //getOptions.options = MQC.MQGMO_ACCEPT_TRUNCATED_MSG |     MQC.MQGMO_CONVERT; 
            while (true)
            {
                MQMessage message = new MQMessage();
                try
                {


                    queue.get(message, getOptions);
                    sbyte[] b = new sbyte[message.MessageLength];                    message.readFully(b);
                    string response = StringHelperClass.NewString(b);
                    //System.out.println(response);
                    string formattedResponse = response.Replace("><", ">\n<");
                    Console.WriteLine(formattedResponse);
                    Console.WriteLine("\n\n" + "--------------------------------------------" + "\n\n");
                    //message.clearMessage();

                }
                catch (IOException e)
                {
                    Console.WriteLine("IOException during GET: " + e.Message);
                    break;
                }
                catch (MQException e)
                {
                    if (e.completionCode == 2 && e.reasonCode == MQException.MQRC_NO_MSG_AVAILABLE)
                    {
                        if (depth > 0)
                        {
                            Console.WriteLine("All messages read.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("GET Exception: " + e);
                    }
                    break;
                }
            }
            queue.close();            _queueManager.disconnect();
        }

        private void selectQMgr()
        {            _queueManager = new MQQueueManager(qManager);
        }

    }

    }

 

I'm getting The type or namespace name 'MQQueueManager' could not be found (are you missing a using directive or an assembly reference?) (CS0246) as error when I execute this code in UFT i.e., getting this compile time error at public MQQueueManager _queueManager = null; line of the code.

Known that some reference should be added using "Add Reference" option but don't know what exactly should we add.

How to resolve this issue?

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

hi, there

Please add “amqmdnet.dll” reference for this test with the linked guide. https://admhelp.microfocus.com/uft/en/latest/UFT_Help/Content/User_Guide/ref_add_reference.htm?Highlight=add%20reference

I also attached a snapshot for your reference. 

Thanks.

James

Highlighted
Respected Contributor.
Respected Contributor.

Hi James,

Thank you so much for the reply.

As you suggested, I've added "amqmdnet.dll" under ".NET Assemly Browser".

Still I'm facing the same issue.

Could you please check the code for it's correctness as I'm not sure about C#. Intially I developped it Java and converted it to C# using online converter.

Please refer to the attachment for the steps I followed and the error (both compile time and runtime errors) I'm getting.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.