1.可以给一个已经做好的exe程序添加Web Services的功能(向别人提供接口和调用别人提供的接口)么?还是必须要新建一个Web Services的工程?2.如果是新建一个Web Services的工程,我选择Web App Debugger可以对他进行调试,也可以出现Form界面,但是我最终就可以这样发布?还是必须要发布成CGI或ISAPI的方式?ISAPI的方式是动态库,我没法添加Form界面啊,我还需要Form界面,CGI好像是控制台窗口的方式,我也没办法添加Form界面,在需要Form界面和Web Services的情况下,应该怎么做呢?谢谢各位!
2、delphi的Web Service服务端就是以ISAPI DLL形式发布的
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://172.20.100.10/test/service.asmx?wsdl
// >Import : http://172.20.100.10/test/service.asmx?wsdl:0
// Encoding : utf-8
// Version : 1.0
// (2010/6/22 上午 11:31:35 - - $Rev: 10138 $)
// ************************************************************************ //unit service;interfaceuses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;const
IS_OPTN = $0001;
IS_REF = $0080;
type // ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl] // ************************************************************************ //
// Namespace : Kye
// soapAction: Kye/HelloWorld
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : ServiceSoap
// service : Service
// port : ServiceSoap
// URL : http://172.20.100.10/test/service.asmx
// ************************************************************************ //
ServiceSoap = interface(IInvokable)
['{B82FAFBA-EAB8-AD5C-2535-FB6046355616}']
function HelloWorld(const name_: WideString): WideString; stdcall;
end;function GetServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ServiceSoap;
implementation
uses SysUtils;function GetServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ServiceSoap;
const
defWSDL = 'http://172.20.100.10/test/service.asmx?wsdl';
defURL = 'http://172.20.100.10/test/service.asmx';
defSvc = 'Service';
defPrt = 'ServiceSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as ServiceSoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'Kye', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'Kye/HelloWorld');
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);
InvRegistry.RegisterExternalParamName(TypeInfo(ServiceSoap), 'HelloWorld', 'name_', 'name');end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,service, StdCtrls;type
TForm1 = class(TForm)
btn1: TButton;
edt1: TEdit;
Label1: TLabel;
procedure btn1Click(Sender: TObject);
private
aa:ServiceSoap;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.btn1Click(Sender: TObject);
begin
aa:=GetServiceSoap(False,'',nil);
ShowMessage(aa.HelloWorld(edt1.Text));
end;end.
1.如果是COM+工程的话,向外发布时,仅需要创建一个WEBSERVICE工程,把COM+进行包装一下即可!
2.如果没什么规划,我想,只能生写一个WEBSERVICE,直接读数据库了
(何况从WETSERVICE本身来说就是无状态的.)所以加FORM的想法还是取消为好.从EXE->CGI/ISAPI, 想方便的话就新建一个CGI/ISAPI程序,然后把EXE原有的功能UNIT添加过来就行了.
如果熟悉WS的开发,也可以直接改原代码, (也就是把相应的HTTPRIO.pas等加进来,再registe一些东西---相对麻烦一点).