As the default transport for SOAP is HTTP, I thought I'd build a test bed on
Indy's HTTP server. The reason being I want to be able to build a standalone
server (ie not rely on IIS etc).
Part of the behaviour of the SOAP support I'm building is to "tear out" the
SOAP packet from the HTTP request. I'm so used to building web apps using
WebBroker, I've been totally shielded from what's in an HTTP request, and
I'm lost as to which property of TIdRequestInfo I can use to do it.
Any help appreciated.
--
Dave Nottage
Pure Software Technology
(I know nothing about SOAP, so I was inclined to answer "set Content-Type to
text\soap and stream the soap stuff in the content part" but that is
probably dead wrong)
--
Rune
Not WebBroker specifically, however a SOAP packet in an HTTP request is
supposed to look like this:
POST /StockQuote HTTP/1.1
Host:
www.stockquoteserver.com
Content-Type: text/xml;
charset="utf-8"
Content-Length: nnnn
SOAPAction:
"Some-URI"
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetLastTradePrice xmlns:m="Some-URI">
<symbol>DIS</symbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The part I'm interested in that is passed to the SOAP implementation from
the HTTP server is where the
<SOAP-ENV:Envelope
...starts, including all the rest. The example is from:
http://msdn.microsoft.com/xml/general/soapspec.asp
...which I recommend reading.
> (I know nothing about SOAP, so I was inclined to answer "set Content-Type
to
> text\soap and stream the soap stuff in the content part" but that is
> probably dead wrong)
Yes, the content type (as you can see) is text/xml. I'm working on the
server side first because I thought it would be the "make-or-break" for me,
and also because the client can originate from a client that I didnt build
(part of the beauty of SOAP).
Again, thanks for any help
Interesting, I'll have to take a look at that when I have more time...
(I'm trying to get a couple of fixes and facelifts in before 8.0.12B now
that Kudzu fixed the functionality failure observed in 11B)
However, I believe your example translates into:
procedure TfmHTTPServerMain.ServeSoap(AThread: TIdPeerThread;
RequestInfo: TIdHTTPRequestInfo; ResponseInfo: TIdHTTPResponseInfo);
begin
ResponseInfo.Headers.Values['SOAPAction:'] := '"SomeURI"';
ResponseInfo.ContentType := 'text/xml;';
ResponseInfo.ContentText := '<SOAP-ENV:Envelope'#13#10 +
'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"'#13#10 +
'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'#13#10
+
'<SOAP-ENV:Body>'#13#10 +
' <m:GetLastTradePrice xmlns:m="Some-URI">'#13#10 +
' <symbol>DIS</symbol>'#13#10 +
' </m:GetLastTradePrice>'#13#10 +
'</SOAP-ENV:Body>'#13#10 +
'</SOAP-ENV:Envelope>'#13#10;
end;
Just insert
if Pos('/soap', LowerCase(RequestInfo.Document)) = 1 then
ServeSoap(AThread, RequestInfo, ResponseInfo)
else
in the HTTP server demo's HTTPServerCommandGet method (right before "if
(Pos('/session',...").
I ran a quick test, and Internet Explorer seems happy.
http://localhost/soap executes the ServeSoap method.
Oh, Indy could do with a good SOAP example, so if you feel the urge,
don't hesitate to join the Indy Demos squad... ;-)
HTH.
--
Rune
Actually, your example has it completely back to front (it's an HTTP
request, and therefore the client generates it, the server needs to
interpret it), however I appreciate the effort, and if you follow the
internet.isapi-webbroker group, you'll see I've worked it out.
> Oh, Indy could do with a good SOAP example, so if you feel the urge,
> don't hesitate to join the Indy Demos squad... ;-)
Will do.