#1 2015-11-06 17:35:29

fabioxgn
Member
Registered: 2015-11-06
Posts: 34

TServiceCustomAnswer Status is not returned to Delphi client

I have a simple method, like:

  IServerMethods = interface(IInvokable)
    function MyMethod(const data: string): TServiceCustomAnswer;
  end;

The method implementation is like:

try
  SomeMethod();
except
  Result.Content := 'server error';
  Result.Status := HTML_SERVERERROR;
end;

When I use it with a TSQLHttpClient the Status value does not return to the client, the Content and Header is OK, but the Status isn't initialized.

I was expecting that the Status would be returned to the client, so I could use it like:

Response := DoRequest;
if Response.Status = HTML_SERVERERROR then
  ....

Is the Status not expected to be filled on the client? I think it makes sense for it to get to the client, looks like a bug to me.

Offline

#2 2015-11-06 20:55:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,266
Website

Re: TServiceCustomAnswer Status is not returned to Delphi client

If Status is not HTML_SUCCESS (200), then TSQLHttpClient would handle it as an error, and won't execute the method.
Only case where Status is to be used is when you have a non TSQLHttpClient as client (e.g. an AJAX client).

If you want to transmit some data to the TSQLHttpClient instance, you need to include this information into the transmitted binary content.

Offline

Board footer

Powered by FluxBB