[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

解决方案 »

  1.   

    Delphi里面soap是不能直接传输string类型的
      

  2.   

    我尝试过强制转化为PChar也不行
      

  3.   

    这样子的,web service程序里面应该就不能用string类型,而你的c#的代码里面用的时string类型
    另外不要转换,而是直接用pchar类型,因为类型出问题应该时soap的传输就处理不了string类型
      

  4.   

    dabaicai(一直是菜鸟) 你是不是陈动动?呵呵,到处都能看到你,开来是高手了
      

  5.   

    我用Delphi7 & ms.net 2003测试没有问题,不知你的方法是否和我的一致:
    1、用.net创建WebService,添加方法并运行,在WEB页中进入“服务说明”链接,另存为xxx.xml;
    2、用Delphi创建一个默认的应用程序,点新建菜单,在WebServices页中选择WSDL Importer,然后选择上一步保存的xxx.xml文件,当前的应用程序中添加了一个单元;
    3、在Form1中添加一个TEdit,一个TButton控件,添加TButton的单击事件,引用上一步新加的单元之后加入如下测试代码:
      ShowMessage(GetService1Soap.GetTest(Edit1.Text));
    我这里是OK的
      

  6.   

    我用VS2005开发的,
    通过 service.asmx?wsdl存为一个WSDL文件,
    然后在delphi7中使用,后面步骤和你一样
      

  7.   

    我试了,wsdl和xml是一样的,只是扩展名不同而已,也好用。
    我没有2005,帮不了你了。
      

  8.   

    你不需要把wsdl保存,只要保存你浏览wsdl的地址,在delphi的控件的该属性中放入该地址即可
      

  9.   

    我建议你在网上下载一个SOAP Toolkit 3.0试一下
    我下载后在我机器上装不起,搞不清楚什么原因
      

  10.   

    我今天也遇到同样的问题了,mmd,以前调用 vs2003的webservice是好的,真是晕,
      

  11.   

    I have fixed this problem.The problem was that VS2005 by default uses the SoapDocumentProtocol,
    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.
      

  12.   

    楼上正确。
    我也是d7+v2005,写的传送文件的东西,
    InvRegistry.RegisterInvokeOptions(TypeInfo(接口名称), ioDocument);
    就可以把参数传上去了。