Author |
Message
|
jslansky |
Posted: Wed Jan 18, 2012 1:38 am Post subject: .NET PCF API conversion |
|
|
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 |
|
 |
JasonE |
Posted: Wed Jan 18, 2012 4:41 am Post subject: |
|
|
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 |
|
 |
jslansky |
Posted: Wed Jan 18, 2012 4:47 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Wed Jan 18, 2012 7:06 am Post subject: |
|
|
 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 |
|
 |
mqjeff |
Posted: Wed Jan 18, 2012 7:24 am Post subject: |
|
|
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 |
|
 |
JasonE |
Posted: Wed Jan 18, 2012 7:34 am Post subject: |
|
|
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 |
|
 |
markt |
Posted: Wed Jan 18, 2012 8:29 am Post subject: |
|
|
 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 |
|
 |
jslansky |
Posted: Wed Jan 18, 2012 10:55 am Post subject: |
|
|
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 |
|
 |
jslansky |
Posted: Wed Jan 18, 2012 10:59 am Post subject: |
|
|
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 |
|
 |
|