cancel
Showing results for 
Search instead for 
Did you mean: 

c# AdapterMessageMonitoringVi GetMessageList Syntax

AlexanderApel
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

AlexanderApel
Participant
0 Kudos

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

former_member190293
Active Contributor
0 Kudos

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.

AlexanderApel
Participant
0 Kudos

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

Former Member
0 Kudos

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.

AlexanderApel
Participant
0 Kudos

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

Answers (0)