.NET Forum / ASP.NET / Web Services / September 2006
How do I pass a message or variable to a web service?
|
|
Thread rating:  |
needin4mation@gmail.com - 31 Aug 2006 21:33 GMT 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. - 31 Aug 2006 23:24 GMT 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?
>I have this in my web service: > [quoted text clipped - 31 lines] > > Thank you for any help. John Saunders - 01 Sep 2006 01:08 GMT > 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
Scott M. - 01 Sep 2006 03:05 GMT I'm sorry John, I don't know what you mean by "document style" web service.
>> Well, I would disagree that you should think of web service calls as >> "passing messages". You should, in fact, think of them as remote [quoted text clipped - 5 lines] > > John John Saunders - 01 Sep 2006 11:50 GMT > I'm sorry John, I don't know what you mean by "document style" web > service. In the <wsdl:binding> section, if you use <soap:binding style="document" />, then you are effectively saying that you want the messages in this binding to be considered, each, as a single XML document, as opposed to a set of RPC-style parameters. The single document can represent multiple parameters, and, depending on your platform, can be processed as multiple parameters.This allows you to think in terms of sending and receiving entire XML documents, possibly complicated ones, instead of restricting your thinking to a flat set of procedure call parameters.
John
Scott M. - 01 Sep 2006 15:11 GMT But you still, are, in fact, calling procedures and receiving back function return values. The transport mechanism may be a complete XML document, but what you are doing (why you are using the services) doesn't change fundamentally.
>> I'm sorry John, I don't know what you mean by "document style" web >> service. [quoted text clipped - 9 lines] > > John John Saunders - 01 Sep 2006 17:41 GMT > But you still, are, in fact, calling procedures and receiving back > function return values. The transport mechanism may be a complete XML > document, but what you are doing (why you are using the services) doesn't > change fundamentally. How do you know that you're calling a procedure? You could, for instance, be calling a BizTalk orchestration, or something equally bizarre.
John
Scott M. - 01 Sep 2006 20:37 GMT Well, I would characterize any process that needs to be invoked a procedure.
>> But you still, are, in fact, calling procedures and receiving back >> function return values. The transport mechanism may be a complete XML [quoted text clipped - 5 lines] > > John Gaurav Vaish (www.EduJiniOnline.com) - 07 Sep 2006 01:15 GMT > Well, I would characterize any process that needs to be invoked a > procedure. Sending a message is, then, also invoking a procedure. Since it requires invoking a method to pust it to the wire and somebody on the other side to grab it and process it -- of course, a method involed
Just my few thoughts
:-)
 Signature Happy Hacking, Gaurav Vaish | http://www.mastergaurav.com http://articles.edujinionline.com/webservices -------------------
Scott M. - 07 Sep 2006 07:26 GMT Well no, not really. Sure, you need to invoke a method to post a message, but that method works on a local object, web services invoke a remote object's method.... A bit of a difference. I can send and receive XML messages quite easily and never get near web services. In other words, sending and receiving XML messages does not constitute web services.
>> Well, I would characterize any process that needs to be invoked a >> procedure. [quoted text clipped - 5 lines] > Just my few thoughts > :-) needin4mation@gmail.com - 01 Sep 2006 04:03 GMT > > Well, I would disagree that you should think of web service calls as > > "passing messages". You should, in fact, think of them as remote [quoted text clipped - 5 lines] > > John Any idea on how to pass the variable to the service? Anyone? Thank you again for any help.
Debasish Pramanik - 01 Sep 2006 11:38 GMT Hi,
Can you pass the entire code, as from your code it doesn't seems you have done anything wrong. It must be related to the settings or environment...or something else
 Signature Regards,
Debasish Pramanik Assetlink India. Phone: +91 20 26119531 (226)
> > > Well, I would disagree that you should think of web service calls as > > > "passing messages". You should, in fact, think of them as remote [quoted text clipped - 8 lines] > Any idea on how to pass the variable to the service? Anyone? Thank > you again for any help. needin4mation@gmail.com - 01 Sep 2006 14:33 GMT That's probably way too much code, but here is someone that had the same problem:
http://groups.google.com/group/microsoft.public.dotnet.framework.webservices/bro wse_frm/thread/9d0a4c200117dc1b/3cc244dfa9208c7f
That is where I got part of my information from.
Here is the code up to that point in my .asmx:
using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Runtime.InteropServices; using System.Data.Odbc; using System.Configuration; using System.Diagnostics; using System.Data; using System.Xml;
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { public Service () {
//Uncomment the following line if using designed components //InitializeComponent(); }
[WebMethod] public string HelloWorld() { return "Hi"; } [WebMethod] public XmlDocument GetDataFromDB(string name) { string errorMessage = ""; XmlDocument myDatas = new XmlDocument(); ...
In my client .aspx:
protected void Button1_Click(object sender, EventArgs e) {
DataBindFrmWS(TextBox1.Text);
}
Thanks again for any help. Everything works, as long as I don't pass it a variable.
This
> Hi, > [quoted text clipped - 23 lines] > > Any idea on how to pass the variable to the service? Anyone? Thank > > you again for any help. needin4mation@gmail.com - 01 Sep 2006 14:54 GMT > I have this in my web service: > [quoted text clipped - 31 lines] > > Thank you for any help. I finally got it working. I looked at the WSDL and found this:
<s:element name="GetDataFromDB"> <s:complexType /> </s:element>
So I went to Visual Studio and updated my web reference and it produced this:
<s:element name="GetDataFromDB"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string" /> </s:sequence> </s:complexType> </s:element>
I guess I need understand how all the pieces work together better. Thanks.
Scott M. - 01 Sep 2006 15:13 GMT If you look at my first response to your question and the last thing I wrote, you'll see that I had already suggested that:
"Are you sure that your web service project has been re-built and than your web service reference has been refreshed?"
>> I have this in my web service: >> [quoted text clipped - 52 lines] > I guess I need understand how all the pieces work together better. > Thanks.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|