我想在X3里面调用 用JAVA写的 WEB SERVICE 服务程序,管理员提供了以下的方法,我不知道以下的这段客户端实现程序是在X3导入地址生成的的还是在DELPHI导入地址生成的
WebService文件
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
生成的接口文件
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost:3518/WebSite1/Service.asmx?WSDL
// Encoding : utf-8
// Version : 1.0
// (2006-8-2 9:38:19 - $Revision: 1.9.1.0.1.0.1.9 $)
// ************************************************************************ //
unit MyService;
interface
uses InvokeRegistry, Types, XSBuiltIns;
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"
// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/HelloWorld
// transport : http://schemas.xmlsoap.org/soap/http
// binding : ServiceSoap
// service : Service
// port : ServiceSoap
// URL : http://localhost:3518/WebSite1/Service.asmx
// ************************************************************************ //
ServiceSoap = interface(IInvokable)
['{77573149-9C57-FA51-F11F-EFD527C91BD9}']
function HelloWorld: String; stdcall;
end;
function GetServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''): ServiceSoap;
implementation
uses SOAPHTTPClient;
function GetServiceSoap(UseWSDL: Boolean; Addr: string): ServiceSoap;
const
defWSDL = 'http://localhost:3518/WebSite1/Service.asmx?WSDL';
defURL = 'http://localhost:3518/WebSite1/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;
RIO := THTTPRIO.Create(nil);
try
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
Result := (RIO as ServiceSoap);
finally
if Result = nil then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://tempuri.org/HelloWorld');
end.
平台上调用方法:
var
s: ServiceSoap;
begin
{ s := JustepExt.MyService.GetServiceSoap(False, 'http://localhost:3518/WebSite1/Service.asmx');
Dialogs.ShowMessage(s.HelloWorld);
s := nil; |