facebook

Error While Connecting to WebService: CLOSED

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #325058 Reply

    anjads
    Member

    Dear,

    I developed a web service that it should return JSON data format as below in ASP.net, and I deployed this web Service into my local IIS as below. Then i am trying to call the webservice from a javascript in the custom javascript file but it gives me error, please how can i call an ASP.net web service from MobiOne.

    Below are the service code and the Javascript that I wrote in MobiOne custom java script file

    —————————————-
    Web Service Code
    —————————————-

    Imports System
    Imports System.Web
    Imports System.Collections
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Web.Script.Serialization
    Imports System.Web.Script.Services
    Imports System.ComponentModel

    <System.Web.Script.Services.ScriptService()> _
    <System.Web.Services.WebService(Namespace:=”http://localhost/&#8221;)> _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <ToolboxItem(False)> _
    Public Class WSRes
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function getConfigurationValueByKey() As String

    Dim strConn As String = My.Settings.strConn

    Dim sqlConnection As SqlConnection = New SqlConnection(strConn)
    sqlConnection.Open()
    Dim sqlCommand As SqlCommand = New SqlCommand(“SELECT * FROM tblRes WHERE [Country] ='” + “KW” + “‘;”, sqlConnection)
    Dim sqlDataset As DataSet = New DataSet()
    Dim sqlDataAdapter As SqlDataAdapter = New SqlDataAdapter(sqlCommand)
    sqlDataAdapter.Fill(sqlDataset)
    sqlConnection.Close()

    Dim MArray()() As String = New String(sqlDataset.Tables(0).Rows.Count)() {}
    Dim i As Integer = 0
    For Each rs As DataRow In sqlDataset.Tables(0).Rows
    MArray(i) = New String() {rs(“Country”).ToString(), rs(“ResName”).ToString()}
    i = i + 1
    Next
    Dim js As JavaScriptSerializer = New JavaScriptSerializer()
    Dim sJSON As String = js.Serialize(MArray)
    Return sJSON
    End Function
    End Class

    —————
    JavaScript
    —————
    function AddRest() {

    var theDropDown = document.getElementById(“m1-MainPageRes-hidden-select-combobox2”);
    $.ajax({ type: “POST”,
    url: “http://localhost/WSRes.asmx/getConfigurationValueByKey&#8221;,
    contentType: “application/json; charset=utf-8”,
    data: “{}”,
    dataType: “json”,
    success: function(response) {
    alert(response);

    },
    error: function(req, status, error) {
    alert(error);
    alert(req);
    alert(status);
    }
    });

    var thedrop =document.getElementById(“m1-MainPageRes-combobox2”);
    var optn = document.createElement(“OPTION”);
    optn.text = “Haha”;
    optn.value = “Haha”;
    theDropDown.options.add(optn);
    theDropDown.options.selectedIndex = 0;
    thedrop.innerText = optn.text;

    }

    The Error I Am Getting Not Known as below
    See attachment Error.png

    Attachments:
    You must be logged in to view attached files.
    #325060

    support-michael
    Keymaster

    @anjads

    Some tips:

    1) Turn off the local web server (Window>Settings>Local Web Server). Then run your mail UI in the test center or load it from file system, url = file://... By running from file:// you should not experience any same origin issues

    2) In Test Center open Tool Panel and Debug into your code. Set a breakpoint an step. Many times you can find your problem watching the execution.

    #325074

    anjads
    Member

    Thank you for your reply, I did what you sent and it worked perfect,

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Error While Connecting to WebService: CLOSED

You must be logged in to post in the forum log in