.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

return more than one value from web service

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net


I am new to web service... I have created a simple web service to add a record to sql server by passing a parameter and returns true or false once done...

At the same time, I want to return the customer_account_number value created on the sql server.. so basically I want to return the true and false and one (or more) additional values..

how can i do that please..


View Complete Post

More Related Resource Links

IE 8 partially cut of my JSON data return from WCF service

Hi All, I am not so sure here is the right place to post my issue. I am using ExtJS treepanel and ajax call to wcf webservice and return JSON array. My service return array. If array count is less than 2, then IE partially cut of my JSON data return from WCF service. But FireFox is working fine with same JSON format string. Very interesting thing is that I try to debug with Fildder. so I have to put "." dot in my url "http://localhost{.}:1234/ then It is working fine.   I am testing with IE8. Here is the JSON format return from FF and FireBug. {"result":[{"href":"..\/EMP\/EmployeeSearch.aspx","iconCls":"","id":"8c362443-7bb3-427e-910c-87b391c6abf5","leaf":true,"text":"Employees"}]} Here is the corrupted JSON string retrun from IE using developer tool. {"result":[{"href":"..\/EMP\/E" [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "GetSiteMap", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] [return: MessageParameter(Name = "result")] List<TreeView> GetSiteMap(string node);

Passing return value from a Web Service to a label in a Form View

I am using JavaScript to call a web service. The JS is correctly receiving and passing the web service information. At the moment, the web service returns a country name as a string to a JavaScript alert pop up box as follows:ret = CountryRegionsWebService.GetTranslatedCountryShortName(ddl1_value, ddl2_value, OnComplete, OnTimeOut, OnError);function OnComplete(args) { alert(args); } I want to change this so that web service returns the country name to a label inside an insert item template of a form view. Is there a way to pass in the label variable to the OnComplete function signature and still account for the variable args?, such as: Server Side Declaration of JavaScript ddl2.Attributes.Add("onChange", "JavaScript:OnComplete('" + lab5.ClientID + "', '" + "args" + "');"); Client Side JavaScript function OnComplete(lab5_id, args) { var lab5 = document.getElementById(lab5_id); lab5.innerHTML = args; }  

How to use return JSON object from web service as a declared Type?

Hi, I just hit the following issue: I am calling a web service that returns a serialized JSON object let's say: __type, FirstName, LastName (.net object Person with properties FirstName and LastName). __type's value is Test.Person I have created a JS object using Type.registerNameSpace/registerClass called Demo.Person and it is registered on the page using the ScriptManager. Everything is working fine; I am able to get data from the server on the call back. Is it possible to make the returned object from the web service be an instance of the declared JavaScript Demo.Person class? The idea would be to call a method like result.getFullName() on the client side without having to copy all the properties. This is just a simple scenario for more complex objects.   Thanks,   Teo

Make my WCF service return json

Iam trying to make my wcf serivce method to return JASON-object, but it dosen't work, when I open in a webbrowser it shows xml. How can I make this method to return json.I have inserted [WebGet(ResponseFormat = WebMessageFormat.Json)],,,, but it didn't help[WebGet(ResponseFormat = WebMessageFormat.Json)] protected override IEnumerable<KeyValuePair<string, SampleItem>> OnGetItems() { // TODO: Change the sample implementation here if (items.Count == 0) { items.Add("A", new SampleItem() { Value = "A" }); items.Add("B", new SampleItem() { Value = "B" }); items.Add("C", new SampleItem() { Value = "C" }); } return this.items; }[WebGet(ResponseFormat = WebMessageFormat.Json)]         protected override IEnumerable<KeyValuePair<string, SampleItem>> OnGetItems()         {             // TODO: Change the sample implementation here             if (items.Count == 0)             {                 items.Add("A", new SampleItem() { Value = "A" });  &nb

wcf returning a list from wcf service - I have lots of locations and I want to return the locations


How is it possible to return some kind of list from a wcf serivce, this the method in my wcf service 
my interface:

    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "Locations")]
    IList<Location> GetLocations();

 public IList<Location> GetLocations()
        Pazar.Data.Repositories.LocationRepository locRepository = new Pazar.Data.Repositories.LocationRepository();
        return locRepository.GetRootLocations().ToList<Location>();

and this how my GetRootLocations looks like, It returns IQueryable, I wounder if I can maybee return Iqueryable from my svc-service?

public IQueryable<Location> GetRootLocations()
        IQueryable<Location> locations = GetAll().Where(p => !p.ID_Parent.HasValue).OrderBy(p => p.Sequence);
        return locations;

calling web service from SSIS return result as null



I got this result

<Result>The result is null. Either the result is null or the Web method returns void.</Result> 
 when I calling web service from SSIS. I setup HTTP connection and tested without any problem; download WSDL without any problem; I did exactly as the link: http://msdn.microsoft.com/en-us/library/ms181267.aspx. From input editor, I selected service and method. For the chosen method, there will be 3 variables (1 input parameter, 2 output parameters). For the input variable, I defined the package variable as string, and copied XML content to the variable as the value. I will select this defined package variable as the input parameter. I then moved to defined output file.
 When I run the simple package, I will get the output file as result as above. What is wron

WCF Data service out put not return correctly



I am consuming wcf Data service in client application following way, when i execute SP, some of the columns are repeating with same value,

  DataServiceContext context1 = new DataServiceContext(new Uri(serviceURL));
  string strparam = "emailid='" + paramemail + "'& LocalTitle='" + paramtitle + "'& ColorGrouping='" + paramcolor + "'";
  string url = serviceURL + "GetSearchResult?" + strparam;
  IEnumerable<Cognos_MTSR> SearchResult = context1.Execute<Cognos_MTSR>(new Uri(url));
  Binding with grid here grid source =SearchResult;

In service part i have written as follows

public List<Cognos_MTSR> GetSearchResult(string emailid, string LocalTitle, string ColorGrouping)

   Entities db = new Entities();
   var query = db.SearchResult(emailid, LocalTitle, ColorGrouping);
   List<Cognos_MTSR> caseList = query.ToList<Cognos_MTSR>();
   return caseList;


can any one suggest on this?


How to return datatable from a typed dataset using WCF service and Jun CTP ?


How to return datatable from a typed dataset using WCF service/



       In one of my application I am using the Typed Dataset that contains many tables. I want to return a particular Datatable form the dataset as following.


Case 1. The following code is working, but the problem is I can not use .EnforceConstraints = false property as this property only available with Dataset.  (I want to use this property because I want to return only selected fields from the table and rest of the fields may have not null columns)

How to return matching keywords from sharepoint search web service


I'm writing an ISV page that is embedded in an iFrame within Microsoft Dynamics CRM 4.0 and it searchs both CRM and Sharepoint for matching candidates. Skills are stored in CRM entities and then Sharepoint Document libraries are searched for matching keywords in document resumes. I then merge the results together. However in the results I would like to show which skills (in crm) and keywords (in sharepoint) matched.

I have been playing arround with the Sharepoint Search Service Tool trying to find a way. The closest I can get is the Managed Search Property "Hit Highlighted Summary", but that won't gurantee every matching keyword to be returned when 5+ keywords are searched. I could search each keyword invidually and post process but that is very inefficient.

Is there a way to accomplish what i'm trying to do? (meta data about the search results about matching keywords?)

Thanks in advance,



SSRS 2008 Web Service Datasource doesn't return embedded class



I am building reports with SSRS 2008 using web services as datasource.

Let me explain my design:

I have 2 classes:

public class Employee

{ public string fname;

public string lnamel;

public Department dept;


public class Department

{public string name;


i have this function as a web method:

public Employee GetEmployee(string lastname)

      Employee emp = new Employee();
      // I query the DB and return the result in a datatable
     // I then bind the table fields to my Employee object
     return emp;


When I test the service, it return the employee's info and his/her dept info as well.

But when i test the dataset in the report, it only return the employee's info and not the department info.

Any suggestion?

Thanks a lot!!!

How to return objects in XML format in WCF service



I have a very simple WCF web service, and define a simple class, "Employee". there is a method, GetActiveEmployees(), I'd like the method return XML format employees, so client call the method and then get XML, not object.

Is there any simple way to do it?


class Employee{

public FirstName{ get; set;}

public LastName{get;set;}



Return ReadOnlyCollection from WCF service and use it in Silverlight 3 client application

Hi all!

I have a solution containing of 3 parts: wcf service, wpf app and silverlight 3 app.
Both wpf app and silverlight app use wcf service to get a collection of objects.

The point is that my business requirements insistently tell me to return ReadOnlyCollection<T> from wcf service.
When I try to do it I have Serialization exception in silverlight client app. But it's ok in wpf app.

Then, I haven't started the investigation for such strange thing (different behavior in wpf and silverlight) and decided to implement custom serialization, returning the ICollection interface and trying to get ReadOnlyCollection on deserializing.  But wcf service proxy class in silverlight app returned Array of T, not ReadOnlyCollection<T> as proxy in wpf did.

So, the question is: Is it possible to return ReadOnlyCollection<T> from WCF service?

Any help is appreciate.


Confusion about web service return types (classes, generic list)?


I have confusion about web service return types? Can a webservice return a genelist? ex: List(Of Employees)

I have searched threads in this forums but got confused, some say 'yes' some say 'no'.

If I mark the class as Serizable will that be enough to return a generic list?


Service Reference: return type converted to a "ref" parameter



I created a WCF service using Message Contracts. One of the operations in the service takes in an entity (embedded in a message contract) and returns an updated version of the entity:

EWADemo.MessageContracts.CustomersService.SaveCustomersResponseMessage SaveCustomers(EWADemo.MessageContracts.CustomersService.SaveCustomersRequestMessage request);

[MessageContract(WrapperName = "SaveCustomers")]
public partial class SaveCustomersRequestMessage
 public EWADemo.DataContracts.Customers Customers

[MessageContract(WrapperName = "SaveCustomersResponse")]
public partial class SaveCustomersResponseMessage
 public EWADemo.DataContracts.Customers Customers

When I tried creating a s

Web Service Return Custom Error Code


I'm trying to write a Web Service that will return several different error codes so the client can handle each error code individually (e.g. err=600 call funcA, err=700 call funcB, etc..).

My code below always returns "500" for the _statusCode (or get_statusCode). Am I doing this wrong? How do I get a Web Service to return custom error codes to the client (javascript)? Any info appreciated. Thanks.


If IsNothing(Membership.GetUser(UserName.ToString.Trim)) Then

objReturnValue = New UserInfo(UserName.ToString.Trim, False)


objReturnValue = Nothing

Err.Raise(vbObjectError + 601, "UserExists", UserName)

End If

Web Service can't return server control?


Hello, i am new to asp.net web service.

I want to send PlaceHolder from my main webform to web service, adding few controls there, and then return it back to my main webform. But,it doesn't seem to be working. It works fine when i return string.

This is code that gives me error :


public PlaceHolder ph(PlaceHolder a)


//some logic to add few controls to placeholder

return a;



Is it the limitation of web service? Any suggestion?

Windows Service Applications Tutorials

You can easily create services by creating an application that is installed as a service. For example, suppose you want to monitor performance counter data and react to threshold values. You could write a Windows Service application that listens to the performance counter data, deploy the application, and begin collecting and analyzing data.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend