Showing posts with label consuming. Show all posts
Showing posts with label consuming. Show all posts

Wednesday, March 28, 2012

Consuming services from another application with Cassini

I have two projects in a solution: a Web Application (UI) project and a Web Service project. I can't get the UI to consume a web service if the projects are running using the built-in web server. My OnCompleted or OnError callbacks never get called. However, it works if I use IIS.

So the client ishttp://localhost:4312/default.aspx and it references the service using:

<atlas:ServiceReferencePath="http://localhost:1234/Service1.asmx"/>

If all I do is make them both IIS apps then change the reference as follows, it works a treat:

<atlas:ServiceReferencePath="/ServiceApp/Service1.asmx"/>

Is this because Cassini's use of different port numbers makes this appear as a forbidden cross-domain call?

BTW, I obviously made sure that Cassini was listening on both ports.

If the port's not the same yes you will get a crossdomain error.

But I don't think that's the only issue. Cassini listens to a specific port and sets up the ASP.NET runtime for a specific virtual directory. 1 port, 1 Virtual directory, 1 instance of Cassini.So unless youhave two separate instenaces of Cassini running the call won't work because it's effectively only servicing a single application. You'll need two instances of VS or Cassini to make this happen and I don't think you can do that either because only one instance can listen on a given port.

So, no you probably can't do that <s>... Use IIS and separate virtuals.

+++ Rick --


Yeah, thanks Rick. That's pretty much the conclusion I've come to. But I find it strange that the port is considered part of the domain. Cool blog by the way.

Stu

Consuming JSON Web Services?

Howdy,

I noticed that Atlas uses JSON to serialize/deserialize objects. Has anyone written an example of the best (most efficient, most elegant) way to consume a JSON Web service from an Atlas application?

(An example of the data I'd be going after is here: http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?appid=jeffreymcmanus&query=bill+gates&results=2&output=json)

If you add "&callback=showResults" to the query, it will come back packaged to pass the JSON data into your custom "showResults" javascript method. Basically, you are getting back a string of client script. It's up to you how you want to handle it in the browser with your own javascript.

At least to me, that's the most elegant way, which is pretty much what you asked.

Peter

Consuming a webservice from a custom control extender

I am making a first attempt at writing own extender using the toolkit, and I need to consume a web service. When I Google on Ajax and webservice, I get a lot of articles, but they all seem to involve modifying the ScriptManager tag to point to the web service I want, and you can't rely on that from an extender paradigm. I know the autocomplete control uses some sort of web service, but picking the code out is tough. Is there a plain vanilla, Hello World type of example of how to consume a web service from a custom control extender?

There seems to be a couple of ways to do this, check this post:

http://forums.asp.net/t/1163304.aspx

Although I like mine betterSmile

Hope this helps,

Elias.


Thanks Elias, that's what I was looking for.