Hi
I want pass NameValueCollec tion as parameter in webmethod.
I try it but that give me error.
Here is Error.
You must implement the Add(System.Stri ng) method on
System.Collecti ons.Specialized .NameValueColle ction because it inherits from
ICollection.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.InvalidO perationExcepti on: You must implement the
Add(System.Stri ng) method on
System.Collecti ons.Specialized .NameValueColle ction because it inherits from
ICollection.
Thanks
--
-MrDotNet MCAD, MCSD
Sr. Software Engineer / Lead Architect 2 6855
A NameValueCollec tion type cannot be used as a parameter to a Web Method.
For more information on which types can be serialized using XML see http://msdn.microsoft.com/library/de...ebservices.asp
However, it is easy to achieve similar functionality e.g., by using the
following simple class:
public class NameValues
{
public NameValues()
{}
public NameValues(stri ng name, string[] values)
{
Name = name;
Values = values;
}
public string Name;
public string[] Values;
}
Instead of trying to use a NameValueCollec tion as parameter you can use an
array of NameValues like so:
[WebMethod]
public void PassNameValues( NameValues[] namesAndValues)
{
foreach (NameValues nameValues in namesAndValues)
{
string name = nameValues.Name ;
foreach (string value in nameValues.Valu es)
{
// ...
}
}
}
Regards,
Sami
"MrDotNet" <Mr******@discu ssions.microsof t.com> wrote in message
news:84******** *************** ***********@mic rosoft.com... Hi I want pass NameValueCollec tion as parameter in webmethod. I try it but that give me error. Here is Error. You must implement the Add(System.Stri ng) method on System.Collecti ons.Specialized .NameValueColle ction because it inherits from ICollection. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidO perationExcepti on: You must implement the Add(System.Stri ng) method on System.Collecti ons.Specialized .NameValueColle ction because it inherits from ICollection.
Thanks -- -MrDotNet MCAD, MCSD Sr. Software Engineer / Lead Architect
and in general,
if you specify the web service interface using a W3C XML Schema (XSD), you
will always be able to transmit it, in a portable fashion.
This is sometimes called the "Contract First" or "Schema First" approach to
building web services.
For more info on the idea. . . http://msdn.microsoft.com/vstudio/ja...p/default.aspx
or check out this cool tool from Christian Weyer http://weblogs.asp.net/cweyer/archiv.../21/39070.aspx
-Dino
"Sami Vaaraniemi" <sa**********@p leasejippii.fi> wrote in message
news:eN******** ******@tk2msftn gp13.phx.gbl... A NameValueCollec tion type cannot be used as a parameter to a Web Method. For more information on which types can be serialized using XML see http://msdn.microsoft.com/library/de...ebservices.asp
However, it is easy to achieve similar functionality e.g., by using the following simple class:
public class NameValues { public NameValues() {}
public NameValues(stri ng name, string[] values) { Name = name; Values = values; }
public string Name; public string[] Values; }
Instead of trying to use a NameValueCollec tion as parameter you can use an array of NameValues like so:
[WebMethod] public void PassNameValues( NameValues[] namesAndValues) { foreach (NameValues nameValues in namesAndValues) { string name = nameValues.Name ; foreach (string value in nameValues.Valu es) { // ... } } }
Regards, Sami
"MrDotNet" <Mr******@discu ssions.microsof t.com> wrote in message news:84******** *************** ***********@mic rosoft.com... Hi I want pass NameValueCollec tion as parameter in webmethod. I try it but that give me error. Here is Error. You must implement the Add(System.Stri ng) method on System.Collecti ons.Specialized .NameValueColle ction because it inherits from ICollection. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidO perationExcepti on: You must implement the Add(System.Stri ng) method on System.Collecti ons.Specialized .NameValueColle ction because it inherits from ICollection.
Thanks -- -MrDotNet MCAD, MCSD Sr. Software Engineer / Lead Architect
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Justin Crossley |
last post by:
I'm having a type mismatch problem when trying to pass a typed dataset to a
web service.
My code is:
CLIENT CODE
I have a dataset schema file called MainData.xsd containing a table called
mytable
|
by: christopherkilmer |
last post by:
I've googled my brains out and haven't found the answer yet, so...
I have a WebMethod that accepts an array of Order objects as a
parameter. I cannot figure out how to send an array to the webservice
namespace ArrayTest
{
public class OrderService : System.Web.Services.WebService
{
private Order _Orders;
|
by: Jaime Stuardo |
last post by:
Hi all..
I have a WebMethod with a parameter defined as DateTime. When I call that
webservice, I get this error:
System.FormatException: The string '07/24/2005' is not a valid AllXsd value.
It seems that dates aren't recognized. I tried using several date formats,
for example, dd/mm/yyyy, mm/dd/yyyy, yyyy/mm/dd, and so on, without success.
Any help woud be greatly appreciated,
|
by: placek |
last post by:
Hi all.
I would like to create two web services:
- The first one - ImportData - should take as an input parameter a XML
document and return an integer saying if passed XML document was valid
and was succesfully processed.
- The second one - ExportData - should take as an input parameter an
integer an return a XML document.
I would like to know if it is possible to do something like that. Do I
|
by: ojinfo |
last post by:
hi
i am currently working on a web service which is supposed to take a
xmldocument as input parameter, and then returns another xmldocument.
the service is added to the web references in my windows application,
and the call is executed. problem is that the input arguments gets
value nothing in the web service.
currently the code works as follows:
- create xmldocument 'input'
| |
by: raghuraman_ace |
last post by:
Hi
i have started a webservice wich has a webmethod with parameters using
literal encoding & encoded encoding . The webservice is compiled
successfully . But i don know how to pass the parameters that satisfy
these encodings .
My web method is
---------------------------------------------
|
by: David++ |
last post by:
Hi folks,
I would be interested to hear peoples views on whether or not 'pass by
reference' is allowed when using a Web Service method.
The thing that troubles me about pass-by-reference into a WebService is that
essentially we are passing an address of an object which resides on the
'local machine' i.e. a local machine object address. Surely when the
WebService method is called and run 'on the server', the reference type will
be...
|
by: needin4mation |
last post by:
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
|
by: shapper |
last post by:
Hello,
I am having some problems in looping through each item in
NameValueCollection:
1 Dim a As New NameValueCollection
2 a.Add("My String", City.NewYork)
3 a.Add("My String", City.Paris)
4 a.Add("My String", City.London)
5
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |