倒,如果是english开可以try一下
解决方案 »
- 谁能看懂这篇文章里面指的WSDL地址?
- 请教仓库管理系统--入库编号的问题
- 关于恢复数据库的问题
- delphi2009 窗体和任务栏的问题
- delphi中有什么办法可以判断一个界面是模式的还是非模式的?
- 如何让窗口始终得到焦点!
- 时间显示问题
- 怎样设置线程优先级?我用的TThread,怎样设置?
- 是什么原因造成MDI父窗体不能最小化的?
- 怎样将dbf中的时间字段(以数字形式存储)转换成delphi时间格式?
- 在接口部分的public中申明变量aa,在private中申明变量bb,那我是否还要在实现部分申明变量aa,bb,若是,1.为何,2.能否给个例子.
- 在query中能不能写这样SQL:select c.*,z.* from a.b c,x.y z ; a,x 是不同的数据库,各位指点一下。
谁有这方面的资料或经验,请赐教!谢谢!
谁有这方面的资料或经验,请赐教!谢谢!
大意清楚,但有很多俚语,要精确翻译的话,要一段时间。
Did you miss it?
For additional information on Web services and an explanation of how to use them, see the first installment in this series, "Using Web services in Delphi 6." That article explains how to use Web services inside Delphi 6, focusing specifically on the Number to Words and BabelFish services.
Delphi 6
Using a Web Service with Delphi 6 proved to be very easy. And fortunately, creating one isn't hard either. Just start Delphi 6, choose File | New | Other, and go to the WebServices tab of the Object Repository. As Figure A shows, you'll find three icons: Soap Server Application, Soap Server Data Module, and Web Services Importer. We’ll use the Soap Server Application icon to start a new Web service.
Figure A
Your choices under the WebServices tab Soap Server Application
When you select Soap Server Application, you are asked what kind of application you want to create. A Web service created this way is a Web server application that produces Web Service Description Language (WSDL) and talks SOAP (to the outside world). But it's still a regular Web server application as well, so you must first select a type of Web server application. This can be ISAPI/NSAPI, plain CGI, WinCGI, Apache (new in Delphi 6), or a Web App Debugger executable. The last choice is also new in Delphi 6 and provides a convenient way to debug your Web server application (including the Web service), but it doesn't result in something you can deploy. (However, you can easily create another project "wrapper" and migrate your Web module to it.)CGI stand-alone executable
Since most ISPs will still not allow you to upload ISAPI or NSAPI DLLs to their Web servers (unless you have your own dedicated server), we’ll choose a plain CGI executable, as shown in Figure B. This will mean that the Web service will be slightly slower (compared to an ISAPI/NSAPI or Apache DLL) because it has to be loaded for every request, but at least it can be deployed more easily.
Figure B
For our example, we’ll choose CGI Stand-Alone Executable.
Web module
As soon as you click OK, you’ll get a regular Web module—but with three new components: an HTTPSoapDispatcher, an HTTPSoapPascalInvoker, and a WSDLHTMLPublish component (see Figure C). The first one responds to incoming SOAP requests and dispatches them for our Web module. The second component translates incoming SOAP requests to method calls for our Pascal object. And the third one produces the WSDL based on our published invokable interface, so that the outside world can learn how to use our Web service.Save the Web module in the file SWebMod.pas and the project as NumberToWordsInDutch.dpr before you continue.
Figure C
The three new components Invokable interface
At this point, we have a Web service skeleton but nothing to publish to the outside world. We need to create a new interface, derived from IInvokable (so it can be invoked from outside). For our example, I want to create an interface called IDutch with a single method called NumToStr. The entire unit with the interface definition appears in Listing A.Note that the call to RegisterInterface is needed to register the IDutch interface in the Invokable Registry. And in order to get a unique GUID value, you can press [Ctrl][Shift]G in the Delphi 6 IDE.Interface implementation
An interface is nice since it defines what we want to allow other people to call (i.e., how they can use our Web service). But we must not forget to implement it. The implementation of the Web service is fairly simple but rather long when it comes to the NumToStr method (which translates a number to a Dutch set of words). Note that we must also register the class TDutch (the implementation of the IDutch interface) in the Invokable Registry. Listing B shows the code for this.Note that I've placed the implementation in unit DutchImp (whereas I placed the interface definition in unit Dutch).Deployment
Remember that I started this Web service as a simple CGI application. As a result, it can be deployed on my DrBob42.TDMWeb.com Web site (which is based on a Web server running Windows 2000). The location of the Web service will be:
http://DrBob42.TDMWeb.com/cgi-bin/NumberToWordsInDutch.exebut if you call it directly (without any further arguments or PathInfo), you won't get a valid response. We didn't add any default behavior to the Web service. (For that you need to add a Web action item, make it the default one, and let it return a response)In order to call the Web service to return the description, you need to add /wsdl and the name of the interface, which results in this:
http://DrBob42.TDMWeb.com/cgi-bin/NumberToWordsInDutch.exe/wsdl/IDutchUsing NumberToWordsInDutch
In "Using Web services in Delphi 6," we used the Web Services Importer to turn the full WSDL into an import unit. You may have noticed that the resulting interface definition looked a lot like the interface definition we’ve made for IDutch. In fact, if you have implemented a Web service in Delphi 6, you do not have to call the Web Services Importer to generate an import unit from the WSDL; you can simply refer to the unit that contains the interface definition in the first place (in our case, that would be unit Dutch).To demonstrate the use of the NumberToWordsInDutch Web service, create a new application and drop an HTTPRIO component on the main form. Make sure the WSDLLocation property of the HTTPRIO component points to
http://DrBob42.TDMWeb.com/cgi-bin/NumberToWordsInDutch.exe/wsdl/Idutchand that the Service property is set to IDutchservice and the Port property has IDutchPort as value. Then, in the FormCreate event handler, you can write the following code:
procedure TForm1.FormCreate(Sender: TObject);
begin
Caption := (HTTPRIO1 AS IDutch).NumToStr(42)
end;This will set the caption of the main form to "tweeenveertig". Not a very useful demo, but you get the idea. In the meantime, if you have any questions about Web services in Delphi 6 or if you want to see some more useful examples, feel free to e-mail, leave a comment in the discussion area below, or visit the SOAP section of my Web site.
Creating Web services?
Are you currently creating, or do you plan to create, Web services for others to use? What suggestions do you have for others wanting to create Web services? Send us an e-mail with your thoughts and suggestions or post a comment below.