Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to send XML to SOAP server w. no encoding?

668 views
Skip to first unread message

Helmut Scheck

unread,
Dec 30, 2003, 5:18:24 PM12/30/03
to
Hello,

I need to send a XML string to a SOAP server but Delphi (6) encode the XML
string which is not good. I have no control on the server so I must send
string. Is this possible to do with Delphi SOAP? Maybe used another datatype
for string?

Thanks.


Grahame Grieve

unread,
Jan 5, 2004, 3:18:19 AM1/5/04
to
Helmut Scheck wrote:

I don't think that what you want to do is possible in
Delphi Soap.

You can do it it IndySoap - but it's not easy. There
is many problems relating to mixing DOM's, object ownership,
character sets, and schema declarations.

Grahame

Hank Scheck

unread,
Jan 7, 2004, 9:00:32 AM1/7/04
to
Thanks Grahame. I finally got it to work by handling HTTTRIOs BeforeExecute
event and replacing SOAPRequest with the XML content sandwiched between
hardcoded SOAP envelope. It's not terribly ugly - less than 10 lines of
code - but not pretty either, and it works (don't try this at home).

Normally I would expect the server to handle the encoding. The server is
using an AXIS implementation and expects document/literal encoding which
Delphi probably cannot handle even when I set the soDocument flag - Delphi
simply encodes the content anyway. I could be wrong about the reason bit
without the workaround it wouldn't work.


Anthony Jowers

unread,
Jun 18, 2004, 10:08:27 AM6/18/04
to
Hank,
Was it neccessary to modify the HTTPRIO component code that invokes
FOnBeforeExecute and returns a var "SoapRequest" such that this string is
pushed back into the Request Stream in D6 ? Under Delphi7 I have the same
exact problem and attempted to solve it in the BeforeExecute as well. Thats
when I found the the component itself has a bug in it.

I made changes to the HTTPRIO source to push the modified SoapRequest string
back into the request. My changes looked like this: (is there a better
way?)

procedure TRIO.DoBeforeExecute(const MethodName: string; Request: TStream);
var
StrStrm: TStringStream;
ReqW: WideString;
s : String;
begin
if Assigned(FOnBeforeExecute) then
begin
{ Ideally we would change the signature of this event to take a Stream.
The change to stream was necessary for attachment and encoding
support.
And it makes the event consistent.... However, for the sake of
backward compatibility.... }
StrStrm := TStringStream.Create('');
try
StrStrm.CopyFrom(Request, 0);
Request.Position := 0;
ReqW := StrStrm.DataString;

FOnBeforeExecute(MethodName, ReqW);

// my changes start here.....................
s := ReqW ;
Request.Size := Length(s);
Request.Seek(0,0);
Request.Write( PChar(s)^, Length(s));
Request.Seek(0,0);
Request.Position := 0;
finally
StrStrm.Free;
end;
{ NOTE: We ignore the var WideString passed in... ???? }
end;
end;


In my calling code, I call the service and pass "XML" as the parameter...
something like:

lookupservice := HTTPRIO1 as lookupservicesoap;

memo1.Lines.text := lookupservice.ProcessNameListMessage( 'XML' ) ;


then in the before execute I used replace the "XML" with the actual
parameter, thus avoiding the encoding....

SoapRequest := AnsiReplaceText( SoapRequest, 'XML', XmlNodesListString );

Thanks,
AJ

"Hank Scheck" <nos...@icc.com> wrote in message
news:3ffc1084$1...@newsgroups.borland.com...

0 new messages