Skip to Content
avatar image
Former Member

c# AdapterMessageMonitoringVi GetMessageList Syntax

Hi Experts,

i need your help. I use this blog Reading Messages from PI System to read all Messages from PI with a c# application.

at the moment i can read a single message by using getMessageByteJavaLangStringBooloean and the messagekey

var base64 = client.getMessageBytesJavaLangStringBoolean(MessageKey, false);

But when i try to get the whole message list i get no respone from PI

this is my code

            BasicHttpBinding binding = new BasicHttpBinding();


            binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;


            EndpointAddress endpoint = new EndpointAddress("http://sapq13:50000/AdapterMessageMonitoring/basic?style=document");
            AdapterMessageMonitoringViClient client = new AdapterMessageMonitoringViClient(binding, endpoint);


            client.ClientCredentials.UserName.UserName = "";
            client.ClientCredentials.UserName.Password = "";


            AdapterFilter filter = new AdapterFilter()
            {
                archive = false,
                dateType = 0,
                nodeId = 0,
                onlyFaultyMessages = false,
                retries = 0,
                retryInterval = 0,
                timesFailed = 0,
                wasEdited = false
            };


            getMessageListResponse resp = new getMessageListResponse(client.getMessageList(filter, 1));
            AdapterFrameworkData da = new AdapterFrameworkData(resp.Response);

can someone help me?

Regards,

Alex

debug.png (19.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Sep 14, 2017 at 11:16 AM

    i solved the problem, if someone has a question feel free to ask me

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Victor,

      yes the code was broken, now i used this one here.

      BasicHttpBinding binding = new BasicHttpBinding();
      String MessageKey = @"your Messagekey like this \OUTBOUND\<culster node>\<SID>\0\";
      binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
      binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
      binding.MaxReceivedMessageSize = maxSize;
      EndpointAddress endpoint = new EndpointAddress(url);
      AdapterMessageMonitoringViClient client = new AdapterMessageMonitoringViClient(binding, endpoint);
      
      
      client.ClientCredentials.UserName.UserName = "User";
      client.ClientCredentials.UserName.Password = "Password";
      
      
      //Returns byte array
      var base64 = client.getMessageBytesJavaLangStringBoolean(messageFromCell + MessageKey, false);
      // From byte array to string
      string s = System.Text.Encoding.UTF8.GetString(base64, 0, base64.Length);
      
      
      //Remove PI Conten from Message
      String Message = SplitString(s);
      XDocument xDocument = XDocument.Parse(Message);
      

      Regards,

      Alex