Losing Scope after client-side call to Web Service

Hello, thank you in advance of taking the time to read this.

I seem to be losing all page scope after a client side call to a web service.  This hasn't happened before, but admittedly this is the second time I have done client-siding, so I am hoping I am missing a setting or something.

In the example code below, getBedTypeCount() returns '5', which is supposed to modify the global variable helloWord.

The alert(result) returns 5, but as soon as the setBedTypeCount() completes, the scope is lost and helloWorld returns to the default value of 1.

I also tried inserting result into a form field value.  The form field correctly shows '5' after the web service is called, but then if I try to later do a formField.value, the result is empty.

Any help on this would be greatly appreciated!!!

 

<head runat="server">

<title>Untitled Page</title>

<script>

var helloWorld = 1;

function getBedTypeCount(){

AQWS.GetBedTypeCount('',setBedTypeCount);

}

function setBedTypeCount(result){

alert(result);

helloWorld = parseInt(result);

 

}

function setForm(){

alert(helloWorld);

getBedTypeCount();

alert(helloWorld);

}

</script>

</head>

<body onload=setForm()>

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods=true >

 

<Services>

<asp:ServiceReference path="MyWebService" InlineScript=false />

</Services>

</asp:ScriptManager>

 

</form>

</body>

</html>

 

0
mrgr8avill
11/16/2007 3:05:46 PM
asp.net.networking-webservices 2181 articles. 0 followers. Follow

3 Replies
1093 Views

Similar Articles

[PageSpeed] 7
Get it on Google Play
Get it on Apple App Store

Okay -- figured out that the scope is not being lost, but rather has not yet been modified (the Asych is stil lupdating by the time the global variable gets called).  How to wait for response using a call to web service?

 

Thanks!!

0
mrgr8avill
11/16/2007 4:15:17 PM

As the client-proxy method is invoked asynchronously the alert(helloWorld); call will be invoked regardless of the web service status. You should invoke the alert from within the assigned on success handler.

The XMLHttpRequest object used by the request executor of ASP.NET AJAX statically sets the execution type as asynchronous not synchronous.

Hope this helps.


Matthew Ellis
ASP.NET 3.5 AJAX Pocket Guide
Amazon.com || MI
0
Matthew
11/16/2007 4:50:13 PM

Thanks, Matthew!!  Since I was calling the update to the global variable from the OnSuccess callback function, I figured all was well.  What I found to be happening though was that the main thread took a few microseconds to update the global variable beyond the function scope.  All I had to do was swap some function calls around so that the global variable was not retrieved immediately following the update, but instead after doing a copule of other things, and all was well.

God I love learning by being kicked in the head for hours at a time.  Sure sticks with you that way though.  Thanks again for your reply and infromation -- I really appreciate the time and effort you and otherm members make to help others here.

0
mrgr8avill
11/16/2007 5:46:24 PM
Reply:

Similar Artilces:

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

Calling a web service in client side C#
Hello,  I am trying to call a web service in client side C# code, having it as a datasource on the page to use. I cannot have a codebehind file due to limitations. Does anyone know how to do this or have suggestions?  Thanks! What do you mean by "client side C#"? -- "Mark As Answer" if my reply helped you -- Hi check this link http://aspdotnetcodebook.blogspot.com/2008/04/how-to-call-webservice-with-aspnet-ajax.html   if you have any problem.. feel free to contact.     "Mark As Answer" If my reply helped you Santosh kuma...

Query on webservices :-- client calling a web service
Hello there I am not sure, this is the right forum. I am trying to post a question and this forum represented quite closed to what i need. Basically, i wrote a webservice ( a very simple one), it returns a string when i call the webservice directly from the browser and click the invoke button. Now i created a proxy of this webservice and i wrote a web page and tried calling my webmethod. Now i get an error with the message Client found response content type of 'text/html', but expected 'text/xml'. The request failed with the error message: -- ...

How To: Call a Java EE Web Service from a .Net Client
Hi, I have to call a Java Web Service from a .Net Client .I'm using VS2008 (.net 3.5) Did you face the same situation ? The web service offers some methods. Each method returns a xml file and a xml attachment. I found this article.http://blogs.msdn.com/bursteg/archive/2008/07/19/how-to-call-a-java-ee-web-service-from-a-net-client.aspx . Do you think that this is a good resource ?  I watched something about WCF. Have I to use WCF ? How can I manage xml attachment ? thank you for your attention .     It's a good resource and there are also other way...

Call remotely hosted web service from client-side?
All of the examples I have seen call the *.asmx file using a relative path but I need to reference a URL such as http://www.domain.com/webservice.asmx to call a remote web service. In the Atlas days I believe this was done using a bridge (*.asbx) but I can't seem to find any recent information regarding this method. Does it still exist? Anyone know how to accomplish this? Thanks, Janea Hi, my buddy Garbin (Allesandro Gallo) wrote an interesting article about this recently: Mash-it Up with ASP.NET AJAX: Using a proxy to access remote APIs. Grz, Kris.Read my blog. Handy Firefox ...

null parameter problem while calling .net web service from java client
Hello, I have a C# .NET web service and a Java client . My java client is able to call the C# method , but when the client calls methods containing complex type parameters , they are ending up being null on the .net side eventhough I am sending the parameters with valid values. I traced also the SOAP messages and they are also semms OK. But why are they arriving null to .net side. What goes wrong? Did anybody whom faced this problem could solve it and how. As I see this is a very common problem as I searched similar forums. So any acceptable answer will be useful t...

Browser Freezing / Locking Up on Async Client Side Web Service Calls
I have an application that uses AJAX and WCF. On some of the pages, some of the time (not consistently), when making an asyncronous web service call and an exception is thrown by the WCF service, the error handler delegate on the client is called correctly, passing the parsed fault and context, and then I do something with the error by injecting the message in a div then displaying that div using a ModalPopupExtender from the AJAX Extensions Toolkit. The modal always displays correctly and makes displaying errors pretty slick, however sometimes when clicking a button in the modal, ...

Call a SECURED (with glassfish) Java EE Web Service from a .Net Client
Hi, Im trying to call a java web service in visual studio 2008 using a simple forms application. The problem that I'm running into is with the security. Can someone point me in the right direction as far as calling a secured java EE web service using .Net? Thanks. Adam Im unfamiliar with glassfish, however if the web service's security is WS-Security compliant, then you'll have to use WSE 3.0 (addon by Microsoft to make web services more useful) or Windows Communication Foundation. Thanks for the reply. Can you point me in the direction of using WSE to call a java...

Web Service Client Calls to Service in DLL
Hello, In order for the proxy to be generated, does the web service has to be an ASMX file?  It can't be in a class library?  If it can be in a class library, how do you reference it with script manager? Thanks.Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4). It will need to be either an ASMX or SVC (WCF) service, or a page method, in order to get the JavaScript proxy generated.Of course, you're still free to leave the heavy lifting to yo...

Bind data to the grid at the client side using AJAX call to web service
With the Current AJAX Tool kit is there a way to databound the grid at the client side.  Basically I want to make a WCF web service all and get the JSON message and populate the grid at the cient side. I am using Visual studio 2005 with .NET frame work 3.0. Please point out if tehre are any examples. I truly appreciate any help regarding this. Thanks I hope this article will help you. http://www.aspdotnetcodes.com/Ajax_ModalPopup_PostBack_GridView.aspxMarking a Reply as 'Answered', not only GAIN us some POINTS, but it also HELP others to find RIGHT solution. Thanks for the...

Not able to access FoxPro database file on network from a Foxpro dll called from .Net Web service
Hi,I have an Active Server Pages (VB Script) application that calls a .net(2.0) web service and the web service calls a Foxpro dll to access the Foxpro database. If the Fox database is on the local machine it works fine. If the Foxpro database is on the network share the Foxpro dll gives me "File does not exist" error message.Seems to be some kind of permission issue. I tried to run the .Net Web service application under a domain user with full access to the network share(using <impersonate) as specified in the following KB article.http://support.microsoft.com/kb/307901#4c I...

Calling a Web Service from a Web Service
Hello,I was looking for some feedback on calling a web service from within a web service. I've heard that it's not good practice (or not possible). I have a scenario where I think it might make some sense.Within our infrastructure, we've created a web service that handles incoming updates on the statuses of all processes. This has proven to be a good thing since it allows applications to communicate across server to make status updates. It's also used by third party developers and applications to communicate with our infrastructure.Along these lines ... we are planning to create a new compon...

.NET CLIENT TO ACCESS a non. NET WEB SERVICE
I develop in .net and need to create a web client to connect to a web service built in Java. http://xchainj.com:8080/axis/services/ScsEnvirodatWaterQualityIndexServiceSoap Its pretty easy when the web service was also built in .net. You can just create a web reference with the gui and automatically can see its functions and stuff. when i put this url in the box and hit go i dont get to see its functions. maybe this shouldnt be the url of the WSDL?? I Have no idea. Im very new to all of this. If there are any examples of .net clients connecting to non .net web clients it woul...

How to call .net web service from Java web application?
Hi all,  I have a vb .net web service.How do i call .net web service from Java web application?What all resources I need?Can you please provide a sample application where a java application is invoking methods of .net web service? Thank you Hi, First I am not familiar with java language, but web services are universal operating system and language independent. It doesn't matter where the services is or in what language is written you just invoke it  and it gives you "replay".  Probably you must reffer to java consuming web services.   Regard...

Web resources about - Losing Scope after client-side call to Web Service - asp.net.networking-webservices

Client-side scripting - Wikipedia, the free encyclopedia
... different and changing content depending on user input, environmental conditions (such as the time of day), or other variables. Client-side ...

Senior Search Manager - Client Side!!
... strategy insight for senior IT management - resources to understand and leverage information technology. Senior Search Manager - Client Side ...

Account Manager - Client Side - Previous Agency Experience Welcome!!
Computerworld Australia is the leading source of technology news, analysis and tools for IT decision makers, managers and professionals.

Media Sales Executive - Client Side!!
Technology news and reviews for business and home.

PPC Paid Search Manager - CLIENT SIDE
Defining Technology for Australia's IT Leaders. PPC Paid Search Manager - SEM - **CLIENT SIDE** Sydney CBD Location Client side!! SEM/PPC/Paid ...

How Basecamp Next got to be so damn fast without using much client-side UI
When we started working on Basecamp Next last year, we had much internal debate about whether we should evolve the existing code base or rewrite ...

Seven Tips for Pitching From the Client's Side of the Table
I had a chance to sit on the other side of the pitch table. Here is what I learned.

Client-side coding: How to prevent malicious use?
Applications that run on a user-controlled device cannot be perfectly protected.

The client side
... regarding the professionals you seek to assist. Even better if you possess that understanding yourself, having worked on the client side. I'm ...

Ecommerce traffic being hijacked by client side malware
According to new research 15 to 30 percent of eCommerce site visitors are infected with Client Side Injected Malware (CSIM) that causes them ...

Resources last updated: 12/1/2015 9:25:50 PM