Hello, I need your help, I have a webservice that uses a parameter but when trying to call it from sends me by mistake.
This is my function, when I run it shows me: Error ('No se pudo cargar desde el WebService')
var makeAjaxConParam = function() {
Ext.getBody().mask('Loading...', 'x-mask-loading', false);
Ext.Ajax.request({ url: 'http://localhost/rechum2007/direcmy/serviceipad.asmx/getemployeesbynopersonalxml',
method: 'POST',
params: {NoPersonal: '101122'},
headers: {'Content-Type': 'application/json'},
success: function(result, request) {
var wsResult = Ext.decode(result.responseText);
Ext.getCmp('content').update(wsResult);
Ext.getCmp('status').setTitle('Datos cargados con exito desde el servicio');
Ext.getBody().unmask();
},
failure: function(result, request) {
Ext.getCmp('content').update("Error");
Ext.getCmp('status').setTitle('No se pudo cargar desde el WebService');
Ext.getBody().unmask();
}
});
};
This the method
<WebMethod(Description:="Traer conforme a una condicion y deja XML")> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True, XmlSerializeString:=False)> _
PublicFunction GetEmployeesByNoPersonalXML(ByVal NoPersonal AsString) As clGeneralesEmp2()
Dim cDatos AsNew ClasesParaDatosAux.clsADONet2.clsADONet_SQL
Utilerias.PrepararDatos(cDatos)
cDatos.ArmarCadenaConexion()
Dim strSQL AsString = _
"SELECT Nombre, P.NoPosicion, FechaNacimiento, FechaIngreso " & _
"From perFuerzaTrabajo P, orgPosiciones S, orgUnidadesOrg O, orgDivisiones D," & _
" orgSubdivisiones SD " & _
"Where S.NoPosicion = P.NoPosicion and O.NoUnidadOrg = S.NoUnidadOrg" & _
" and D.Division = S.Division and" & _
" (S.Division = SD.Division and S.Subdivision = SD.SubDivision) " & _
"And ( NoPersonal = " & NoPersonal & ")"
Dim datares As DataTable
Dim ds AsNew DataSet
If cDatos.conectar Then
Try
If cDatos.PreparaDataSet(ds, strSQL, "perFuerzaTrabajo") Then
datares = ds.Tables(0)
EndIf
Catch ex As Exception
Finally
IfNot IsNothing(ds) Then ds.Dispose()
cDatos.CerrarConexion()
EndTry
EndIf
Dim Al AsNew ArrayList
ForEach row As Data.DataRow In datares.Rows
Utilerias.MoverDtEmpl2RowAArray(row, Al)
Next
datares.Dispose()
Dim outArray() As clGeneralesEmp2 = CType(Al.ToArray(GetType(clGeneralesEmp2)), clGeneralesEmp2())
Return outArray
EndFunction
This is the out class clGeneralesEmp2
Imports Microsoft.VisualBasic
PublicClass clGeneralesEmp2
Public Nombre AsString
Public NoPosicion AsLong
Public FechaNacimiento AsString
Public FechaIngreso AsString
EndClass
This is the function that convert the datarow in array
PublicSharedSub MoverDtEmpl2RowAArray(ByRef drP As Data.DataRow, ByRef ArrayRef As ArrayList)
Dim obj As clGeneralesEmp2 = New clGeneralesEmp2
IfNot IsDBNull(drP.Item("Nombre")) Then
obj.Nombre = CType(drP.Item("Nombre"), String)
Else
obj.Nombre = ""
EndIf
IfNot IsDBNull(drP.Item("NoPosicion")) Then
obj.NoPosicion = CType(drP.Item("NoPosicion"), Long)
Else
obj.NoPosicion = 0
EndIf
IfNot IsDBNull(drP.Item("FechaNacimiento")) Then
obj.FechaNacimiento = Utilerias.FechaConMes_str(CType(drP.Item("FechaNacimiento"), Date).ToString, False).ToUpper
Else
obj.FechaNacimiento = Utilerias.FechaConMes_str(Now.ToString, False).ToUpper
EndIf
IfNot IsDBNull(drP.Item("FechaIngreso")) Then
obj.FechaIngreso = Utilerias.FormatearFecha(CType(drP.Item("FechaIngreso"), Date).ToString, False).ToUpper
Else
obj.FechaIngreso = Utilerias.FechaConMes_str(Now.ToString, False).ToUpper
EndIf
ArrayRef.Add(obj)
EndSub