none
How to deserialize WCF Queue Entries using commas for field delimeters RRS feed

  • Question

  • Thank you Edward for helping me enumerate the WCF/MSMQ queue entries

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/dbf49393-2d9e-4657-90ab-5d1ee7269f3b/how-to-write-cwpfwcf-client-to-display-entries-in-wcfmsmq-queue?forum=wcf

    Here are the results I get when running your code:

    export PATH=$PATH:/usr/bin:/cygdrive/c/Perl64/site/bin:/cygdrive/c/Perl64/bin:$(/usr/bin/cygpath -u $USERPROFILE)/Documents/bin; sleep 65; ls -ltr ^>^> $USERPROFILE/Documents/logs/Test.logtruefalsefalsefalseWinOOPC:\Users\shein\Documents\logs\TestDefault.logC:\Users\shein\Documents\WinOOP23
    export PATH=$PATH:/usr/bin:/cygdrive/c/Perl64/site/bin:/cygdrive/c/Perl64/bin:$(/usr/bin/cygpath -u $USERPROFILE)/Documents/bin; sleep 65; ls -ltr ^>^> $USERPROFILE/Documents/logs/Test.logtruefalsefalsefalseWinOOPC:\Users\shein\Documents\logs\TestDefault.logC:\Users\shein\Documents\WinOOP24
    export PATH=$PATH:/usr/bin:/cygdrive/c/Perl64/site/bin:/cygdrive/c/Perl64/bin:$(/usr/bin/cygpath -u $USERPROFILE)/Documents/bin; sleep 65; ls -ltr ^>^> $USERPROFILE/Documents/logs/Test.logtruefalsefalsefalseWinOOPC:\Users\shein\Documents\logs\TestDefault.logC:\Users\shein\Documents\WinOOP25

    Basically I queued up a few entries with a sleep of 65 seconds and used linqpad to run Edward's code to deserialize/serialize the the entries. Here is my actual C# Interface (I've enhanced it a bit):

    namespace MSMQNoSecurityService
    {
    
        [ServiceContract]
        public interface IMSMQService
        {
            /// <summary>
            /// 
            /// </summary>
            /// <param name="command">Command to execute using cmd.exe or cygwin bash</param>
            /// <param name="cygwin">Use cygwin bash?</param>
            /// <param name="admin">Execute in elevated privledge mode</param>
            /// <param name="impersonate">Use the WCF impersonation feature</param>
            /// <param name="loadEnvironmentVariablesFromEmacs">Parse the .emacs file in c:\cygwin64\home\[alias]\.emacs</param>
            /// <param name="jobName">Name used for display</param>
            /// <param name="logfile">Default log file</param>
            /// <param name="workingDirectory">Default directory</param>
            /// <param name="environmentVariables"></param>
            /// <param name="jobId">integer index from job queue table or unique job GUID</param>
            [OperationContract(IsOneWay = true)]
            void ShellCommand(string command, bool cygwin, bool admin, bool impersonate, bool loadEnvironmentVariablesFromEmacs, string jobName, string logfile, string workingDirectory, System.Collections.Generic.Dictionary<string,string> environmentVariables, Object jobId);
        }
    }

    So this is progress.... I thought it was going to be easy to discern the different fields! But I'm not finding it obvious! So my requests are:

    (1) Presently the deserialization/serialization is just jamming all the fields together and I need some indication of where one field (parameter) ends and the next one starts.

    (2) Hmmm.... that double left shift operator that both CMD.EXE and bash use to redirect standard output to the end of a file has been escaped with a carrot ("^")! Hmmm... Is "^" the escape character? So we are not completely decoded yet. Is it simply a matter of removing all the carrots except when there are two carrots in succession in which case I only remove the first one?

    Thank you!

    siegfried


    siegfried heintze

    Thursday, March 23, 2017 2:48 PM

Answers

  • >> Presently the deserialization/serialization is just jamming all the fields together and I need some indication of where one field (parameter) ends and the next one starts.

    To get every field and value, I suggest you try “result.InnerXml”.

                System.Messaging.MessageQueue[] queueList = System.Messaging.MessageQueue.GetPrivateQueuesByMachine(Environment.MachineName);
                MessageQueue myQueue = queueList[1];
                List<System.Messaging.Message> messages = myQueue.GetAllMessages().ToList();
                foreach (System.Messaging.Message message in messages)
                {
                    System.Xml.XmlDocument result = ConvertToXMLDoc(message);     
                    MessageBox.Show(result.InnerXml);
                }



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by siegfried_ Tuesday, March 28, 2017 4:39 AM
    Friday, March 24, 2017 3:07 AM