delphi调用C# WEB服务,参数传递问题
服务端:
public NetDiskWebSrv () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public void RegistServerInfo(string GUID,string strCompanyName,string strSoftVersion,string strHostIP)
{
//----------------------------------------
string strSQL = "select * from NetDiskServerInfo Where GUID='"+GUID+"'";
PubClass TmpPub = new PubClass();
try
{
if (TmpPub.RecordExist(strSQL))
{
strSQL = "update NetDiskServerInfo set CompanyName='" + strCompanyName + "',SoftVersion='" + strSoftVersion + "',";
strSQL = strSQL + "ServerUrl='" + strHostIP + "',UpdateTime='" + DateTime.Now + "' where GUID='" + GUID + "'";
}
else
{
strSQL = "insert into NetDiskServerInfo ([GUID],CompanyName,SoftVersion,ServerUrl,UpdateTime)";
strSQL = strSQL + "values('" + GUID + "','" + strCompanyName + "','" + strSoftVersion + "','" + strHostIP + "','" + DateTime.Now + "')";
}
TmpPub.ExcuteSQL(strSQL);
}
finally
{
}
}
//------------客户端---
var
ProxySrv:NetDiskWebSrvSoap;
sGUID,sHost,sCompany,sVersion:widestring;
begin
sGUID:=edtGUID.Text;
showmessage(sGUID);
sHost:=edtstrHostIP.Text;
sCompany:=edtstrCompanyName.Text;
sVersion:=edtstrSoftVersion.Text;
ProxySrv:=(httpRIOMain as NetDiskWebSrv.NetDiskWebSrvSoap);
//ShowMessage(ProxySrv.HelloWorld);
try
// ProxySrv.RegistServerInfo(Pchar(sGUID),Pchar(sCompany),Pchar(sVersion),Pchar(sHost));
ProxySrv.RegistServerInfo('sdfsdfsdf','sdfsdfsdf','eeee','dfsdfsdfdf');
except
Application.MessageBox('WEB服务调用失败!', 'WEB服务调用提示', MB_OK +
MB_ICONSTOP); end;
----------------------------------------
服务端调试通过,调用HelloWorld正确
调用 RgistServerInfo时,传到服务端的参数都变成了null,将参数改成pchar类型,仍然失败.
求教大吓们...........
(开发环境:D7+VS2005)
服务端:
public NetDiskWebSrv () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} [WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public void RegistServerInfo(string GUID,string strCompanyName,string strSoftVersion,string strHostIP)
{
//----------------------------------------
string strSQL = "select * from NetDiskServerInfo Where GUID='"+GUID+"'";
PubClass TmpPub = new PubClass();
try
{
if (TmpPub.RecordExist(strSQL))
{
strSQL = "update NetDiskServerInfo set CompanyName='" + strCompanyName + "',SoftVersion='" + strSoftVersion + "',";
strSQL = strSQL + "ServerUrl='" + strHostIP + "',UpdateTime='" + DateTime.Now + "' where GUID='" + GUID + "'";
}
else
{
strSQL = "insert into NetDiskServerInfo ([GUID],CompanyName,SoftVersion,ServerUrl,UpdateTime)";
strSQL = strSQL + "values('" + GUID + "','" + strCompanyName + "','" + strSoftVersion + "','" + strHostIP + "','" + DateTime.Now + "')";
}
TmpPub.ExcuteSQL(strSQL);
}
finally
{
}
}
//------------客户端---
var
ProxySrv:NetDiskWebSrvSoap;
sGUID,sHost,sCompany,sVersion:widestring;
begin
sGUID:=edtGUID.Text;
showmessage(sGUID);
sHost:=edtstrHostIP.Text;
sCompany:=edtstrCompanyName.Text;
sVersion:=edtstrSoftVersion.Text;
ProxySrv:=(httpRIOMain as NetDiskWebSrv.NetDiskWebSrvSoap);
//ShowMessage(ProxySrv.HelloWorld);
try
// ProxySrv.RegistServerInfo(Pchar(sGUID),Pchar(sCompany),Pchar(sVersion),Pchar(sHost));
ProxySrv.RegistServerInfo('sdfsdfsdf','sdfsdfsdf','eeee','dfsdfsdfdf');
except
Application.MessageBox('WEB服务调用失败!', 'WEB服务调用提示', MB_OK +
MB_ICONSTOP); end;
----------------------------------------
服务端调试通过,调用HelloWorld正确
调用 RgistServerInfo时,传到服务端的参数都变成了null,将参数改成pchar类型,仍然失败.
求教大吓们...........
(开发环境:D7+VS2005)
---------------------------
Debugger Exception Notification
---------------------------
Project PrjNetDiskWebSrvClient.exe raised exception class ERemotableException with message 'System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.Data.OleDb.OleDbException: 字段 'NetDiskServerInfo.GUID' 不能是零长度的字符串。
在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
在 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
在 System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
在 PubClass.ExcuteSQL(String strSQL)
在 NetDiskWebSrv.RegistServerInfo(String GUID, String strCompanyName, String strSoftVersion, String strHostIP)
--- 内部异常堆栈跟踪的结尾 ---'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
我用C#写了一个简单的WEB服务程序,计算两整数的和
[WebMethod]
public int AddReult(int x, int y)
{
return (x + y);
}
我用DELPHI调用此服务,传入 12,12
在服务端跟踪 x,y值居然为0,0
superman