[WebMethod]
public string GetTest(string instr)
{
return "This is a test-----" + instr;
}调用
ServiceSoap = interface(IInvokable)
['{77573149-9C57-FA51-F11F-EFD527C91BD9}']
function GetTest(const instr: WideString): WideString; stdcall;
end;procedure TForm1.btn2Click(Sender: TObject);
var
p : ServiceSoap;
begin
p:= HTTPRIO1 as ServiceSoap;
ShowMessage(p.GetTest('我的'));end;
返回"This is a test-----" ,参数并没有传递过去,要怎么改?
delphi7.0+vs2005
public string GetTest(string instr)
{
return "This is a test-----" + instr;
}调用
ServiceSoap = interface(IInvokable)
['{77573149-9C57-FA51-F11F-EFD527C91BD9}']
function GetTest(const instr: WideString): WideString; stdcall;
end;procedure TForm1.btn2Click(Sender: TObject);
var
p : ServiceSoap;
begin
p:= HTTPRIO1 as ServiceSoap;
ShowMessage(p.GetTest('我的'));end;
返回"This is a test-----" ,参数并没有传递过去,要怎么改?
delphi7.0+vs2005
另外不要转换,而是直接用pchar类型,因为类型出问题应该时soap的传输就处理不了string类型
1、用.net创建WebService,添加方法并运行,在WEB页中进入“服务说明”链接,另存为xxx.xml;
2、用Delphi创建一个默认的应用程序,点新建菜单,在WebServices页中选择WSDL Importer,然后选择上一步保存的xxx.xml文件,当前的应用程序中添加了一个单元;
3、在Form1中添加一个TEdit,一个TButton控件,添加TButton的单击事件,引用上一步新加的单元之后加入如下测试代码:
ShowMessage(GetService1Soap.GetTest(Edit1.Text));
我这里是OK的
通过 service.asmx?wsdl存为一个WSDL文件,
然后在delphi7中使用,后面步骤和你一样
我没有2005,帮不了你了。
我下载后在我机器上装不起,搞不清楚什么原因
whereas Delphi uses the SoapRpcProtocol.The effect was that all strings passed from the Delphi Client to the .NET
server were nulled.The Fix is to add one line of code to the INITIALIZATION Section of the Soap
Interface unit, Autogenerated in Delphi when you import a WSDL. The line of
code is:InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);Where "ServiceSoap" is the name of your interface.
我也是d7+v2005,写的传送文件的东西,
InvRegistry.RegisterInvokeOptions(TypeInfo(接口名称), ioDocument);
就可以把参数传上去了。