You should also at least be implementing the Error event, in case something is going wrong. For diagnostic purposes, I’d suggest implementing:
AuthenticationRequired (in case it’s requesting a username & password)
HeadersReceived (perhaps you’re getting a HTTP status with no content)
[quote=410094:@Paul Lefebvre]On Windows, I just put a Xojo.Net.HTTPSocket on a page and called the Eddie’s Electronics web service with it from a button using this code:
It can be convenient to put the socket on the page as its events will have access to page methods and properties.
If you create your socket in code using New then you’d want to make sure the socket does not go out of scope so it should probably be a property of the page.
I just tried both these methods and they worked fine.
I’m not able to intercept the result from the PageReceived event.
I call a WebService using Xojo.Net.HttpSocket inside a webcontainer and, following the flow with the debugger, the PageReceived event ends with the expected result (e.g., an array that I have also tried to save in a webcontainer property ).
But, when I try to use the data in the webcontainer, I get NilObjectException.
I understand this depends on the asynchronous execution of the socket, but I’m not able to solve my problem.
[quote=410662:@natale pappalardo]I’m not able to intercept the result from the PageReceived event.
I call a WebService using Xojo.Net.HttpSocket inside a webcontainer and, following the flow with the debugger, the PageReceived event ends with the expected result (e.g., an array that I have also tried to save in a webcontainer property ).
But, when I try to use the data in the webcontainer, I get NilObjectException.
I understand this depends on the asynchronous execution of the socket, but I’m not able to solve my problem.
Can someone insert an example that can help me?[/quote]
So the debugger stops and tells you where the exception is and looking at the debugger variables can you tell which one you are using is nil?
[quote=410928:@natale pappalardo]While b = False
If ar.Ubound > -1 Then b = True
Wend[/quote]
Because of this…
While b = False
If ar.Ubound > -1 Then b = True
Wend
Thats a tight loop that doesnt yield the current thread. Now, you could yield the thread, but you must consider that you may end up with a thread context change. You wont see the problems unless you are running more than one session and the likelihood of problems goes up with every additional user.
While b = False
If ar.Ubound > -1 Then b = True
Wend
Thats a tight loop that doesnt yield the current thread. Now, you could yield the thread, but you must consider that you may end up with a thread context change. You wont see the problems unless you are running more than one session and the likelihood of problems goes up with every additional user.[/quote]
thanks for the clarification.
but how can I intercept, in a webpage, the result of the socket PageReceived event, before the program flow proceeds with the following instructions?
[quote=410948:@natale pappalardo]thanks for the clarification.
but how can I intercept, in a webpage, the result of the socket PageReceived event, before the program flow proceeds with the following instructions?[/quote]
Well… the correct answer here is that you shouldnt. The problem with doing it this way is that you run the real risk of locking up your entire app for 30 seconds if the server you are calling doesnt respond.
The correct way to do this is to implement the PageReceived event and finish your processing there. The thing to remember is that asynchronous events from things like sockets and timers (where the responses always come later) all fire on the main thread. That is, when the event fires the framework cant tell which session made the request. You will have to keep track of that and then set up a SessionContext object before trying to access any session specific data.