Declaring List In Web Service?
Jan 9, 2010Why is it that I cannot declare List in my web service using asp.net just like what I got on a certain site.
Code:
List<string> responses = new List<string>();
Why is it that I cannot declare List in my web service using asp.net just like what I got on a certain site.
Code:
List<string> responses = new List<string>();
Is declaring a constructor private or declaring a class sealed is same thing?
View 1 Repliesi have a dropdown list with values
America
Asia
Europe
I need to the display the ddl as Select Type and when i click the dropdownlist to see the values in it, it should display the three values, but i should not use Select Type as a list item and it should not be displayed in the list. It should only be used as a default text in ddl.
I have built a WCF Service that is being consumed by a Silverlight app. At first I created one method that was very simple:
public String SfTest()
{
return "SF Test";
}
No poblem. My silverlight app references my service and displays "SF Test" in a textbox. Now I add a method to my wcf service like this:
public List<String> GetTest()
{
List<String> list = new List<string>();
String a = "a";
list.Add(a);
String b = "b";
list.Add(b);
return list;
}
I update the reference to the service in my Silverlight app and the using statement in my xaml cs page throws an error like the service doesn't even exist although it is there. I am assuming the problem has to do with datatypes or serialization or something like that but it is driving me up the wall. Why can't I consume a simple generic list in my Silverlight app through the WCF service.
I've created a simple WCF service hosted by ASP.NET web site:
[Code]....
I can add references to this service as to WCF service, as to WebService.WcfTestClient application successfully recognized service and its methods.
But "Web Service Studio" [URL] can't get a list of operations... Why? How to diagnose/resolve that?
P.S. I work under VS 2008 using .NET 3.5
I just noticed that I can save a lot of spacing by not using "as" when declaring variables, in some cases (not sure if this is something new in VS2010). For example:
Dim Name as string = "Bob"
works the same as:
Dim Name = "Bob"
I prefer the latter as some of my type declarations can be very long due to the library I am working with, and omitting the types simplifies the lines and makes them more readable. I am wondering a few things:
1. Do the two methods function at all differently?
2. Is this a bad practice, or generally excepted?
3. Is there a name for this?
I just want to know the declaration of variables in a separate class file or declaring in the same aspx.cs file. the best practice of declaring the variables.
View 3 RepliesWhen the page loads, the GridView (located in an update panel) should be loaded with my first SQL SELECT statement. On the button click, the same GridView will be loaded with new data.
What am i doing wrong? On startup, the GridView doesn't appear.
Public cmd As New SqlCommand()
Public percentp As New SqlCommand()
Public da As New SqlDataAdapter(cmd)[code].....
public Jquery Extra(this HtmlHelper htmlhelper,
string message,
IDictionary<string, object> htmlAttributes)
if i declare the this Htmlhelper htmlhelper when i declare my method, but i don't want to pass that parameter in when i call the method?
I have a really simple web interface which has been created in visual studio 2010 and is connected to an SQL server running MS SQL Server 2008. I essentially want the user to be able to enter values into the two text boxes provided and when the button is clicked, these values are inserted into the relevant table in the database.
When I run the code, I get an error back saying that the 'scalar variable for @clientName is not defined.' I have altered the insert statement to fixed values rather than entering from the text boxes and this works fine (ie, replace @clientName and @serverName in the insert statement with 'xx' and 'yy' respectively). How I can define these scalar variables. I'm not to sure what i'm missing. Code below.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
[Code] .....
The code that the button executes is below
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
SqlDataSource1.Insert()
End Sub
End Class
How is it possible to return some kind of list from a wcf serivce, this the method in my wcf service
my interface:
[Code]....
and this how my GetRootLocations looks like, It returns IQueryable, I wounder if I can maybee return Iqueryable from my svc-service?
[Code]....
I want to list all the countries in my dropdown list. where can i get all the names? from service right? How to do this?
View 4 RepliesIn the web servce I say
public List<Customer> GetCustomers()
{
PR1Entities dc = new PR1Entities();
var q = (from x in dc.Customers
select x).ToList();
return q;
}
(customer is a entity object)
Then I generate the proxy when I add the service.. and in the reference.cd it say
public wcf1.ServiceReference1.Customer[] GetCustomers() {
return base.Channel.GetCustomers();
}
WHY IS IT AN ARRAY? I asked for a List.
I have an object that contains a list of Email addresses and EmailIDs.
Code:
public class DataObjects
{
public class UserEmails
{
private string _Email;
public string Email
[Code] ....
And I populate it like this:
Code:
protected void GetEmails()
{
DataAccess da = new DataAccess(); //this is a separate Data Access class with loads of methods to access the database
List<DataObjects.UserEmails> myUserEmailsList = new List<DataObjects.UserEmails>(); //create a list of UserEmails objects
myUserEmailsList = da.getUserEmails(1); //this passes in a UserID to the data access function that returns me a list of emails for this user
myPassedList(myUserEmailsList); //I pass the list to another function just to prove the data is there and can be retrieved.
}
The last line in GetEmails passes the list to myPassedList
Code:
protected void myPassedList(IList EmailsList)
{
foreach (DataObjects.UserEmails myUserEmails in EmailsList) //loop through the list to prove it is populated etc.
{
int EmailID = myUserEmails.EmailID;
string Email = myUserEmails.Email;
}
}
Everything above works fine. Here's the question. When I am at the point where I have populated the List of UserEmails - I need to pass it to a web service for someone else to access the data.
I pass my list to a function and I can loop through it by writing:
foreach (DataObjects.UserEmails myUserEmails in EmailsList)
which is fine, for me, because my application knows what DataObjects.UserEmails means ... the people receiving the list won't. They are just getting a list.
Can they loop through the list I pass them without knowing the structure of the object in the list and just extract the data?
I want to declare a Dictionary<string, object> variable but don't know where/how to. The values in the dictionary will be objects from the Page (ListBoxes, DropDownLists, etc) so I can't exactly create a class somewhere else. Is there any way I can make this variable accessible from each method in the codebehind?
View 5 RepliesI'm using a web service and I want to return a list to my client. I am nearly newby at web services and I can't return a List<String> object to my client. But when i call the method it says "Unable to cast object of type 'System.Collections.Generic.List`1[System.String]' to type 'System.String[]'" What should I do?
View 2 RepliesThis is a continuation on this question:The problem is simple. I need to call methods from a REST web service which controls several tables. One table is a snapshot table which contains records with huge XML files. Each XML file is basically a backup from another database. This backup XML is then sent to customers who use the data as read-only information in another product. Basically, the data in the XML are lists of companies, products, business rules and whatever more. And no, those customers work offline most of the time, so they cannot get the data live.Walking through the list of snapshots is tricky: XMLData.Snapshots.Skip(N).Take(1).First(); but it works very nice. It's the answer of the previous Q.But there are three other lists of data that I need to walk through. These are called Changes, Errors and Messages. They contain (1) changes to the data, (2) errors that occurred during modifying the data and (3) generic messages. All of these records are linked to a snapshot record. Thus a single snapshot can contain multiple changes, errors and messages.
I still cannot access the server code but since there's a REST service wrapped around an entity framework exposing most of the functionality, I can still use that service. (And that service is only accessible internally, on the Intranet. This is basically what I have to work with. And while the lists of changes, errors and messages are relatively small, the snapshots are still huge.
The problem is that I now want to generate a client-side report of the changes, errors and messages, but without grouping them by snapshot! They need to be grouped by date. But each record also needs to show the title of the snapshot, which causes me some incredible headaches...When walking through e.g. the Changes with the regular foreach instruction I can load the Snapshot data by using XMLData.LoadProperty(Change, "Snapshots"); but since the snapshot record itself is generally about 300 MB, this just slows the whole thing down to a crawl. (There are tens of thousands of these records in total!) So I need a faster solution, without having to modify the server code.
Yeah, okay. Modifying the server would be the proper way but that's not possible. It's in production and this list isn't important enough to require an upgrade of the server. Basically, I'm not allowed to modify any server-code for now. (But they still want this list.)The application I'm working on is something that just needs to run once per week or per month. But with the current amount of records, I estimate it would take more than two days to finish. The data itself will be updated a few times every office day and snapshots are created every week or so on the server. Errors can always be generated when users start browsing the site which maintains the data but in general, there will be about 50 changes and 4 errors per week, plus a few messages when the server goes down and up again or when snapshots are generated.
How do you declare a dictionary called MyDic in the master page?
I want MyDic to hold lists of objects MyObj with a date as the key so that I can write something like this: "get the list for date 1/28/2011 from MyDic" or "put this list of MyObj from 1/28/2011 in MyDic".
I'd like to declare the dictionary in the master page so that I can access it in every page.
I got a simple SQL Connection which works fine under VS 2005, once I convert to VS 2008, is failed to work. I even re-build entire apps from scratch under VS 2008, yet it still failed.
Here's the code.
[Code]....
The code failed at this line:
objCon = New SqlConnection()
Error message being:
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
I want to create a control just like a Panel.
I want my control to accept some controls as childs without typing the template name, just like the Panel, as shown here:
<asp:Panel runat="server">
My content
<div>Content</div>
</asp:Panel>
I have controls with content inside without telling what is the ITemplate.
I basically want to convert this
<my:MyControl runat="server">
<ContentTemplate>
My content
<div>Content</div>
[Code]....
The above works with <Content></Content> tags inside the control, but without it doesn't work. And the attribute isn't doing anything at all (I guess). What's missing?
I have this procedure
[Code]....
I don't know what variable should be put in where clause for tblVisitor.visitorID because there's a variable that was already passed by an output identity parameter by a different stored procedure. What will I put in the where clause for visitor id?
I have a Interface for CRUD operations.and some classes implemented it.I want to design a user control that have two buttons:insert and delete,to reuse this control over my forms.this class must have a instance of my interface to do insert and delete tasks (if I'm right).this is my interface:
[Code]...
my problem is,i can't declare a property of type ISchoolSystemRepository in user control,because i must pass T for interface.
What is the use of declaring the static class. I know that we cant create the object for the static class but i want to know that is the use of creating the class as static.
View 1 RepliesIs there a way I can see the list of operations that are exposed by a WCF service same as we can with a asmx service?
View 1 RepliesI need to pass a random number from 1 to 100 from the client to a webservice, and then the webservice will subtract this number from the list of 100 numbers (say 1-100). Then, in the next call, the next random number will be subtracted from the rest 99 numbers and so on.
I need this to be done with AJAX. I don't know where the Array list should be held in the first place (would it be in the web service or in the code behind? ), and how this can be done?