7 Replies Latest reply on Mar 30, 2012 3:06 PM by Simon Wood

    HTML5 Web Services

      I have a doubt regarding HTML5 Web Services. I tried to access a sample Web Service from HTML5, but not able to access. [The same web service is able to access from ASP .NET].

      The web service return 'Hello World'.

      I am using RhoElements 1.0. I tried this to run from Desktop  itself[Both Program in same computer]. The HTML5 Program I have written is given below.

       

      <!DOCTYPE html>

      <html>

      <head>

      <title>Hello World</title>

      <script type="text/javascript">

      var iCallID;

      function InitializeService()

      {

       

      service.useService("http://localhsot/getService/Service1.asmx?WSDL", "HelloWorldService");

      service.HelloWorldService.callService("HelloWorld");

       

      }

      function ShowResult()

      {

      alert(event.result.value);

      }

      </script>

      </head>

      <body  onload="InitializeService()" id="service" style="behavior:url(webservice.htc)" onresult="ShowResult()">

          </body>

      </html>

       

       

      I tried using ‘Json’ also but still not producing result.

      Reply soon

        • Re: HTML5 Web Services
          Daniel Silva

          Not sure if this is the problem, but "localhost" is misspelled.

          • Re: HTML5 Web Services

            Yep, "localhost" is spelled "localhsot"

              • Re: HTML5 Web Services

                Aric,

                Thanks for your reply.That was a type error. i have spelled correctly. but not getting the result.

                My Web service is as follows:

                 

                using System;

                using System.Collections;

                using System.ComponentModel;

                using System.Data;

                using System.Diagnostics;

                using System.Web;

                using System.Web.Services;

                using System.Xml;

                 

                service1.asmx.cs

                 

                namespace getService

                {

                          /// <summary>

                          /// Summary description for Service1.

                          /// </summary>

                          public class Service1 : System.Web.Services.WebService

                          {

                                    public Service1()

                                    {

                                              //CODEGEN: This call is required by the ASP.NET Web Services Designer

                                              InitializeComponent();

                                    }

                [WebMethod]

                                    public string HelloWorld()

                                    {

                                              return "Hello World";

                                    }

                }

                }

                  • Re: HTML5 Web Services
                    Robert Galvin

                    I would suggest you try loading the same html that you are trying to load with RhoE inside of Chrome browser on your desktop. Then look at the Chrome developer tools to help debug. Does it work here and not in RhoE?

                     

                    Sent from my Verizon Wireless 4G LTE DROID

                      • Re: HTML5 Web Services
                        Adel Sari

                        Hi Rob,

                        Trying to access web service (the same holloWord example listed above) fails for me,

                        i have download the webservice.htc file from Microsft web site, and test in google Chome (18.0.1025.142 m).

                        The error generated is:

                        1. Uncaught TypeError: Object #<HTMLInputElement> has no method 'useService'
                          1. callWebService
                          2. (anonymous function)
                          3. onclick

                         

                         

                          • Re: HTML5 Web Services

                            I'd guess the chance of this working on anything other than IE is low.

                             

                            Make your webservice JSON compliant and use the Rho::AsyncHttp.  The attributes you'll need for your web service method are:

                             

                                interface IMyInterface

                                {

                                    [OperationContract]

                                    [WebGet(UriTemplate = "Job/{callsign}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]

                                    List<JobData> MyMethod(string callsign);

                             

                            Don't forget the WebHttpBehaviour on the endpoint