NetTalk Central

Author Topic: Accessing variables from MAIN in a Servicemethod  (Read 6012 times)

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Accessing variables from MAIN in a Servicemethod
« on: July 21, 2017, 01:07:26 AM »
Hello Bruce and all others,

the Webserver has all those pretty values in the WebPerfomance GROUP shown on the window of my server, however, when run as a Service, I can't make any use of them. my question now is, how can I access those variables in MAIN from inside a Servicemethos, so that I can send them back as return values or alternatively make an HTML-page from those performance data?

Thanks in advance
Wolfgang

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: Accessing variables from MAIN in a Servicemethod
« Reply #1 on: July 21, 2017, 07:32:13 AM »
Wolfgang, there is indeed a hidden gem in example 34 Calculator (34). When you open the example there is a Performance (NetWebForm) procedure that is not available by the menu options when you compile but, if you write /Performance (after the URL) you see something like the image below.

Hope this helps.

Cheers @ Urayoan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: Accessing variables from MAIN in a Servicemethod
« Reply #2 on: July 21, 2017, 09:15:43 PM »
Example 34 !! Thanks Ura.
I knew I did it for one of the examples, but I couldn't remember which one.

I need to update it though so it uses websockets rather than a timer...

cheers
Bruce

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: Accessing variables from MAIN in a Servicemethod
« Reply #3 on: July 23, 2017, 09:46:28 AM »
Great tip, urayoan!

Works perfect!

On the Server-side (SOAP), I put this into the Embed "ServiceMethod":

    WebPerformance = p_web.RequestData.Webserver.Performance

where WebPerformance is a defined GROUP, which is my ReturnValue.

On the Client-side I do a simple WebClient.POST() and in WebClient.Pagereceived I wrote this:

    xmlPerformanceData.load(WebPerformance ,self.page, len(clip(self.page)), '', 'WebPerformance')

For anyone, who wants to do the same, here is the GROUP:
Code: [Select]
WebPerformance  GROUP,PRE(wp)
StartDateA        LONG,NAME('StartDateA')
StartTimeA        LONG,NAME('StartTimeA')
NumberOfRequests  LONG,NAME('NumberOfRequests')
NumberOfSpiderRequests LONG,NAME('NumberOfSpiderRequests')
NumberOf404Requests LONG,NAME('NumberOfSpiderRequests')
NumberOf500Requests LONG,NAME('NumberOf404Requests')
TotalRequestTime  REAL,NAME('TotalRequestTime')
NumberOfRequestsLTHalf LONG,NAME('NumberOfRequestsLTHalf')
NumberOfRequestsLTOne LONG,NAME('NumberOfRequestsLTOne')
NumberOfRequestsLTTwo LONG,NAME('NumberOfRequestsLTTwo')
NumberOfRequestsLTFive LONG,NAME('NumberOfRequestsLTFive')
NumberOfRequestsGTFive LONG,NAME('NumberOfRequestsGTFive')
RequestTimeLTHalf REAL,NAME('RequestTimeLTHalf')
RequestTimeLTOne  REAL,NAME('RequestTimeLTOne')
RequestTimeLTTwo  REAL,NAME('RequestTimeLTOne')
RequestTimeLTFive REAL,NAME('RequestTimeLTFive')
RequestTimeGTFive REAL,NAME('RequestTimeGTFive')
AverageRequestTimeLTHalf REAL,NAME('AverageRequestTimeLTHalf')
AverageRequestTimeLTOne REAL,NAME('AverageRequestTimeLTOne')
AverageRequestTimeLTTwo REAL,NAME('AverageRequestTimeLTTwo')
AverageRequestTimeLTFive REAL,NAME('AverageRequestTimeLTFive')
AverageRequestTimeGTFive REAL,NAME('AverageRequestTimeGTFive')
MaximumThreads    LONG,NAME('MaximumThreads')
MaximumSessions   LONG,NAME('MaximumSessions')
MaximumSessionData LONG,NAME('MaximumSessionData')
MaximumThreadPool LONG,NAME('MaximumThreadPool')
NumberOfSessions  LONG,NAME('NumberOfSessions')
NumberOfSessionData LONG,NAME('NumberOfSessionData')
NumberOfThreads   LONG,NAME('NumberOfThreads')
NumberOfThreadPool LONG,NAME('NumberOfThreadPool')
                END

You can simply copy and paste it either into the DATA-Embed or directly into the DATA-PAD, if you prefer.

Thanks again!

bye
Wolfgang

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: Accessing variables from MAIN in a Servicemethod
« Reply #4 on: July 24, 2017, 10:39:27 AM »
Nice! Thank you Wolfgang

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: Accessing variables from MAIN in a Servicemethod
« Reply #5 on: July 24, 2017, 10:41:03 AM »
Example 34 !! Thanks Ura.
I knew I did it for one of the examples, but I couldn't remember which one.

I need to update it though so it uses websockets rather than a timer...

cheers
Bruce


That would be great Bruce. Cheers!