调用代码为:
Edt2.Text:=(HTTPRIO1 as ServiceSoap).HelloWorld;然后报如下错误,Unable to retrieve the URL endpoint for Service/Port 'Service'/'' from WSDL 'http://192.168.0.110/testoutput/service.asmx?WSDL'谢谢大家
Edt2.Text:=(HTTPRIO1 as ServiceSoap).HelloWorld;然后报如下错误,Unable to retrieve the URL endpoint for Service/Port 'Service'/'' from WSDL 'http://192.168.0.110/testoutput/service.asmx?WSDL'谢谢大家
http://192.168.0.110/testoutput/service.asmx可以看到那方法,并且还可以调用,现在方法很简单,vs2005 webservice 代码如下:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;[WebService(Namespace = "http://192.168.0.110/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]public class Service : System.Web.Services.WebService
{
public Service () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod]
public string HelloWorld() {
return "HelloWorld";
}
}帮忙了大家,谢谢
yi10000() ( ) 信誉:100 Blog 请问需要启动什么服务?
InvRegistry.RegisterInvokeOptions(TypeInfo(接口名), ioDocument);
['{F93E24C5-FB73-8A4C-8CAF-705CC11BEE69}']
function HelloWorld: WideString; stdcall;
function datetostr(const dt: TXSDateTime): WideString; stdcall;
end;function GetServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ServiceSoap;
implementationfunction GetServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ServiceSoap;
const
defWSDL = 'http://192.168.0.110/testoutput/sendtest.asmx?WSDL';
defURL = 'http://192.168.0.110/testoutput/sendtest.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), 'http://192.168.0.110/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://192.168.0.110/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);end.我的代码为上面的,问题依旧
你试试直接用URL调用,而不通过WSDLLocation调用。代码如下:
var
mHttpRIO: THTTPRIO;
mServiceSoap: ServiceSoap;
begin
mHttpRIO := THTTPRIO.Create(nil);
try
mHttpRIO.HTTPWebNode.UseUTF8InHeader := True;
mHttpRIO.Converter.Options := mHttpRIO.Converter.Options + [soUTF8InHeader, soUTF8EncodeXML];
mHttpRIO.URL := 'http://192.168.0.110/testoutput/service.asmx'; mServiceSoap := mHttpRIO as ServiceSoap;
Edt2.Text:= mServiceSoap.HelloWorld;
finally
mServiceSoap := nil;
end;
end;
你试试直接用URL调用,而不通过WSDLLocation调用。代码如下:
var
mHttpRIO: THTTPRIO;
mServiceSoap: ServiceSoap;
begin
mHttpRIO := THTTPRIO.Create(nil);
try
mHttpRIO.HTTPWebNode.UseUTF8InHeader := True;
mHttpRIO.Converter.Options := mHttpRIO.Converter.Options + [soUTF8InHeader, soUTF8EncodeXML];
mHttpRIO.URL := 'http://192.168.0.110/testoutput/service.asmx '; mServiceSoap := mHttpRIO as ServiceSoap;
Edt2.Text:= mServiceSoap.HelloWorld;
finally
mServiceSoap := nil;
end;
end;