Showing posts with label exposing. Show all posts
Showing posts with label exposing. Show all posts

Monday, March 26, 2012

Exposing Web Services from an ASPX page does not work

Hi All,

I am working with ATLAS technology. i am trying to imitatehttp://atlas.asp.net/quickstart/atlas/doc/services/default.aspx#webpage
"Exposing Web Services from an ASPX page"

i am having an aspx page which is inherited from our own Page class not from System.Web.UI.Page.

public partial class MainSearchPage : some namespace.MyPage

but this example does not work in this context.because in javascript, function OnWebRequestComplete1(result) returns null as result.

please help me in this issue.

thanks
Jaideep

hello.

well, i think that it should work. here's an example:

pypage.cs
namespace Test
{
public class MyPage:Page
{
[WebMethod]
public string HelloWorld(string s)
{
return "Hello '" + s + "'";
}
}
}

now, the aspx page:


Untitled Page

function handle()
{
PageMethods.HelloWorld( "Luis", handleComplete );
}

function handleComplete( res )
{
alert( res );
}

here everything is working properly...

Yes, this should work. To debug your issue, I would try:

Check on the server whether your method gets called at all.

yes, my server side code in code behind of aspx is not getting called.
in javascript side:

function handle()

{

PageMethods.HelloWorld("jaideep", handleComplete );

}

function handleComplete( res )

{

debug.dump(res,"Result",true);

alert( res );

}

in debugger, result is null.also my aspx is having one user control also.i tried to put debug in my code behind.but function HelloWorld is not getting called.

any clue as to what is happening.
thanks

jaideep


after viewing request/response in Fiddler ,i got a message indicating a corrupted viewstate.
same is the problem in following post:
http://forums.asp.net/1205269/ShowPost.aspx "ViewState and Atlas ".
and as per the instruction given , i removed "type =="hidden" condition from file
Atlas.js on line 3495.and now it is working!! but this approach is correct or not?
please let me know about this.
Thanks

JAideep


Copying my reply from the other thread:

I tried a few things, but was not able to repro. Could you give this a try with the March CTP to see if it still happens?

thanks,
David

Exposing Web Services from a custom control

In one of quickstart tutorials there is a way to use a WebMethod straight in the aspx.page(http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx#webpage)

<%@dotnet.itags.org. Import Namespace="System.Web.Services" %
...

<script type="text/C#" runat="server">
[WebMethod]
public string HelloWorld(string s)
{
return "Hello '" + s + "'";
}
</script>

This example calls

PageMethods.HelloWorld(document.getElementById("nameTextBox").value, OnWebRequestComplete1);
on the client side

I am developing custom controls and am wondering if I can call a WebMethod from within my custom control.

I would imagine I have to register the namespace and class of my custom control but I don't know how. It obviously works on the aspx page because of the built-in PageMethods function

IMHO, you can't do this in the current version of Atlas because the Atlas Server Library doesn't provide this future. It will be necessary to look through control tree searching special methods... And Atlas must have an ability to know, which instance of webcontrol was called by client script. It's very difficult, as I think.

Exposing Web Services defined in class libraries

I have a class library (or will have) that defines a bunch of web services. I can reference Atlas if necessary. How do I expose all these web services to Atlas via IIS/ASP.Net. In other words, I do *not* want the code for my web services to be in the web project, I want them to be in an external project and optimally just included with a single line for all services, or a line per service if necessary.

Thanks.

All you need to do is to add your assembly as a reference to the web project and then add it to the ScriptManager service reference as following:

 <atlas:ScriptManager ID="ScriptManager1" runat="server" > <Services> <atlas:ServiceReference Type="namepsace.typename" /> </Services></atlas:ScriptManager>

Replace the bold text with the type name of your web service.


Seems that this has changed since way back when... How do I reference a service in a class library now? How do I then hook it up to an extender, e.g. an AutoCompleteExtender?

Thanks.

Exposing web service that returns DataSet

Hi,

Is there anyway to call web service(asmx) method that returns DataSet from client javascript that uses

AJAX <ScriptManager> (that generates auto js proxy) , I know that custom classes works as a return value, what about DataSets?

If Yes I can I process those DataSets , in client callback functions?

TNX

Leeor

leeorc

dont know if you can do this and whether it is an issue for you but if you do move to datasets then you will be restricting your web service to .net consumers only


http://weblogs.asp.net/infinitiesloop/archive/2006/12/14/ajax-futures-december-ctp-returning-datasets-datatables-and-datarows-from-a-webservice-or-pagemethod.aspx

Exposing methods in ASP.NET AJAX Control Project

I've read every bit of documentation that I could find online (which isn't a lot) about creating your own extender with the ASP.NET AJAX Control Project. There are lots of examples about how you expose the properties in the Extender.vb or Extender.cs file, which passes the values down to the .js file. But is it possible to expose callable methods? I can add handlers forevents, but what about methods you can call at any time?

If anyone can give me an example of the proper syntax to do this, it would be greatly appreciated. Thanks.

You can't expose methods from the .cs or .vb file of your control; you'll need to use webservices or pagemethods to call a server method.

I don't want to call a server method, I want to expose a function in the Behavior.js.


Do you mean callable by JavaScript or Server-Side Code ?

all methods in your behavior.js in the Prototype section are callable methods.

You can call methods using the

$find(BehaviorID).Method() notation


Thank you for the response. That's what I needed, but just out of curiosity, is it possible to "expose" those methods to the servers side... much in the same way that the properties in the extender.cs file exposes the properties in the behavior.js file?


No.

The properties in the .cs file will be injected into the output html, and some initialization logic implemented in javascript is responsible for initializing the component with those properties.

Basically, server side object and client side object can't access each other directly.

Exposing desktop applications to the web through AJAX

Hi,

I would like to present a very impressive application that provides access to a desktop only application through the web. This is a power full demonstration of the capabilities of Visual WebGui which is an open source framework that provides WinForms like development for developing web application.

Here is a link to a web cast showing this application:

http://www.networkd.com/demos/inferno/ 

Hope you find this intriguing enough to find our more about Visual WebGui (http://www.visualwebgui.com). If you do I would be happy to give you guys more information.

Cheers,
Guy

Hi,

As far as I know, AJAX isn't design to do that.

I have searched a lot for your, and found you post this topic to several forums.

I agree withW3bbo's reply athttp://channel9.msdn.com/ShowPost.aspx?PostID=359753

?The web isn't winforms though, and I believe it's a fallacy to try to mimic local apps within a browser. Remember, the author has very little control over the client and webapps are much easier to break, abuse HTTP, place tight requirements on the client end (often requiring client script (or worse) to be enabled), and have a disproportionately long development time.

Not forgetting the WYSIWYG paradigm they're based on, when the web is inherently WYSIWYM.

Never mind how not a single GUI framework for the web has full compliance with the specifications.

How is this project justified?

If you have further question,let me know.

Best Regards,