Web services VB.Net chiamati da JQuery

di
Anonimizzato28682
il
5 risposte

Web services VB.Net chiamati da JQuery

Buongiorno a tutti,
espongo un mio problema a cui, per ora, non so trovare una soluzione:
Piazzati su un server Aruba, dispongo di una serie di web services scritti in VB. Li ho sempre adoperati senza nessun problema e in qualsiasi tipo di programma desktop ma adesso vorrei utilizzarli anche con JQuery.
Ho aggiunto questa semplicissima funzione per verificarne il funzionamento

<WebMethod()>
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
Public Function Test() As String
Dim Js As JavaScriptSerializer = New JavaScriptSerializer()
Dim result As String = "Test Json"
Return Js.Serialize(result)
End Function


Il file asmx inizia così
-------------------------------------------------------------------------------------------------
<%@ WebService Language="VB" Class="WebService1" %>

Imports System
Imports System.Web
Imports System.Web.Services
Imports System.Xml.Serialization
Imports System.Net
Imports System.Net.Mail
Imports System.Data
Imports System.Data.SqlClient
Imports System.Xml
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services
Imports System.Web.Script.Serialization

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()>
<WebService(Namespace:="https://www.uninspired.it/WS")>
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Public Class WebService1

Inherits System.Web.Services.WebService

etc. etc.
-------------------------------------------------------------------------------------

la funzione java è altrettanto semplice

--------------------------------------------------------------------------------------
function callWS () {
var webMethod = "https://www.uninspired.it/WS/Aruba.asmx/Tes";

$.ajax({
type: "GET",
url: webMethod,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#webservice").html(msg);
},
error: function(e){
$("#webservice").html("Unavailable");
}
});

}
---------------------------------------------------------------------

il risultato però è un errore che Chrome notifica così

GET https://www.uninspired.it/WS/Aruba.asmx/Tes 500 (Internal Server Error) jquery-3.5.0.js:10099
la riga 10099 è questa:
xhr.send( options.hasContent && options.data || null );


Grazie in anticipo per l'attenzione

5 Risposte

  • Re: Web services VB.Net chiamati da JQuery

    Fai una prova, togliendo il "json" e lavorando in text/plain e vedi se almeno così funziona
  • Re: Web services VB.Net chiamati da JQuery

    Scusa ma mi sono accorto di una cosa, tu ci mostri la function callWS() ma poi dici che l'errore è su un altra linea ???
  • Re: Web services VB.Net chiamati da JQuery

    È il JS che si referenzia nella HEAD della pagina.
  • Re: Web services VB.Net chiamati da JQuery

    Per la precisione questo
    <script src=">

    e non funziona anche con altri come questo <script src="https://code.jquery.com/jquery-latest.j">

    p.s: Se la prova si riferiva alla funzione Test del web service ovvero togliere l'oggetto che si occupa della serializzazione java e magari passare direttamente la variabile stringa, non funziona comunque
  • Re: Web services VB.Net chiamati da JQuery

    Grazie per avermi ospitato ma la questione è risolta. sembra che siano consentiti solo POST e non GET. Ho riscontrato pure che sono funzionanti Chrome e Firefox ma non Edge
Devi accedere o registrarti per scrivere nel forum
5 risposte