急...用DELPHI 调用.NET 做的一个WEB SERVER .参数传入无效!没多少分了.各位高手帮帮忙了.delphi 引用完后接口: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"
GetEntDataResult = type WideString; { "http://tempuri.org/" }
GetEntListResult = type WideString; { "http://tempuri.org/" }
GetChangedListResult = type WideString; { "http://tempuri.org/" }
GetPrjDataResult = type WideString; { "http://tempuri.org/" } // ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : ServiceSoap
// service : Service
// port : ServiceSoap
// URL : http://localhost/RisWebSvr/Service.asmx
// ************************************************************************ //
ServiceSoap = interface(IInvokable)
['{77573149-9C57-FA51-F11F-EFD527C91BD9}']
function GetEntData(const WhereStr: WideString): GetEntDataResult; stdcall;
function GetTest(const AStr: WideString): string; stdcall;
function GetEntList(const AWhere: WideString): GetEntListResult; stdcall;
function GetChangedList: GetChangedListResult; stdcall;
function GetPrjData(const WhereStr: WideString): GetPrjDataResult; stdcall;
procedure TruncateData(const SQLStr: WideString); stdcall;
end;客户端代码:procedure TfrmMain.Button2Click(Sender: TObject);
var
A:ServiceSoap;
B, sWhere:WideString;
XMLDoc: IXMLDocument;
begin
A := HTTPRIO1 as ServiceSoap;
sWhere := edtCity.Text;
B := A.GetTest(sWhere);
Memo1.Lines.Add( B );
{......}
end;
.NET WEB SERVER 部分代码:using System;
using System.Web;
using System.Xml;
using System.Data.SqlClient;
using System.Web.Services;
using System.Web.Services.Protocols;[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} /// <summary>
/// 取得企业数据
/// </summary>
/// <param name="WhereStr">对应的企业ID</param>
/// <returns></returns>
[WebMethod(Description = "取得企业数据")]
public XmlDataDocument GetEntData(string WhereStr)
{
return new XmlDataDocument(DBAccess.OpenDataSet("Select * from a_ent_all where " + WhereStr));
} /// <summary>
/// 取得企业列表
/// </summary>
/// <param name="AWhere">过滤条件一般为已经下载的企业编号</param>
/// <returns></returns>
[WebMethod(Description = "测试")]
public string GetTest(string AStr)
{
string sWhere = SysUtils.MergeStrings(new string[] { " where deleted=0 ", AStr }, " and ", false);
return sWhere;
}
{...........}问题:
在DELPHI 中调用接口方法,传入WEB SERVER .在WEB SERVER 中函数进去后的参数都是NULL 值.不知是为什么!!!谢谢各位了.!如
DELPHI :
procedure TfrmMain.Button2Click(Sender: TObject);
var
A:ServiceSoap;
B, sWhere:WideString;
XMLDoc: IXMLDocument;
begin
A := HTTPRIO1 as ServiceSoap;
sWhere := edtCity.Text;
B := A.GetTest(sWhere);
Memo1.Lines.Add( B );
{......}
end;.NET 的WEB SERVER 上: public string GetTest(string AStr)
{
string sWhere = SysUtils.MergeStrings(new string[] { " where deleted=0 ", AStr }, " and ", false);
return sWhere;
}其中参数ASTR 怎么都是NULL .其他函数也一样.
是不是有可能参数在DELPHI 中定义的是WIDESTRING 类型,在.NET 中是STRING 类型???
// 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"
GetEntDataResult = type WideString; { "http://tempuri.org/" }
GetEntListResult = type WideString; { "http://tempuri.org/" }
GetChangedListResult = type WideString; { "http://tempuri.org/" }
GetPrjDataResult = type WideString; { "http://tempuri.org/" } // ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : ServiceSoap
// service : Service
// port : ServiceSoap
// URL : http://localhost/RisWebSvr/Service.asmx
// ************************************************************************ //
ServiceSoap = interface(IInvokable)
['{77573149-9C57-FA51-F11F-EFD527C91BD9}']
function GetEntData(const WhereStr: WideString): GetEntDataResult; stdcall;
function GetTest(const AStr: WideString): string; stdcall;
function GetEntList(const AWhere: WideString): GetEntListResult; stdcall;
function GetChangedList: GetChangedListResult; stdcall;
function GetPrjData(const WhereStr: WideString): GetPrjDataResult; stdcall;
procedure TruncateData(const SQLStr: WideString); stdcall;
end;客户端代码:procedure TfrmMain.Button2Click(Sender: TObject);
var
A:ServiceSoap;
B, sWhere:WideString;
XMLDoc: IXMLDocument;
begin
A := HTTPRIO1 as ServiceSoap;
sWhere := edtCity.Text;
B := A.GetTest(sWhere);
Memo1.Lines.Add( B );
{......}
end;
.NET WEB SERVER 部分代码:using System;
using System.Web;
using System.Xml;
using System.Data.SqlClient;
using System.Web.Services;
using System.Web.Services.Protocols;[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} /// <summary>
/// 取得企业数据
/// </summary>
/// <param name="WhereStr">对应的企业ID</param>
/// <returns></returns>
[WebMethod(Description = "取得企业数据")]
public XmlDataDocument GetEntData(string WhereStr)
{
return new XmlDataDocument(DBAccess.OpenDataSet("Select * from a_ent_all where " + WhereStr));
} /// <summary>
/// 取得企业列表
/// </summary>
/// <param name="AWhere">过滤条件一般为已经下载的企业编号</param>
/// <returns></returns>
[WebMethod(Description = "测试")]
public string GetTest(string AStr)
{
string sWhere = SysUtils.MergeStrings(new string[] { " where deleted=0 ", AStr }, " and ", false);
return sWhere;
}
{...........}问题:
在DELPHI 中调用接口方法,传入WEB SERVER .在WEB SERVER 中函数进去后的参数都是NULL 值.不知是为什么!!!谢谢各位了.!如
DELPHI :
procedure TfrmMain.Button2Click(Sender: TObject);
var
A:ServiceSoap;
B, sWhere:WideString;
XMLDoc: IXMLDocument;
begin
A := HTTPRIO1 as ServiceSoap;
sWhere := edtCity.Text;
B := A.GetTest(sWhere);
Memo1.Lines.Add( B );
{......}
end;.NET 的WEB SERVER 上: public string GetTest(string AStr)
{
string sWhere = SysUtils.MergeStrings(new string[] { " where deleted=0 ", AStr }, " and ", false);
return sWhere;
}其中参数ASTR 怎么都是NULL .其他函数也一样.
是不是有可能参数在DELPHI 中定义的是WIDESTRING 类型,在.NET 中是STRING 类型???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货