case studies white papers downloads technology process careers sitemap contact
about us products solutions domains services projects search clients
Technical papers

 

 

SOAP And Web Services


Page 3 of 4
 

Debugging SOAP Data


Abstract
This article shows you how you can see the SOAP data passed from and to your SOAP application (Delphi 6 Enterprise).

Introduction
I assume you already know how this SOAP business works, and how to write your basic SOAP server, your basic SOAP client etc. But let's say you're foxed about certain things, and you need to see the SOAP packet being passed from and to your application. I'm assuming that you're building a SOAP client in Delphi, and you're connecting to some SOAP server - which is potentially somewhere "out there". I will proceed to discuss TWO ways to get to the SOAP packets.

1) Using ProxyTrace: First, get ProxyTrace from http://www.4s4c.com/tcptrace/pt.asp. Now, run it, on say port 8080 (which is the default). Then, simply go to Delphi and set your HTTPRio's HTTPWebNode.Proxy property to "localhost:8080". Like this:

Note: If you're running Delphi 7 with Indy, you need to set the proxy to “http://localhost:8080" or Indy won't be able to parse the text properly. Thanks to Joe Rykowski for this tip.

Run your application and you can actually see the data going back and forth like this:

Of course, remember to remove that proxy setting when you're done with your testing, or your application will refuse to work if the proxy isn't running.

2) From within Delphi: "No", you say, "I want to manipulate the actual data sent and received". Well, after you apply Update Pack 2, you have an easy way to do this. Update Pack 2 is available at http://www.borland.com/delphi/webreg/d6/d6_registeredusers.asp.

You can use the events BeforeExecute and AfterExecute to do what you want:

 

procedure TForm1.HTTPRIO1BeforeExecute(const MethodName: String;
 var SOAPRequest: WideString);
begin
 Memo1.Lines.Text := SoapRequest;
end;
procedure TForm1.HTTPRIO1AfterExecute(const MethodName: String;
  SOAPResponse: TStream);
begin
  SoapResponse.Position := 0;
  Memo2.Lines.LoadFromStream(Soapresponse);
end;

Points to be noted:

1) The BeforeExecute gives you a string, the AfterExecute gives you a Stream. (Note: I do not make the rules)

2) In the AfterExecute we have to set the SoapResponse.Position to 0. When you get this stream, it's currently positioned at the end of the stream. I expect this to be fixed in the next service release, but no big deal for us really.
This should be even more clear from this source code at http://www.agnisoft.com/download (ReqResp.zip)

-------------------------------------------------------------------------------------------------------

Page 3 of 4
 

 

© 1998-2012, Agni Software (P) Ltd. All Rights reserved.