IndyHTTP-Post get only WDSL in WebBrowser

Hi, after yesterdays improvement most topic are clear for me.

We habe an AppServer for internal interfaces using TCP, which is working well now. Furthermore the same AppServer is using another WebService (using ROIndyHTTPServer). In the interface is a “Monitor”-function, which gets a HTML-page. Unfortunatly this interface is not usable in my WebBrowser (e.g. Firefox);instead the WSDL is shown instead (I’ve unchecked the “ServeRodl” already).

Any ideas?
Thanks,
Peter

what message you are using? TROSOAPMessage?
how are you trying to call monitor function?

I’ve used in old version ROPostMessage, and I did not change it.
I call the Monitor-function in my Browser.

can you check that another WebService (using ROIndyHTTPServer) has TROPostMessage as dispatcher? if WSDL is shown it indicates that SOAP message is used…

I’ve created the ROIndyHTTPServer again and set the Dispatcher to ROPostMessage. In the project there is no TROSOAPMessage.

If I set ROIndyHTTPServer:ServeRodl, I get the WSDL; if I unset it, I get a “Invalid Path” in the Browser.

I can’t reproduce problem with TROPostMessage in MegaDemo sample.

steps:

  • update server-side as:
TMegaDemoServerMainForm.ROPostMessage.MultiLine := false
  • test TROPostMessage with this file: test.htm (1.6 KB)

I’ve tried the MegaDemo, and it’s the same -->
when I open the Browser (Firefox) without function, I get the WDSL. If I try a function (e.g. GetServerTime), I get “Invalid Path” like in my project

have you tried to use my .htm?
it sends

__MessageType=Message&__InterfaceName=MegaDemoService&__MessageName=GetServerTime&__ClientID=B51199FE-9E86-4AA1-8CB1-54B4E05AB130&Submit=Submit

to http://localhost:8099/post and recieves response like

__MessageType=Message&__InterfaceName=MegaDemoService&__MessageName=GetServerTimeResponse&__ClientID=B51199FE-9E86-4AA1-8CB1-54B4E05AB130&"Result=2015-07-17
 10:53:48"

I don’t know, what I should try …

How to use the .htm-file?
In the sample or my project?

from your post:

you wanted to receive results in browser so launch MegaDemo sample and open attached .htm in Firefox

I get an excpetion -->

__MessageType=Exception __ExceptionClass=EROException __ExceptionMessage=Unknown message type “Message&__InterfaceName=MegaDemoService&__MessageName=GetServerTime&__ClientID=B51199FE-9E86-4AA1-8CB1-54B4E05AB130&Submit=Submit” __Exception=EROException

have you updated server-side?

Ok, it’s working now …

This means, that I must change all interfaces to envlop in all detailled stuff (like __MessageType, __InterfaceName, …)?

you can

  • change all interfaces to envlop in all detailled stuff (like __MessageType, __InterfaceName, …)
    or
  • use OnCustomResponseEvent, something like
TMegaDemoServerMainForm = class(TForm)
..
  procedure ROServerCustomResponseEvent(
    const aTransport: IROHTTPTransport; const aRequestStream,
    aResponseStream: TStream; const aResponse: IROHTTPResponse;
    var aHandled: Boolean);

....

procedure TMegaDemoServerMainForm.FormCreate(Sender: TObject);
...
  ROIndyHTTPServer := TROIndyHTTPServer.Create(Self);
  ROIndyHTTPServer.OnCustomResponseEvent := ROServerCustomResponseEvent;  //added

...
procedure TMegaDemoServerMainForm.ROServerCustomResponseEvent(
  const aTransport: IROHTTPTransport; const aRequestStream,
  aResponseStream: TStream; const aResponse: IROHTTPResponse;
  var aHandled: Boolean);
var
  lMessage:  IROMessage;
  op: TROResponseOptions;
  s: ansistring;
begin
  if pos('/xxxx',aTransport.PathInfo) = 1 then begin  // "xxxx" shouldn't be defined in Server.Dispathers
    SetLength(s, aRequestStream.Size);
    aResponseStream.Position := 0;
    aRequestStream.Read(Pointer(s)^, Length(s));
    s := '__MessageType=Message&__InterfaceName=MegaDemoService&'+s;
    aRequestStream.Size := 0;
    aRequestStream.Write(Pointer(s)^, Length(s));

    lMessage:= (ROPOSTMessage as IROMessageCloneable).Clone;
    MainProcessMessage(lMessage,atransport,aRequestStream,aResponseStream,op);
    aHandled := True;
  end;
end;

in this case, .html can pass only __MessageName:

<html><body><form method="POST" action="http://localhost:8099/xxxx">
__MessageName:<input type="text" name="__MessageName" size="45" value="GetServerTime">
<input type="submit">
</form></body></html>

Evgeny,
I’ve still problems …

How to start MegaDemo (GetServerTime) in the URL?

I’ve tried -->
http://localhost:8099/post?__MessageType=Message&__InterfaceName=MegaDemoService&__MessageName=GetServerTime&__ClientId=b51199fe-9e86-4aa1-8cb1-54b4e05ab130

… but I get the WSDL again.

And in our project, we mask (envelop) the messages in ROPostMessageReadFromStream; I think, that sure also work. But I’ll get only “Invalid Path” when I try the Monitor-function. (I’ve tried your solition, but the result is the same …)

Any ideas?

Bye,
Peter

ROSDK supports only POST method instead of GET by default. however you can change this behavior with OnCustomResponseEvent.

update MegaDemoServerMain.pas as

procedure TMegaDemoServerMainForm.ROServerCustomResponseEvent(
  const aTransport: IROHTTPTransport; const aRequestStream,
  aResponseStream: TStream; const aResponse: IROHTTPResponse;
  var aHandled: Boolean);
var
  lMessage:  IROMessage;
  op: TROResponseOptions;
  s: ansistring;
begin
  if pos('/xxxx',aTransport.PathInfo) = 1 then begin  // "xxxx" shouldn't be defined in Server.Dispathers
    s := aTransport.QueryString;
    aRequestStream.Size := 0;
    aRequestStream.Write(Pointer(s)^, Length(s));

    lMessage:= (ROPOSTMessage as IROMessageCloneable).Clone;
    MainProcessMessage(lMessage,atransport,aRequestStream,aResponseStream,op);
    aHandled := True;
  end;
end;

note: this update requires another changes from my earlier post.

after this fix, you can use
http://localhost:8099/xxxx?__MessageType=Message&__InterfaceName=MegaDemoService&__MessageName=GetServerTime&__ClientId=b51199fe-9e86-4aa1-8cb1-54b4e05ab131

Mmmh,
when I update the sample, I’ll get an error in Browser -->

__MessageType=Exception
__ExceptionClass=EROException
__ExceptionMessage=Unknown message type
"Message&__InterfaceName=MegaDemoService&__MessageName=GetServerTime&__ClientId=b51199fe-9e86-4aa1-8cb1-54b4e05ab131"
__Exception=EROException

Could you please post the final unit (MegaDemoServerMain.pas) ?

Bye,
Peter

MegaDemoServerMain.zip (8.5 KB)

How to open/download the zip?

try again