如何将消息或变量传递给Web服务? [英] How do I pass a message or variable to a web service?
问题描述
我在我的网络服务中有这个:
public XmlDocument GetDataFromDB(字符串名称)
{
... 。
在数据库中做一些名称变量的东西...
将XmlDocument返回给我的数据网格;
}
现在,在我的客户端default.aspx中我有一个调用此按钮的按钮
函数:
public void DataBindFrmWS(字符串名称)
{
尝试
{
XmlDocument myServiceDoc = new XmlDocument();
System.Xml.XmlNode neNode;
//将生成的XML从WebMethod添加到创建的用户
XmlNode
neNode = myService1.GetDataFromDB(名称); //从上面
....
编译时说这句话在最后一行打破:
没有方法重载GetDataFromDB''需要''1''参数。
这是什么意思?
我读到我不应该认为这不是传递变量,如
函数调用,而是发送消息。我无法弄清楚如何发送这个简单的消息
。我只想发送一个带有最后一个
名称的简单字符串。
感谢您的帮助。
好吧,我不同意您应该将Web服务调用视为
传递消息。事实上,您应该将它们视为远程程序
(函数)调用。如果webmethod需要一个参数,那么你必须将
一个传递给函数。
你确定你的web服务项目已被重建并且比你的
网络服务参考已刷新?
< ne *********** @ gmail.comwrote in message
news:11 ********************** @ m73g2000cwd.googlegr oups.com ...
>我在我的网络服务中有这个:
public XmlDocument GetDataFromDB(字符串名称)
{
...
在数据库中做一些名称变量的东西...
将XmlDocument返回给我的数据网格;
}
现在,在我的客户端default.aspx中我有一个调用这个
函数的按钮:
public void DataBindFrmWS(字符串名称)
{
尝试
{
XmlDocument myServiceDoc = new XmlDocument();
System.Xml.XmlNode neNode;
//将生成的XML从WebMethod添加到创建的用户
XmlNode
neNode = myService1.GetDataFromDB(name); //从上面
...
编译时说这句话在最后一行打破:
" ;方法GetDataFromDB没有重载需要''1''参数。
这是什么意思?
我我认为我不应该认为这是传递变量,如在
函数调用中,而是发送消息。我无法弄清楚如何发送这个简单的消息
。我只想发送一个带有最后一个
名称的简单字符串。
感谢您的帮助。
>
" Scott M." < s - *** @ nospam.nospamwrote in message
news:OJ ************** @ TK2MSFTNGP04.phx.gbl ...
好吧,我不同意您应该将Web服务调用视为
传递消息。实际上,您应该将它们视为远程
过程(函数)调用。如果webmethod需要一个参数,那么
你必须将一个参数传递给该函数。
Scott,请记住,有两种样式的Web服务:RPC样式,以及
Document样式。有些像后者,为了一般性(我愿意)。
John
对不起John,我不知道不知道你的意思是文件样式网络服务。
" John Saunders" < john.saunders at trizetto.comwrote in message
news:e7 ************** @ TK2MSFTNGP06.phx.gbl ...
< blockquote class =post_quotes>
" Scott M." < s - *** @ nospam.nospamwrote in message
news:OJ ************** @ TK2MSFTNGP04.phx.gbl ...
>嗯,我不同意您应该将Web服务调用视为传递消息。实际上,您应该将它们视为远程过程(函数)调用。如果webmethod需要一个参数,那么你必须将一个参数传递给该函数。
Scott,请记住有两种样式的Web服务:RPC样式,
和Document样式。有些人喜欢后者,为了一般性(我愿意)。
John
I have this in my web service:
public XmlDocument GetDataFromDB(string name)
{
....
do some stuff with name variable..on the database...
return the XmlDocument to my datagrid;
}
Now, in my client default.aspx I have a button that calls this
function:
public void DataBindFrmWS(string name)
{
try
{
XmlDocument myServiceDoc = new XmlDocument();
System.Xml.XmlNode neNode;
//Adding the resulting XML from WebMethod to a user created
XmlNode
neNode = myService1.GetDataFromDB(name); //from above
....
It breaks on this last line when compiling saying:
"No overload for method "GetDataFromDB'' takes ''1'' arguments."
What does this mean?
I read that I should think not of this as passing variables as in
functions calls, but sending messages. I can''t figure out how to send
this simple message. I only want to send a simple string with a last
name.
Thank you for any help.
Well, I would disagree that you should think of web service calls as
"passing messages". You should, in fact, think of them as remote procedure
(function) calls. If the webmethod requires a parameter, then you must pass
one to the function.
Are you sure that your web service project has been re-built and than your
web service reference has been refreshed?
<ne***********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...>I have this in my web service:
public XmlDocument GetDataFromDB(string name)
{
...
do some stuff with name variable..on the database...
return the XmlDocument to my datagrid;
}
Now, in my client default.aspx I have a button that calls this
function:
public void DataBindFrmWS(string name)
{
try
{
XmlDocument myServiceDoc = new XmlDocument();
System.Xml.XmlNode neNode;
//Adding the resulting XML from WebMethod to a user created
XmlNode
neNode = myService1.GetDataFromDB(name); //from above
...
It breaks on this last line when compiling saying:
"No overload for method "GetDataFromDB'' takes ''1'' arguments."
What does this mean?
I read that I should think not of this as passing variables as in
functions calls, but sending messages. I can''t figure out how to send
this simple message. I only want to send a simple string with a last
name.
Thank you for any help.
"Scott M." <s-***@nospam.nospamwrote in message
news:OJ**************@TK2MSFTNGP04.phx.gbl...Well, I would disagree that you should think of web service calls as
"passing messages". You should, in fact, think of them as remote
procedure (function) calls. If the webmethod requires a parameter, then
you must pass one to the function.Scott, remember that there are two styles of web service: the RPC style, and
the Document style. Some like the latter, for generality (I do).
John
I''m sorry John, I don''t know what you mean by "document style" web service.
"John Saunders" <john.saunders at trizetto.comwrote in message
news:e7**************@TK2MSFTNGP06.phx.gbl..."Scott M." <s-***@nospam.nospamwrote in message
news:OJ**************@TK2MSFTNGP04.phx.gbl...>Well, I would disagree that you should think of web service calls as
"passing messages". You should, in fact, think of them as remote
procedure (function) calls. If the webmethod requires a parameter, then
you must pass one to the function.
Scott, remember that there are two styles of web service: the RPC style,
and the Document style. Some like the latter, for generality (I do).
John
这篇关于如何将消息或变量传递给Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!