Skip to Content
0

c# AdapterMessageMonitoringVi GetMessageList Syntax

Sep 13, 2017 at 12:41 PM

78

avatar image
Former Member

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

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

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

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Alexander!

I believe the best practise would be to post the solution here, right in your answer. Especially, if you gonna mark it as Best answer.

Regards, Evgeniy.

0
Former Member

Hi Evgeniy,

my solution is more comprehensive than thought, so i have chosen this path.

If someone has a question or need help, i will gladly help.

best regards,

Alex

0
Former Member

Alex, I really need your help, I'm running exactly your code and always I get 0 form response.

Can you help me please. I didn't get with the error.

0
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

0