Showing posts with label call. Show all posts
Showing posts with label call. Show all posts

Saturday, March 24, 2012

my web service call works from one page, not from the other.

have a user control that uses Atlas to call a web service. I drop
this control on a page in the root directory and it works with no
problem. I then add the control to another control, which is on
another page and it will not work. It does not seem to know what the
webService is.

My web service is in the same project and the ascx control and is named
meterCommunication.asmx in a folder called webService.

The control is a button ond onClick it callas a javascript function
that has the following line for calling the web service:
meterCommunication.sendMessage(meterID, commType, _onRequestComplete);

The error that I get is a javascript error that says:
meterCommunication is undefined

I can't figure out what is different between the two pages. Since this
is on a user control they should be identical.

How does the javascript know what meterCommunication is?
I don't know enough about this to troubleshoot the problem.

You need to make sure that you import the web service proxy, either in your page or in the user control. This is done using:
<scriptsrc="/yourapp/subdir/YourService.asmx/js"type="text/javascript"></script>
Maybe you have that only on the page that works?

Need assistance with popup making an AJAX/Webservice

Hi - I would like to have a popup panel appear on a roll-over of an image and then for that panel to call a webservice that hits a database on the backend to populate a gridview. But I have no idea where to start. I would like this panel to have the progress indicator while the grid is loading. Any links/help would be very greatly appreciated.

Thank you,
daveIn the Atlas framework, look at the UpdateProgress control. In the AtlasControlToolkit, check out the HoverMenuExtender and DynamicPopulateExtender.
Thank you. I'm looking now :)

Wednesday, March 21, 2012

Need help with DynamicPopulate and WebService

I'm having a bit trouble getting this to work... I've made a very simple WebService, tested it etc. Everything works fine, I can even call it 'from a normal website as usual', but when I call it from this Extender I keep getting an error:

WebService call failed: 500

This is a snippet from the Extendersetup:

<

atlasToolkit:DynamicPopulateExtenderID="dp"runat="server">
<atlasToolkit:DynamicPopulateProperties
TargetControlID="Panel1"
ClearContentsDuringUpdate="true"
PopulateTriggerControlID="Label1"
ServicePath=http://localhost/wstest/service.asmx
ContextKey="kkl"
ServiceMethod="GetHtml"
/>
</atlasToolkit:DynamicPopulateExtender>

And from the WebService:
[System.Web.Services.WebMethod]
publicstring GetHtml(string contextKey)
{
System.Threading.Thread.Sleep(250);
string value ="";
if (contextKey =="U")
{
value =DateTime.UtcNow.ToString();
}
else
{
value =String.Format("{0:" + contextKey +"}",DateTime.Now);
}
returnString.Format("<span style='font-family:courier new;font-weight:bold;'>{0}</span>", value);
}

Everything is just taken from the samples, but exposed like a WebService.

Any good ideas with this can be??Confused

Kind regards

Make sure you have the webservice stuff in your web.config. The easiest thing to do is to make sure you're starting with a new "Atlas" Website, since it's already set up. If not, I think this is all you need:

<

configSections>

<

sectionname="webServices"type="Microsoft.Web.Configuration.WebServicesSection"requirePermission="false"/>

</configSection>

<

microsoft.web>

<webServicesenableBrowserAccess="true"/>

</microsoft.web>


I've all that in my Web.config - I used the Atlastemplate when I started the project. I've also updated all Atlasfiles to the latest versions.

I've just tested the AtlasControlToolkit and DynamicPopulate and the testharness, i've added the ServicePath right between these:

TargetControlID

="Panel1"
ServicePath=http://localhost/wstest/service.asmx
PopulateTriggerControlID="Label1"ServiceMethod="GetHtml"

Page Method Update:

WebService call failed: 500


Script Method Update:

Script Success

// (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Permissive License. // See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. // All other rights reserved. // Script objects that should be loaded before we run var typeDependencies = ['AtlasControlToolkit.DynamicPopulateBehavior']; // Test Harness var testHarness = null; var panel1, panel2, dp1, dp2; var webServiceResult, scriptResult, customResult; function fireUpdate(targetId) { var target = testHarness.getElement(targetId); testHarness.fireEvent(target, 'onclick'); } function webServiceComplete() { return webServiceResult; } function scriptComplete() { return scriptResult; } function customComplete() { return customResult; } function webServiceSuccess() { testHarness.assertEqual(webServiceResult, "Web Service Success", "Web service call failed: " + webServiceResult); return true; } function scriptSuccess() { testHarness.assertEqual(scriptResult, "Script Success", "Script call failed: " + scriptResult); return true; } function customSuccess() { testHarness.assertEqual(customResult, "Custom Success", "DOM call failed: " + customResult); return true; } function onWebServicePopulated(s, e) { webServiceResult = panel1.innerHTML; } function onScriptPopulated(s, e) { scriptResult = panel2.innerHTML; } function onCustomPopulated(s, e) { customResult = panel1.innerHTML; } function testCustom() { dp1.populated.remove(onWebServicePopulated); dp1.populated.add(onCustomPopulated); dp1.populate("Custom Fail 1"); dp1.populate("Custom Fail 2"); dp1.populate("Custom Success"); } // Register the tests function registerTests(harness) { testHarness = harness; // Get the controls on the page panel1 = testHarness.getElement('ctl00_ContentPlaceHolder1_Panel1'); panel2 = testHarness.getElement('ctl00_ContentPlaceHolder1_Panel2'); dp1 = testHarness.getObject('dp1'); dp1.populated.add(onWebServicePopulated); dp2 = testHarness.getObject('dp2'); dp2.populated.add(onScriptPopulated); var test = testHarness.addTest('Test Page Method'); test.addStep(function(){fireUpdate('ctl00_ContentPlaceHolder1_Label1');}, webServiceComplete, webServiceSuccess); var test = testHarness.addTest('Test Script Method'); test.addStep(function(){fireUpdate('ctl00_ContentPlaceHolder1_Label2');}, scriptComplete, scriptSuccess); var test = testHarness.addTest('Test Custom'); test.addStep(testCustom, customComplete, customSuccess); }

var PageMethods = new function() {var cm=Sys.Net.PageMethod.createProxyMethod;cm(this,"GetHtml","contextKey");}

But still an error... Could there be something wrong with the WebService? An Error 500 is a bit hard to work with. For developing the WebService I just took the ASP.NET WebService-template. I've uploaded the WebService in a folder under the Default Web Site, as you can see in the servicepath. As I mentioned earlier the WebService is working fine if I just manually inputs the path into the browser, also I've checked that the WebMethod satifyes the required signature!

Kind regards


i had the same problem with ajax-toolkit and cascadingdropdown-extender (which is calling a local webservice).

--> WebService call failed: 500

as soon as i deleted the attribute enableBrowserAccess="true" inside <webservice>-section, everything worked as expected. !?