ws non funzionante...

buongiorno a tutti,
ho creato due ws con il metodo handlespecialURL.

il primo funziona tranquillamente, ossia questo qui:

Dim db As New MSSQLServerDatabase

db.Host =host // or just the IP if using the default instance
db.DatabaseName = dbnm
db.UserName = user  // or "Domain\\UserID for trusted domain accounts
db.Password = pass


If db.Connect Then
  
  Dim stringa_sql as string
  stringa_sql="select USERWEB,PWDUWEB,DBNAME from Credenziali where "+parametri
  
  Dim ps As MSSQLServerPreparedStatement
  ps = db.Prepare(stringa_sql)
  
  Dim rs As RecordSet = ps.SQLSelect
  dim item as new JSONItem
  dim numrec as Integer
  numrec=0
  if rs <> Nil Then
    While Not rs.EOF
      numrec=numrec+1
      dim d as new Dictionary 
      d.Value("USERWEB") = rs.IdxField(1).StringValue
      d.Value("PWDUWEB") = rs.IdxField(2).StringValue 
      d.Value("DBNAME") = rs.IdxField(3).StringValue 
      item.Insert(numrec,d)
      rs.MoveNext
    Wend
    rs.Close
  End If
  db.Close
  Return item // And return it to the caller
Else
  MsgBox("Connection error:" + db.ErrorMessage)
End If

il secondo, invece, non mi torna nulla, neanche il JSON vuoto, eppure mi sembrano abbastanza simili come logica, ecco il secondo:

Dim db As New MSSQLServerDatabase

db.Host =host // or just the IP if using the default instance
db.DatabaseName = "FS_School" 'dbnm
db.UserName = user  // or "Domain\\UserID for trusted domain accounts
db.Password = pass


If db.Connect Then
  
  Dim stringa_sql as string
  stringa_sql= "select CODSTUDE,COGSTUDE,NOMSTUDE FROM ANA_STUD WHERE CODSTUDE='0000010028'"
  
  Dim ps As MSSQLServerPreparedStatement
  ps = db.Prepare(stringa_sql)
  
  Dim rs As RecordSet = ps.SQLSelect
  dim item as new JSONItem
  dim numrec as Integer
  numrec=0
  if rs <> Nil Then
    While Not rs.EOF
      numrec=numrec+1
      dim a as new Dictionary
      a.Value("CODSTUDE") = rs.IdxField(1).StringValue 
      a.Value("COGSTUDE") = rs.IdxField(2).StringValue 
      a.Value("NOMSTUDE") = rs.IdxField(3).StringValue
      item.Insert(numrec,a)
      rs.MoveNext
    Wend
    rs.Close
  End If
  db.Close
  
  Return item // And return it to the caller
Else
  MsgBox("Connection error:" + db.ErrorMessage)
End If

questo invece come vengono chiamate in handlespecialurl

dim data as string = Request.Entity.DefineEncoding(encodings.UTF8) // We have to apply the right encoding to the received data
dim input as JSONItem = new JSONItem( data ) // Creating a new JSON object from it
dim output as JSONItem

Select Case Request.Path // What is the method received as part of the request? (URL)
  
case "GetUser"
' isoliamo i parametri
  parametri = NthField(Request.QueryString, "&", 1)+" and "+NthField(Request.QueryString, "&", 2)
  parametri = ReplaceAll (parametri,"%27","'")
  
  output = GetUser // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
  
case "GetAunni"
  output = GetAlunni // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
  Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
  
end select

Return true

quale pu essere il problema?

Ciao Ciro,

giusto che nel case leggi questo:

case "GetAunni"

Dovrebbe essere GetAlunni?

Se non questo il problema ti consiglio un debug sul case e poi anche un debug all’interno del secondo medoto nel codice:

if rs <> Nil Then ... While Not rs.EOF numrec=numrec+1 ...

Fammi sapere

il get user funziona, anche senza il ?

mettendo il break all’interno del codice dove dici tu, non si ferma…

aggiungo anche che mettendo dietro un button il method get alunni ho il risultato voluto, ossia (dati di fantasia):

[{“CODSTUDE”:“0000010028”,“COGSTUDE”:“BARBETTA”,“NOMSTUDE”:“CICCIO”}]

provo a postare sul forum internazionale…

Se metti in handlespecialurl prima del case

system.debugLog Request.Path

Cosa appare?

Se nel case metti in breakpoint su output = GetAlunni , si ferma?

Mettendo un break prima del case, nella request ho:

GetAlunni

se metto il breakpoint nel case non si ferma :frowning:

questa la sintassi della chiamata al ws

http://127.0.0.1:8080/special/GetAlunni?USERWEB=‘10028’&PWDUWEB=‘mypwd’&DBNAME=‘FS_School’

Ciao Ciro,
non vorrei essere banale.

Ma la mia risposta era che vedo un case scritto:

case “GetAunni”

in vece di

case “GetAlunni”

cavolo! non me ne ero accorto…era proprio quello!!!

grazie!

domani visita oculistica mi sa…

[quote=411309:@Domenico Costa]Ciao Ciro,
non vorrei essere banale.

Ma la mia risposta era che vedo un case scritto:

case “GetAunni”

in vece di

case “GetAlunni”[/quote]
Infatti… e il mio metodo serviva proprio a far notare questo