AJAX :: Unable To Make Wcf JSON Ajax Service Work Through Http Like Asmx?

Jun 22, 2010

I am new to WCF, I was using web service asmx before. I have trouble on making my wcf JSON ajax service work through http like asmx.Could you help me see what wrong in my code?My WCF services are defined in my website application folder. My aim is to call this service in my aspx page java-script code and return complex object back as JSON to my javascript. I have no problem on doing this through classic asmx web service.


When I try to test it through my browser by type this in the URL , URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc/GetAll. it return "Method not allowed."

But if I type just this URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc, it return this:

WCFCompanyService Service

You have created a service.To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:

svcutil.exe URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc?wsdl

This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:

C#

class Test { static void Main() { HelloClient client = new HelloClient();

[Code]....

This is my Ajax-enabled WCF service code:

[Code]....

This is the web.config service model setting

[Code]....

View 1 Replies


Similar Messages:

AJAX :: Unable To Use Wcf Service With Json

Feb 13, 2010

I have developed a wcf service for asp.net ajax client. It includes the following steps.

(1) Created WCF sevice contract with the operation "DoWork()" which will take string as input and retun string as output.

(2)Implemented the above operation contract(attributed the implementation class with aspnetcompatibility requirement as enabled).

(3)Added the webscriptenabled to endpoint in web.config file.

(4)Hosted the wcf servie.

(5)Downloaded the javascript file from the service.(e.g.,http://localhost/service1.svc/js)

Client

(1)Opend new asp.net webapplication.

(2)Added the downloaded .js file.

(3)Given the scripts path for ajaxscript manager as both .js file and service url.

e.g

<asp:ScriptManager
ID="id1"
runat="server">
<Scripts>
<asp:ScriptReference
Path="http://localhost:3443/Service1.svc/js/"
/>
<asp:ScriptReference
Path="~/js1.js"
/>
</Scripts>
</asp:ScriptManager>

(4)With this I am unable to call service method

View 2 Replies

WCF / ASMX :: Unable To Make Connection Between Client And Service

Apr 30, 2010

I receive the following error, when trying to consume Wcf service:

"An existing connection was forcibly closed by the remote host". Consuming the service works fine when the host and the client are on the same machine. When I move the client to Hyper-V virtual machine (I didn't try it on a real computer) - it throws the error. Both firewalls are turned off Do you know what can cause such behaviour? Here are the details:

Both the client (hyper-v) and the service are on Windows server 2008 R2

Service url - http://wcftest/CalculatorService.svc (wcftest is the website and is mapped in the hosts file to localhost)

Service config:

[Code]....

Client config:

[Code]....

Are there any configuration settings which I'm missing?

View 1 Replies

WCF / ASMX :: How To Make Web Service Work In A Shared Hosting

Feb 26, 2011

I am trying to put a basic Hello World Web Service in my Go Daddy Shared hosting.

It is a basic default Hello World Web Service that Visual Studio 2010 automatically generates: it works in my local web machine: i can invoke and can see the xml.

I have transferred the Service1.asmx and the Service1.cs file( in the App_Code folder ). I can view the web service page, but I cannot invoke the web service method, and as a result I cannot see the xml file where the "Hello World" string will be in side the <string> element.

Though I can see the web service page, there is no invoke button. How will I invoke or render the content in an aspx page? As the web page has to change the name space, I have changed the namespace to my website address, but still I cannot see or do an invocation and as a result cannot see the generated xml. My question is

1) what should I do so that I can see the return xml value from the web service?

2) what should I do so that I can render the data of the web service in a web page ( for example, in mywebservicepage.aspx)?

[Code]....

View 2 Replies

AJAX :: Dropdown List In Javascript Using Ajax Service But Unable To Get Its Selected Value In Button?

Apr 6, 2010

I am using ASP.Net 3.5. I have fiiled dropdown list in javascript using ajax service but unable to get its selected value in button click event on server side.

View 1 Replies

AJAX :: Making Custom Accordion / Just Make A Button That Would Hide First Pane But Cant Get To Make It Work?

Sep 3, 2010

I would like to make a custom accordion, in which I have 2 panes, but where you couldn't open the second one until you clicked a validation button in the first one that would open the second...

I tried to just make a button that would hide the first pane but I cant get to make it work.

[Code]....

[Code]....

View 7 Replies

AJAX :: Consume .asmx With JQuery (POST Method, Not JSON)?

Feb 4, 2010

The ideal goal is to consume .asmx web service using jQuery like this

[Code]....

View 2 Replies

Pass A String To A Web Service Using JQuery / JSON / AJAX?

Oct 29, 2010

As it is now I create a JavaScript object and then stringify it, put it in a hidden textbox and my code behind can read this string. I then use JSON.NET to parse the string which works fine. I now try to use ajax to post it to my web service but have some issues with how to send the string. I have tried many ways but gets the common errors like

Invalid JSON primitive: myString.

So I checked this out [URL] and it works with hard coded values but I want to use a variable.

JavaScsript to create the object:

for (var i = 0; i < results.rows.length; i++) {
var row = results.rows.item(i);
var customer = new Object();
customer.id = row['id']
customer.name = row['name']
var customerString = JSON.stringify(customer);
$.ajax({
type: "POST",
url: "synchronise.asmx/synchroniseCustomers",
data: "synchroniseCustomers: " + customerString,
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (xhr, status) {
alert("An error occurred: " + status);
},
success: function (msg) {
alert("success");
}
});
}

WebMethod:

public void synchroniseCustomers(string customerString)
{
JObject o = JObject.Parse(customerString);
string id = (string)o["id"];
string name = (string)o["name"];

If I use data: '{ FirstName: "Dave", LastName: "Ward" }'

in the example above it works but I wish to pass on a string instead.

View 2 Replies

AJAX :: Wcf Based Web Service Returns Data In JSON?

Jul 7, 2010

I want to make a web servcie(.svc) that returns JSON data after entering the input.....which is resulted as in the downloaded filein JSON format.i want something like that-http://209.62.6.226/GracoRest/service.svc/Rest/WheretoBuyplease help me for the above but....step by step...i m trying WCF very 1st time

View 3 Replies

AJAX :: Make This Work For Several Days But It Just Doesn't Work?

Oct 7, 2010

i'm trying to make this work for several days but it just doesn't work.

this is my code:

aspx page:

[Code]....

webservice:

[Code]....

this was downloaded from this website.

the problem is that the page loads fine but no autocomplete occurs.

View 5 Replies

Make A JQuery Ajax Call To A Webservice That Needs To Return JSON

Jun 19, 2010

Actually I am trying to learn jQuery Ajax calls to asp.Net webservices.

I have been trying to call the webmethod below:

[code]....

Do I need to serialize my object in some way before setting the 'data' attribute, so that I can call $.ajax() function?

View 2 Replies

AJAX :: Use Return JSON Object From Web Service As A Declared Type?

Jan 3, 2010

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.

View 3 Replies

AJAX :: Add Http Header When Use Call Web Service?

Aug 4, 2010

I have one ajax call web service, and want to add some http headers using javascript, can we do that use setrequestheader in ms ajax?This is my javascript

[Code]....

[Code]....

View 3 Replies

AJAX :: Http 417 Error While Calling A Web Service?

Apr 20, 2010

i got a this exception when i calling my web service in producction server.i already test the web service in server side and this don't have problemasbut when i calling the web service in the development site this throw a

(spanish)"Error de la solicitud con el código de estado HTTP 417: Expectation failed." or
(english)"The request failed with status code HTTP 417: Expectation failed."

View 3 Replies

WCF / ASMX :: Read Data From Json Web Service?

Dec 16, 2010

I'd like to read data server-side from a web service that outputs in json format. I haven't found any good examples that don't use jquery and are server-side.

Specifically I'm looking at the "weight" field from this api:

[URL]

PS: this is a spin off of another post at: [URL]

View 6 Replies

WCF / ASMX :: Return JSON Data From A 2.0 Web Service?

Sep 10, 2010

Just ramping up on JSON and JQuery and returning data to a ASP.NET web page from a web service using Ajax. The JQuery part is pretty straight-forward. However, when trying to return JSON formatted data instead of XML from a 2.0 web service, I'm stuck. The web service does have the System.Web.Script.Services.ScriptService attribute, so I can hit it via JavaScript; however, the web service always...always...returns data in XML format, no matter if I explicitly say I want JSON as the datatype in my JQuery code. So I don't know if this is an issue with the web service or the JQuery code. I posted this here, but realize that the category could be incorrect depending on where the issue is. Is there no way to return JSON data from a 2.0 web service? It's a production web service, so I can't change the code unfortunately.

View 3 Replies

Unable To Pass User Credentials From WCF Web Service To ASMX Web Service

May 25, 2010

My WCF Client calls my WCF Service which then calls ASMX Web Service. The problem is i have configured my wcf client and wcf service to windows credentials type but when wcf service calls asmx service the user credentials (default windowsidentity) is not passed to asmx service.

In WCF Service i am able to get user identity by using : Thread.CurrentPrincipal.Identity.Name;
WCF Service - i have disabled anonymous access and enabled windows authentication. ASMX Web Service - i have disabled anonymous access and enabled windows authentication.
WCF Service Config
[Code]....

View 1 Replies

Jquery - Why 3 Extra HTTP Requests Are Done If You Use Ajax Call To A .net Web Service

Apr 4, 2011

When I was reading the blog Using jQuery to Consume ASP.NET JSON Web Services

I have seen this argument:

"By using jQuery to call the web service directly, we've eliminated over 100 KB of JavaScript and three extra HTTP requests. "

Why does the ASP.NET AJAX call to a .NET Web-Service needs 3 extra HTTP requests? What are those requests? (I wonder how jQuery manages the call with lesser HTTP requests in this case).

View 2 Replies

WCF / ASMX :: HTTP Post To Web Service?

Sep 16, 2010

have a web service that I'm trying to consume from a console app through http post. I receive a 500 exception error from the xmlstring parm being passed to the web service. Add the following to web.config of the web service. Although it is not working in debug in vs 2008 as well.

[Code]....

[Code]....

[Code]....

the host file is setup for the web service as well.

[Code]....

View 6 Replies

C# - Can't Make Ajax Work With MVC 3

Dec 25, 2010

This is my Controller method

[HttpPost]
public ActionResult RemoveValue()
{
return View();
}

And this is how i am trying to access to method

@Ajax.ActionLink("Asenkron process", "RemoveValue")

But if i remove HttpPost attribute then it works. I have tested this on MVC 3 RC 2

View 2 Replies

WCF / ASMX :: Connecting To Web Service Via Http Post?

Jul 22, 2010

My web service uses .Net Framework 2.0. An e-learning application reads and updates an Access database in the web service via Http Post commands. I test the e-learning application and the web service using the version of IIS 7 that came with Windows Vista. I run IIS using localhost in my browser.

All works well. But a friend is having trouble running the same test with my files on her IIS 6 server. So I'm developing a checklist of issues in setting up an IIS 6 server to run a web service. I plan to include all possible causes of problems including permissions, accounts that are needed, etc. Are there resources to which I can go for this checklist?

View 1 Replies

AJAX :: Unable To Get Any Extender To Work?

Apr 13, 2010

I am using VS2008 sp1 professional. I added the .Dll toolkit that is most recent my page loads fine but with no extiontion ie. no calender will pop up or no water mark will show ??

[Code]....

View 4 Replies

AJAX :: ASMX Call Does Not Work In Dataview?

Apr 23, 2010

I have just started with ajax, therefore I have no clear ideas jet.

I'm following HOW TO Call ASMX Web Services tutorial, but how you can suppose, something doesn't work properly.

I have created a web service (code below)

public class Customer

View 6 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

WCF / ASMX :: Calling A Remote Or Local Web Service That Returns A JSON With JQuery?

Mar 16, 2011

how to create a Web service that returns a JSON(or JSONP). That also should be able to work for cross-domain access aswell as for a local call.. help to get this working or for a few links for further reading about this

View 2 Replies







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