RAD Studio for Microsoft .NET
|
RAD Studio web services use the .NET Framework as the services layer. As a consequence, any existing Delphi 7 or earlier web service client applications need to be modified to use the .NET Framework.
This topic includes:
Make the following changes and additions to your applications:
The following notes address discrete issues that you may encounter when porting web service client applications.
Delphi 7 and the .NET SOAP implementations differ slightly. You need to set certain options on the server (TSOAPDomConv.Options property) to succeed in getting multiple clients to work. Set the following options to ensure that both client applications can process the SOAP packages and can transfer the correct encoding:
[soTryAllSchema, soRootRefNodesToBody, soUTF8InHeader, soUTF8EncodeXML]
The following table shows the corresponding exceptions between Delphi 7 and the .NET Framework.
Delphi 7 Exception |
.NET Framework Exception |
ERemotableException |
System.Web.Services.Protocols. SoapException |
ESOAPHTTPException |
System.Net.WebException |
In Delphi 7, the ERemotableException.FaultCode property returns a qualified name, such as SOAP-ENV:Client.Login. You must then extract the code using the ExtractLocalName function. The .NET Framework SoapException class provides the SoapException.Code.Name property directly.
In Delphi 7, the THTTPRIO component provides OnBeforeExecute and OnAfterExecute events, which allow you to monitor requests and responses. You can implement similar functionality using the .NET Framework SoapExtension class. The following is part of an example that implements this functionality. You can find the full example on Borland's CodeCentral. The link is included in the link list at the end of this topic.
uses System.Xml, System.Web.Services, System.Web.Services.Protocols, System.IO; type TSoapMessageEvent = procedure (Sender: TObject; const Xml: string) of object; TSoapMonitor = class(TObject) private FOnRequest: TSoapMessageEvent; FOnResponse: TSoapMessageEvent; protected procedure DoRequest(const Xml: string); procedure DoResponse(const Xml: string); public class function FormatXmlData(const Xml: string): string; static; property OnRequest: TSoapMessageEvent add FOnRequest remove FOnRequest; property OnResponse: TSoapMessageEvent add FOnResponse remove FOnResponse; end; . . . { TSoapMonitor } procedure TSoapMonitor.DoRequest(const Xml: string); begin if Assigned(FOnRequest) then FOnRequest(Self, Xml); end; procedure TSoapMonitor.DoResponse(const Xml: string); begin if Assigned(FOnResponse) then FOnResponse(Self, Xml); end; class function TSoapMonitor.FormatXmlData(const Xml: string): string; var Doc: XmlDocument; Sw: StringWriter; Xw: XmlTextWriter; begin Doc := XmlDocument.Create; Doc.LoadXml(Xml); Sw := StringWriter.Create; Xw := XmlTextWriter.Create(sw); Xw.Formatting := Formatting.Indented; Xw.Indentation := 2; Xw.IndentChar := ' '; doc.Save(xw); Result := sw.ToString; Xw.Close; Sw.Close; end;
In Delphi 7, you are required to send the header before every method call. The header object is freed after the call. In the .NET Framework, the header class persists after calling a method, until new is assigned, or until the header class is cleared by assigning nil.
The .NET Framework does not support MIME attachments. Delphi 7 SOAP does not support DIME attachments.
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|