Consuming Web service from .net 3.5 web application using ajax

Hi , Before in .net 2005 ,I use to consume the  web service from client side via Ajax and java script. that's just adding web service inside the script manger services.

But  it was not possible with .net 2008 version WEB APPLICATION   , Even it works well with .net 2008 web sites.

 Please help me to solve the issue.

0
maheshwaran
11/19/2008 10:54:48 AM
asp.net.client-side 24353 articles. 2 followers. Follow

5 Replies
1547 Views

Similar Articles

[PageSpeed] 46

I have no idea what you mean. Please post the code that "does not work".

NC...

 

0
NC01
11/19/2008 2:34:49 PM

I have the same problem.  I have a .NET 3.5 Web Application not Web Site.  I fully qualify the web service with the namespace i,e,

    ClientServices.ControlServer.HelloWorld(controlName, SucceededCallbackWithContext, FailedCallback, HTMLtarget);

The webservice it self is decorated with the ScriptService and the WebMethod is decorated with the WebMethod and the ScriptMethod attributes:

        [System.Web.Script.Services.ScriptMethod(ResponseFormat=System.Web.Script.Services.ResponseFormat.Xml,UseHttpGet=true,XmlSerializeString=true)]
        [WebMethod]
        public string HelloWorld(string message)
        {
            return message;
        }

I register the script and the service in the script manager.  I then trigger the function and get the javascript error of 'ClientServices' is not defined

p.s. not sure if this is an IE8.0 bug with the asp.net forum but if you scroll while making a quick reply so it is out of view you lose everything you have just written


Cheers,

Andrew
Blog : andrewrea.co.uk
0
REA_ANDREW
11/19/2008 3:57:44 PM

  Here the error was, 

   To use the web service in java script i use the below code,

   <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="MySampleService.asmx" />
            </Services>
        </asp:ScriptManager>

 Which called by using the statement  MySampleService.Helloworld()  in java script, Which works good in 2008 web sites but not in 2008 web applications the script error says "MySampleService was not defined"

 

0
maheshwaran
11/20/2008 4:03:36 AM

 Hi,

I have similar problem and I solved this issue .......

Just simply change the nameSpace

using System.Web.Script.Services;

 

namespace Khalid99h

{

 

    [WebService(Namespace = "http://localhost:49232/Khalid99h/")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    [ScriptService]

   public class Service : System.Web.Services.WebService

    {

 

    .............

//rest of your code..........

 }

 

}

 

 

Now you can access this web service like this: 

//Java script OR Code behind file

<script type="text/javascript">

 

    function CallNextDate()

    {

        Khalid99h.Service.HelloWorld( );   //assume there is a function in web service Helloworld()

    }

 </script>

 

 



Hafiz khalid nawaz
Team Lead(.NET)
eSoul consultancy pvt ltd
0
khalid99h
12/23/2008 11:00:04 AM

Hello Thank you very much i will try andlet you know

0
maheshwaran
12/23/2008 11:35:01 AM
Reply:

Web resources about - Consuming Web service from .net 3.5 web application using ajax - asp.net.client-side

Application - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Pre-Christmas job application rush hits Australian public service
Speed required for pre-Christmas job window opening for public servants. Check out who is hiring.

Cloud application adoption increases 71 percent in 2015
The adoption of cloud applications is soaring, up by 71 percent in the last year according to the results of a new survey. The latest Cloud ...

Tashfeen Malik's visa application under scrutiny - Business Insider Deutschland
The US government has released the visa application for Tashfeen Malik, who along with her husband killed 14 people in an attack in San Bernardino, ...

MBA: Mortgage Applications Increase in Latest MBA Weekly Survey, Purchase Applications up 37% YoY
From the MBA: Refinance, Purchase Applications Both Up in Latest MBA Weekly Survey Mortgage applications increased 7.3 percent from one week ...

German-Based Spirea Promotes Decentralized PV Applications In Uruguay
... Its technical operations specialist, Laurie Lawrence, pointed out that Uruguay [&hellip German-Based Spirea Promotes Decentralized PV Applications ...

Visa application of San Bernardino shooter released
CNN Visa application of San Bernardino shooter released CNN (CNN) The visa application of one of the San Bernardino shooters was released ...

ZTE to develop smartphone application processors in house
ZTE has stepped up its efforts to internally develop smartphone chipset solutions, aiming to re-capture the title as one of the top-three smartphone ...

Pre-K Applications Begin Jan 25, a Month Earlier Than Last Year, City Says
The DOE has moved the process up to Jan. 25 on the heels of a similar schedule shift for kindergarten. MANHATTAN — The application period for ...

NASA accepting applications for the position of 'astronaut'
Wanted ads aren't usually newsworthy, unless the company is NASA and the job is "going to space." The US space agency has started recruiting ...

Resources last updated: 12/23/2015 3:18:41 PM