ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » .NET PCF API conversion

Post new topic  Reply to topic
 .NET PCF API conversion « View previous topic :: View next topic » 
Author Message
jslansky
PostPosted: Wed Jan 18, 2012 1:38 am    Post subject: .NET PCF API conversion Reply with quote

Newbie

Joined: 18 Jan 2012
Posts: 4

Hello,

I'm trying to use amqmdnet.dll (IBM MQ .NET API) to send and receive PCF messages to remote MQ manager. When I send PCF command MQCMD_INQUIRE_Q_NAMES, I receive PCF message but queue names are encoded in EBCDIC. When I ask for CodedCharSetId and CharacterSet of MQ manager when new object IBM.WMQ.MQQueueManager is created, it says "437". I can get values from response, but data is in EBCDIC. I can see data of response in hexadecimal when I capture network packets comming from MQ manager and then I can convert them (from hex) to ASCII - successfully. But in C# are data "interpreted" as ASCII, but not correctly. Most of the characters are presented as "?". How can I get these data exactly as they arrived (in hex) or do a conversion of data in response using .Net API?

Thanks for any suggestion.

Jan
Back to top
View user's profile Send private message
JasonE
PostPosted: Wed Jan 18, 2012 4:41 am    Post subject: Reply with quote

Grand Master

Joined: 03 Nov 2003
Posts: 1220
Location: Hursley

Can you give a rough code snippet of how you are getting the response and getting the queue name from it please.
Back to top
View user's profile Send private message
jslansky
PostPosted: Wed Jan 18, 2012 4:47 am    Post subject: Reply with quote

Newbie

Joined: 18 Jan 2012
Posts: 4

JasonE wrote:
Can you give a rough code snippet of how you are getting the response and getting the queue name from it please.

Yes,

Code:

using System;
using System.Collections;
using System.Threading;
using IBM.WMQ;
using IBM.WMQ.PCF;

namespace my.Example.Mq
{

   public class InquireQueueNames
   {
      private String queueManagerName = null;
      private MQQueueManager queueManager;
      private Hashtable properties;

      public static void Main()
      {
         InquireQueueNames me = new InquireQueueNames();
         me.Go();
      }

      private void Go()
      {
         FindQueueNames();
      }


      private bool useDefaultQm
      {
         get
         {
            return true;
         }
      }

      private void FindQueueNames()
      {

         try
         {
            properties = new Hashtable();
            properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
            properties.Add(MQC.HOST_NAME_PROPERTY, "my.mq.com");
            properties.Add(MQC.PORT_PROPERTY, "1414");
            properties.Add(MQC.CHANNEL_PROPERTY, "my.mqchannel");

            Console.Write("Connecting to queue manager.. ");
            queueManager = new MQQueueManager(queueManagerName, properties);
            if (!queueManager.IsConnected)
            {
               queueManager.Connect();
            }
            Console.WriteLine("done");

            Console.WriteLine("Using QM:\n  '{0}'", queueManager.Name.Trim()); // Name has trailing spaces
            PCFMessageAgent agent = new PCFMessageAgent(queueManager);
            PCFMessage request = new PCFMessage(CMQCFC.MQCMD_INQUIRE_Q_NAMES);
            request.AddParameter(MQC.MQCA_Q_NAME, "LQ0129.SOPIC*");
            request.AddParameter(MQC.MQIA_Q_TYPE, MQC.MQQT_LOCAL);
            PCFMessage[] responses = agent.Send(request);

            if (responses == null) throw new Exception("bogus response from MQ PCF.");
            else
            {
               if (responses[0].GetCompCode() == MQC.MQCC_OK)
               {
                  PCFParameter[] p = responses[0].GetParameters();
                  if ((p != null) && (p.Length > 0))
                  {
                     string[] names = (string[])p[0].GetValue();
                     Console.WriteLine("{0}", p.ToString());
                     Array.Sort(names, System.StringComparer.Ordinal);
                     Console.WriteLine("\nQueue Names:");
                     for (int i = 0; i < names.Length; i++)
                     {
                        Console.WriteLine("  {0}", names[i].Trim());  // name has trailing spaces
                     }
                     Console.WriteLine();
                  }
               }
            }

         }
         catch (IBM.WMQ.MQException mqex)
         {
            Console.WriteLine("While inquiring queue names, MQ Exception: " + mqex.Message);
         }
         catch (Exception ex1)
         {
            Console.WriteLine("While inquiring queue names, Exception:" + ex1);
         }

      }
   }

}

My code is based on this example: http://cheeso.members.winisp.net/srcview.aspx?dir=MQ&file=Mq.InquireQueueNames.cs
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jan 18, 2012 7:06 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Look at the raw message and the CCSID values in it's header chaining...
If everything is correct there and the pcf agent does not automatically translate... raise a PMR.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Wed Jan 18, 2012 7:24 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Which one is coming out as EBCDIC?

You are
Code:
Console.WriteLine("{0}", p.ToString());

and
Code:
Console.WriteLine("  {0}", names[i].Trim());  // name has trailing spaces


Is it the first one or the second one that's EBCDIC?
Back to top
View user's profile Send private message
JasonE
PostPosted: Wed Jan 18, 2012 7:34 am    Post subject: Reply with quote

Grand Master

Joined: 03 Nov 2003
Posts: 1220
Location: Hursley

I think its a PMR... Looks like (and I could VERY well be wrong) we read the bytes from the message and convert to ascii, ignoring the ccsid of the MQCFST block.... Let me know the number if you raise this.
Back to top
View user's profile Send private message
markt
PostPosted: Wed Jan 18, 2012 8:29 am    Post subject: Reply with quote

Knight

Joined: 14 May 2002
Posts: 508

I don't think the PCF classes in .Net are formally supported. I'm not at all surprised if they don't do the right things to z/OS.
Back to top
View user's profile Send private message
jslansky
PostPosted: Wed Jan 18, 2012 10:55 am    Post subject: Reply with quote

Newbie

Joined: 18 Jan 2012
Posts: 4

mqjeff wrote:
Which one is coming out as EBCDIC?

You are
Code:
Console.WriteLine("{0}", p.ToString());

and
Code:
Console.WriteLine("  {0}", names[i].Trim());  // name has trailing spaces


Is it the first one or the second one that's EBCDIC?


Second one. First was a test I accidentally left in code. Sorry.
Back to top
View user's profile Send private message
jslansky
PostPosted: Wed Jan 18, 2012 10:59 am    Post subject: Reply with quote

Newbie

Joined: 18 Jan 2012
Posts: 4

markt wrote:
I don't think the PCF classes in .Net are formally supported. I'm not at all surprised if they don't do the right things to z/OS.


AFAIK you are right. There is no line about PCF support in official documents and on IBM website. However, it is too difficult for me to try creating PCF message with MQMessage class "manually". So PCFMessage "helper" class was best choice for me.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » .NET PCF API conversion
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.