delphi 调用webservice 之前是没有密码验证的,可以正常调用webservice并正常使用服务,但后来将webservice 改成需要用户名各密码验证之后,就出现Unauthorized (401),不知从何要加入用户名和密码的验证
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : https://extranetapps.hongkongairport.com/SPMV_RPT/upload/wsdl/com/hkairport/spmv/webService/UpstreamService.wsdl
// Encoding : UTF-8
// Codegen : [wfDebug,wfUseSerializerClassForAttrs]
// Version : 1.0
// (2008-1-31 11:01:19 - 1.33.2.5)
// ************************************************************************ //unit UpstreamService1;interfaceuses InvokeRegistry, SOAPHTTPClient, 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://webService.spmv.hkairport.com
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : UpstreamServiceSoapBinding
// service : UpstreamServiceService
// port : UpstreamService
// URL : https://extranetapps.hongkongairport.com/SPMV_RPT/upload/services/UpstreamService
// ************************************************************************ //
UpstreamService = interface(IInvokable)
['{7C4BBD3A-9F99-85E7-891A-E7E5CAE0C5D6}']
function handleUpstream(const fromemail: WideString; const stringContent: WideString): WideString; stdcall;
end;function GetUpstreamService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): UpstreamService;
implementationfunction GetUpstreamService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): UpstreamService;
const
defWSDL = 'https://extranetapps.hongkongairport.com/SPMV_RPT/upload/wsdl/com/hkairport/spmv/webService/UpstreamService.wsdl';
defURL = 'https://extranetapps.hongkongairport.com/SPMV_RPT/upload/services/UpstreamService';
defSvc = 'UpstreamServiceService';
defPrt = 'UpstreamService';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
begin
RIO := THTTPRIO.Create(nil);
end
else
RIO := HTTPRIO;
try Result := (RIO as UpstreamService);
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(UpstreamService), 'http://webService.spmv.hkairport.com', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(UpstreamService), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(UpstreamService), ioDocument);
end.
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : https://extranetapps.hongkongairport.com/SPMV_RPT/upload/wsdl/com/hkairport/spmv/webService/UpstreamService.wsdl
// Encoding : UTF-8
// Codegen : [wfDebug,wfUseSerializerClassForAttrs]
// Version : 1.0
// (2008-1-31 11:01:19 - 1.33.2.5)
// ************************************************************************ //unit UpstreamService1;interfaceuses InvokeRegistry, SOAPHTTPClient, 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://webService.spmv.hkairport.com
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : UpstreamServiceSoapBinding
// service : UpstreamServiceService
// port : UpstreamService
// URL : https://extranetapps.hongkongairport.com/SPMV_RPT/upload/services/UpstreamService
// ************************************************************************ //
UpstreamService = interface(IInvokable)
['{7C4BBD3A-9F99-85E7-891A-E7E5CAE0C5D6}']
function handleUpstream(const fromemail: WideString; const stringContent: WideString): WideString; stdcall;
end;function GetUpstreamService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): UpstreamService;
implementationfunction GetUpstreamService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): UpstreamService;
const
defWSDL = 'https://extranetapps.hongkongairport.com/SPMV_RPT/upload/wsdl/com/hkairport/spmv/webService/UpstreamService.wsdl';
defURL = 'https://extranetapps.hongkongairport.com/SPMV_RPT/upload/services/UpstreamService';
defSvc = 'UpstreamServiceService';
defPrt = 'UpstreamService';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
begin
RIO := THTTPRIO.Create(nil);
end
else
RIO := HTTPRIO;
try Result := (RIO as UpstreamService);
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(UpstreamService), 'http://webService.spmv.hkairport.com', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(UpstreamService), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(UpstreamService), ioDocument);
end.
是不是这个意思?
HTTPReqResp1.UserName:='aa';
HTTPReqResp1.Password:='bb';
HTTPRIO1.HTTPWebNode :=HTTPReqResp1;