C# - WCF Service Not Returning Value To JQuery

Mar 10, 2010

I have a problem with getting jquery to retrieve results from a WCF service. I am hosting the WCF service within IIS and when I attach the debugger to this process I can see that the code is processed successfully. However, when it hits the callback within jquery there is no data??

I have set up a trace on the wcf service and there are no errors. It just seems as though the data is lost after the wcf service method completes.

Here is the jquery code which calls the service:

$.get("http://ecopssvc:6970/ecopsService.svc/Echo", {echoThis: "please work"}, function(data) {
alert("Data Loaded: " + data);
});

Here is the wcf config:

<system.serviceModel>
<services>
<service name="EcopsWebServices.EcopsService" behaviorConfiguration="EcopsServiceBehaviours">
<endpoint address="" behaviorConfiguration="WebBehaviour"
binding="webHttpBinding" bindingConfiguration="" contract="EcopsWebServices.IEcopsServiceContract" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehaviour">
<webHttp />
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="EcopsServiceBehaviours">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

Here is the service contract:

[ServiceContract]
public interface IEcopsServiceContract
{
[WebGet]
[OperationContract]
string Echo(string echoThis);
}

Here is the Service implementation:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class EcopsService : IEcopsServiceContract
{
#region IEcopsServiceContract Members
public string Echo(string echoThis)
{
return string.Format("You sent this '{0}'.", echoThis);
}
#endregion
}

View 3 Replies


Similar Messages:

Web Service Returning Xml Data Using Jquery Works Fine On Local But Not On Server?

Jan 4, 2010

I am having a webmethod that returns some data.I'm using jquery to call that function with its Content type specified as XML.The problem is that it is working on local machine but not on server.The code i'm using is:

var arrInputs = pnl.getElementsByTagName("input");
str = arrInputs[0].value;
$.ajax({[code]....

Ajaxfinish is defined afterwards and it works fine on local.Is there some more settings i need to do to make it executable

View 1 Replies

WCF / ASMX :: Returning List From Wcf Service?

Sep 19, 2010

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]....

View 5 Replies

WCF / ASMX :: Service Returning Old Values?

Sep 14, 2010

I am developing an application with WCF services. The basic functionaloty of a screen is to provide an entry screen to add particular entity. Once save even fired It will save the data to the database and call the bind method to bind into the grid by refreshing the latest data.

When I am running the site from my source (Visual Studio) , it works perfectly. When the client calls method to fetch the data the WCF service, it returns latest (added) data. But the issue comes in the server when it works with IIS. I deployed the code in the server, once the data added I am getting the old data only. But after two refresh I am getting the latest data.

what required to be done to get the latest record.

View 3 Replies

AJAX :: Web Service Returning A DataTable?

Feb 15, 2010

I am using ASP.NET AJAX 3.5

I have a web service that is invoked by the ScriptManager that is attempting to return a DataTable to the receiving javascript.

[Code]....

[Code]....

My service method is called successfully.

[Code]....

[Code]....

View 3 Replies

C# - Web Service Returning Ajaxified Results?

Sep 19, 2010

I am hoping someone can point me in the right direction here. I am trying to create web service that will return ajaxified results. Specifically, I want to write a web service that will fetch email through a secure connection. However, rather then have the web service return every single email, I just want to fetch maybe 5 emails at a time. I've always used Ajax as a client helper technology and not sure how to go about implementing this on a server side, or if its even possible.

I am using ASP.NET/C#, by the way.

View 1 Replies

VS 2010 - Stub For A Web Service That Will Be Returning XML

Jun 23, 2011

I'm going to be calling a webservice that will return me data in xml format. Since the web service is not ready yet, I want to test locally by calling a function that returns the xml. So if I have a sample xml file on my hard-drive, how do I just open it and read it and create an xml string from it? I don't care at this point about parsing anything out; I will do that in the caller and have that written. I just want all the xml back.

View 9 Replies

WCF / ASMX :: Service Over Https Returning Error

Oct 11, 2010

I am trying to deploy a wcf service. I have created a simple service, basically I have created a new wcf service and tried to deploy it however I get this error

The type 'WCF_Application.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

I am trying to deploy my service to a subdomain like
https://services.mydomain.com/business

My config looks like this

[Code]....

View 3 Replies

WCF / ASMX :: Service Returning A Blank Page?

Mar 2, 2011

Ok so I am trying to setup a WCF web service. I thought I had my .svc and webConfig ready to go, but when I hit this service all I get is a blank page.

[Code]....

View 1 Replies

WCF / ASMX :: Returning List From A Web Method In A Web Service?

Mar 25, 2010

I'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 Replies

Web Service Returning XML Result And Nodevalue Is Always Null?

May 25, 2010

I have an ASP.NET web service which returns an XMLDocument. The web service is called from a Firefox extension using XMLHttpRequest.

var serviceRequest = new XMLHttpRequest();
serviecRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

I consume the result using responseXML. So far so good. But when I iterate through the XML I retrieve nodeValue - nodeValue is always null. When I check the nodeType the nodeType is type 1 (Node.ELEMENT_NODE == 1).

Node.NodeValue states all nodes of type Element will return null.

In my webservice I have created a string with the XML i.e. xml="Hank"

I then create the XmlDocument
XmlDocument doc = new XmlDocument();
doc.LoadXML(string);

I know I can specify the nodetype using using CreateNode. But when I am just building the xml by appending string values is there a way to change the nodeType to Text so Node.nodeValue will be "content of the text node".

View 1 Replies

WCF / ASMX :: Returning Parent And Child Objects In Web Service?

May 3, 2010

I have to return collection of parent and child objects in a web service but I am not being able to solve this.

look below code blocks where i will try to explain my problem:

This is my web method which returns a list of parents

[Code]....

[Code]....

Below is my child Class:

[Code]....

View 1 Replies

Streaming Wcf Service Returning Corrupt Streamed File?

Aug 31, 2010

I have a WCF service that returns a stream object. But for some reason i get a corrupt zip file back which i am streaming.

Contract Code

[ServiceContract(Namespace = "http://schemas.acme.it/2009/04/01")]
public interface IFileTransferService
{
[OperationContract(IsOneWay = false)]
FileDownloadReturnMessage DownloadFile(FileDownloadMessage request);

[Code].....

View 2 Replies

WCF / ASMX :: Need Details On Returning An Entire Existing XML File From A Web Service?

Jan 20, 2011

I've been reading quite a few tutorials on web services and xml files and one thing isn't quite clear to me. If I want to create an XML file on the fly the tutorials are pretty straight forward but, I want to grab an existing XML file from the web server and return the whole thing. Do I need to read the XML file and send each individual node or is there a way to send the file all at once? The tutorials imply that the whole file could be a node but I'm not clear on what that entails or if it would work. Also do you have a link to an example?

View 1 Replies

WCF / ASMX :: Windows Communication Foundation Service Returning Xml / Json Data?

Aug 25, 2010

I Need by service contract to return the xml/json result depending on the request type. function which will convert my result set (i am using linq to sql) so that i do not need to create the xml format for the result set by iterating through the table row many times.What is the suitable way to do that.

I need a kind of short cut method which will convert the table data to xml result.Had i been using asp.net mvc i would have been able to generate the xml data by overriding the the ExecuteResult method in the ActionResult and giving Conetnt-Type = "text/xml" as OP.But since i am using Wcf i don't have the controller context(as controller context is the parameter that needs to be passed to Execute Result).

My present code for converting the table data to the xml format is below.

public XDocument UsersLists(string authToken)
{
bool IsAuthenticated = Authenticate(authToken);
XDocument xDoc = new XDocument();
XElement root = new XElement("Users");

[Code]....

I need to eliminate this way of generating xml for each table records.

View 1 Replies

JQuery :: Returning Search Results From .cs To .js Array?

Mar 9, 2011

In my web form I have a search box. The user enters a string, and once the search button is clicked, I pass the value from my .js file to my .cs file and do some processing to get the results. Up to this point everything is fine, but now I dont know how to get my results back to my .js page. The serach results at this point are in a dataset, and also in an multidimensional array. I have a multi array because I need to pass back the code and description of the items found.

[Code]....

At this point I have used the passed string 'value' to get my required code/descriptions, but i'm not sure how/if I can get either the Dataset or multidimensional array back to my .js page

View 2 Replies

JQuery :: LinkButton OnclientClick Is Not Returning The Value False

Jun 25, 2010

Somehow my onclientClick is not returning the value false correctly. I am trying to prevent the user from clicking on the button. How ever user can click on it first time in this case. I am looking to turn off my LinkButton's Click event, by setting it to false. How would I do this? Somehow returning false doesn't cancel the event.

[Code]....

C# Code

[Code]....

View 2 Replies

C# - Returning Multiple Values To Be Used In JQuery From A WebMethod

Mar 3, 2011

I have jquery using ajax/json to grab an elements ID and then hits:

[System.Web.Services.WebMethod]
public static string EditPage(string nodeID)
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(Global.conString))
using (SqlCommand cmd = new SqlCommand("contentPageGetDetail", con))
{
cmd.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = Global.SafeSqlLiteral(nodeID, 1);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(dt);
}
}
if (dt.Count > 0)
{
string pageTitle = dt.Rows[0]["Title"].toString();
string contentID = dt.Rows[0]["ContentID"].toString();
return pageTitle, contentID, nodeID;
}
else
{
return "Failed";
}
}

When it's time to return I want to grab all content returned from the stored procedure back to the jquery method in the success section and set a hiddenfield, dropdown value, and a title in a textfield. In the jQuery I tried using "pageTitle" but it came up undefined. What do I need to do jQuery side to grab whats being returned and populate fields in my Web Form before showing the form?

View 3 Replies

JQuery :: Get JSON Call To MVC Controller Not Returning Data

Nov 25, 2010

This is probably something simple. The following JQuery call is executing and calling the controller. The controller is executing correctly. I used the sample data that's commented out to verify that the templates were working also. However, the success function is not executing in the browser. Any thoughts or other ways I can debug this?

<script type="text/javascript">$(document).ready( function(){ alert("Here"); @* var myData = [ {first: "Jane", last: "Doe"}, {first: "John", last: "Doe"} ]; *@ $.getJSON( "/User/Filter",function(myData){ $("#myDataTemplate").tmpl(myData).appendTo("#itemContainer"); } ); alert("there"); }
);</script>
//Controller
public ActionResult Filter() { var myData = this.repository.GetAllUsers(); //return Json(myData); return Json(myData, JsonRequestBehavior.AllowGet);}

View 6 Replies

JQuery UI Autocomplete WebService Source Returning JSON?

Nov 29, 2010

I have been trying for two months to get this code working, and I am close, but still confused. I want the JQuery UI Autocomplete function to call an web service which returns JSON data and display that data for selection, and on selection put the selected value into a hidden field.

There are several issues:

1) The autocomplete function is not firing
2) The source: "/AutoSuggest.asmx/DOTFind?" line throws an invalid object exception
3) The service requires two parameters: (string prefixText, int count) - count tells it how many records to return.
4) I am not at all certain that this code will accept JSON data that comes back from the service

Here is the code:

[code]....

View 4 Replies

JQuery :: Parse Or Use Returning A String Array From Websevice?

Dec 27, 2010

i wrote a webservice method. i am using it with ajax jquery. method returns string[] array. ho can i read array's values using ajax jquery.

View 3 Replies

JQuery :: Returning A Json String From A Webmethod From An Aspx Page?

Nov 27, 2010

My Problem is that i am returning a json string from a webmethod from an aspx page.

I want to create a dynamic html table using that json string but found no solution for that.

Can anyone Provide me the solution to generate html table from json string ?

View 6 Replies

Jquery - WebMethod Returning JSON But The Response Obj In $.ajax() Callback Is Only A String

Mar 8, 2011

public class JsonBuilder
{
private StringBuilder json;
public JsonBuilder()
{
json = new StringBuilder();
}
public JsonBuilder AddObjectType(string className)
{
json.Append(""" + className + "": {");
return this;
}
public JsonBuilder Add(string key, string val)
{
json.AppendFormat(""{0}":"{1}",", key, val);
return this;
}
public JsonBuilder Add(string key, int val)
{
json.AppendFormat(""{0}":{1},", key, val);
return this;
}
public string Serialize()
{
return json.ToString().TrimEnd(new char[] { ',' }) + "}";
}
}

Here is the Web Method [WebMethod]

public static string GetPersonInfo(string pFirstName, string pLastName)
{
var json = new JsonBuilder().AddObjectType("Person");
json.Add("FirstName", "Psuedo" + pFirstName).Add("LastName", "Tally-" + pLastName);
json.Add("Address", "5035 Macleay Rd SE").Add("City", "Salem");
json.Add("State", "Oregon").Add("ZipCode", "97317").Add("Age", 99);
return json.Serialize();
}................

View 1 Replies

Web Forms :: Unable To Display Required Result When Returning True From JQuery

Feb 9, 2012

I have used the script as follows to display simple alert and confirmation. On confirmation if the result is true i have to execute button click code that was written but i am unable to do that 

<script type="text/javascript">
$(document).ready(function () {
$("#btn").click(function () {
var inputs = document.getElementsByTagName("input");

[Code].....

View 1 Replies

Returning Complex Types (multiple Lists) To Client Side Using Jquery.ajax?

Feb 8, 2011

I'm designing a page which makes an ajax call (via jQuery.ajax) to a page method on the server side.On the server side, I have two classes: Agent and Channel.

In the page method, I'd like to return a List<Agent> and a List<Channel> to the client side. How can I return two lists to client side? should wrap them up in one class like:

[code]....

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved