Borland released the second patch for C ++ Builder 6 and Delphi 6. This is a very important patch for Delphi 6. It not only fixes some problems in Delphi 6, but also greatly enhances the functions of Delphi 6, especially in soap/Web service development. A new web service page, compared with the previous one before patching (see "Delphi 6 preemptive research-one of bizsnap/soap/WebService-A Hello world! In addition to replacing all the icons (now the same as C ++ Builder 6), the SOAP server interface wizard is added, this is a wizard for creating a SOAP server interface. In the previous introduction, creating a SOAP server interface requires a lot of code. With this wizard, you can save a lot of trouble. With the SOAP server interface wizard, when creating a Web service application, you are automatically asked whether a server interface is generated, for example. In addition to using soap for multi-layer application development, APIs must be created. The wizard dialog box for creating a server interface is shown in. Follow the tutorial in Delphi 6-one of bizsnap/soap/WebService-A Hello world! Create a soaphello interface, enter soaphello in the service name, and confirm the interface to generate two units: soaphellointf. PAS and soaphelloimpl. pas, respectively, the interface definition and interface Implementation Unit for this interface. The content of the soaphellointf. Pas unit is as follows: { Invokable interface ISoapHello }
unit SoapHelloIntf;
interface
uses InvokeRegistry, Types, XSBuiltIns;
type
{ Invokable interfaces must derive from IInvokable } ISoapHello = interface(IInvokable) ['{3A9E6BD6-F128-40AD-B9F1-FB254C463CCC}']
{ Methods of Invokable interface must not use the default } { calling convention; stdcall is recommended } end;
implementation
initialization { Invokable interfaces must be registered } InvRegistry.RegisterInterface(TypeInfo(ISoapHello));
end.
The content of the soaphelloimpl. Pas unit is as follows: { Invokable implementation File for TSoapHello which implements ISoapHello }
unit SoapHelloImpl;
interface
uses InvokeRegistry, Types, XSBuiltIns, SoapHelloIntf;
type
{ TSoapHello } TSoapHello = class(TInvokableClass, ISoapHello) public end;
implementation
initialization { Invokable classes must be registered } InvRegistry.RegisterInvokableClass(TSoapHello);
end.
Then, you only need to add the definition and implementation of the required interface methods to the two units to complete a server interface, which is much more convenient than the original one. This is only a surface change. In the first example in this chapter, if you enter http: // localhost/soap/soaptest. DLL cannot see anything. You must enter http: // localhost/soap/soaptest. dll/WSDL to view the WSDL list of all interfaces. However, after the Delphi 6 patch 2 is installed, re-compile this subroutine. You can see http: // localhost/soap/soaptest. DLL displays a beautiful page, similar to soap development with visual studio.net. The http: // localhost/soap/soaptest. dll/WSDL page is also different from the original one. However, this is not the most important change. Let's look at http: // localhost/soap/soaptest. the dll/WSDL/isoaphello page has some slight changes compared with the preceding WSDL, and this is the most important, this improvement finally allows the Web service application developed with Delphi 6 to be called by the client program developed by Visual studio.net! The new WSDL file is as follows: <?xml version="1.0"?> <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="IHelloservice" targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <message name="GetHelloRequest"> <part name="aID" type="xs:int"/> </message> <message name="GetHelloResponse"> <part name="return" type="xs:string"/> </message> <portType name="ISoapHello"> <operation name="GetHello"> <input message="tns:GetHelloRequest"/> <output message="tns:GetHelloResponse"/> </operation> </portType> <binding name="IHellobinding" type="tns:IHello"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetHello"> <soap:operation soapAction="urn:HelloIntf-IHello#GetHello" style="rpc"/> <input> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:HelloIntf-IHello"/> </input> <output> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:HelloIntf-IHello"/> </output> </operation> </binding> <service name="IHelloservice"> <port name="IHelloPort" binding="tns:IHellobinding"> <soap:address location="http://localhost:1024/WSDemo1.WSDemo1/soap/IHello"/> </port> </service> </definitions>
The new WSDL importer has also changed a lot. The new WSDL importer wizard is displayed, which is better than the original one (for example, "Delphi 6 preemptive Research -- one of bizsnap/soap/WebService -- a hello World! Is much more beautiful, of course, this is just a surface, click "Next", if the interface is imported successfully, you can immediately see the generated interface file content, if you press "finish", you can generate an interface file (Note: Because the generated interface file name is the interface name by default, but Delphi has a limit that the unit name cannot be the same as the object name, therefore, you must change the name before saving it ). Of course, the improvements to the WSDL importer are not just these superficial things. The most important improvement is that it can easily import the WSDL generated by the web service program written in visual studio.net, and can smoothly access its interface. Finally, it is worth mentioning that the soap part of C ++ Builder 6 is the same as that of patch 2 # of Delphi 6, if C ++ Builder 6 is installed on the same machine of Delphi 6 that has not been patched 2 #, the soap part of Delphi 6 will become unavailable. The solution is to patch Delphi 6 2 #. [Mental Studio] Bird mar.20-02 |