Advice for viewing logs in web service call responses

I’m not sure how to see log statements in an Http Response or completion method. I imagine the problem could be that these Log statements are part of another thread(?), but I’m not sure what to do resolve it.

Here’s my test project, indicating a “successful” result for my test. I actually gave it a bogus url, and want to see the expected failure response.

MPhttpRO 3.zip (2.4 MB)

Hmm. All logs should show in the console, regardless what thread they are on. Let me have a loony at your project…

It looks ike you are using asynchronous code in a synchronous context — your test just fires off to getUser, which initiated an async HTTP request (to be called back later), and then moves on.

Since you just have the one test, chances are the test completes and the executable is done, long before there HTTP request had a chance to complete. You cannot test async code in that way.

There’s two ways to solve this. well three. One is to use sync code (Http.ExecuteRequestSynchronous). The other is to wait and let the request complete before terminating the test. This could be achieved by using an Event that gets triggered by the successfully completed request and gets waited for in the test or (less ideal and a hack, but easier for a simple test) by just putting the main/test thread to sleep for a time sufficient enough for the request to finish.

For example, simply putting a

    ccws.getUser(email, host, gotUser.completion);
    Thread.Sleep(30000);

I see this log output:

errorInGetUser=java.net.ProtocolException: cannot write to a URLConnection if doOutput=false - call setDoOutput(true)
postString=data={"email":"d*m"}
getUser Failed: 

Which seems to be an Elements RTL bug; fixed in the attached version (same steps as earlier to use it). now I get:

errorInGetUser=RemObjects.Elements.RTL.HttpException: Unable to complete request, error code: 403
postString=data={"email":"d***m"}
getUser Failed: 

which AFAICT is valid, as its an actual server response

elements.jar 2.zip (546.8 KB)

Tried following the same steps as before with the latest elements.jar file, but got a different result. It added another reference instead of replacing the earlier one. Not sure, but I think the small “e” vs. capitalized “E’” in Elements may also be involved. I’ve tried undoing and retrying, but I’ve ended up with a mess.

That’s the same issue with the case mismatch as yesterday. You’ll need to manually fix the case to match, or (better) get the new .2565 build that’s out now that has my fix for that.