Spanish Ayuda con web service

Pablo Torres

Active Member
Licensed User
Longtime User
Hola, necesito ayuda con un web service, debo consumir el ws con el siguiente detalle:

POST /ws/ws_sac.asmx HTTP/1.1
Host: www.saliracomer.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ws_Restaurantes_Inicial xmlns="http://saliracomer.com/">
<usr>string</usr>
<pwd>string</pwd>
<codDepto>int</codDepto>
<inicial>char</inicial>
</ws_Restaurantes_Inicial>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ws_Restaurantes_InicialResponse xmlns="http://saliracomer.com/">
<ws_Restaurantes_InicialResult>
<RestauranteWS>
<Codigo>int</Codigo>
<Nombre>string</Nombre>
<InformacionAdicional>string</InformacionAdicional>
<Direccion>string</Direccion>
<Zona>string</Zona>
<Telefono>string</Telefono>
<Cocinas>string</Cocinas>
<Caracteristicas>string</Caracteristicas>
<Precio>string</Precio>
<ValorCalificacion>int</ValorCalificacion>
<Calificacion>string</Calificacion>
<CantidadComentarios>string</CantidadComentarios>
<Comentarios>string</Comentarios>
<Destacado>boolean</Destacado>
<RefDestacado>string</RefDestacado>
<Promociones>
<PromocionWS xsi:nil="true" />
<PromocionWS xsi:nil="true" />
</Promociones>
</RestauranteWS>
<RestauranteWS>
<Codigo>int</Codigo>
<Nombre>string</Nombre>
<InformacionAdicional>string</InformacionAdicional>
<Direccion>string</Direccion>
<Zona>string</Zona>
<Telefono>string</Telefono>
<Cocinas>string</Cocinas>
<Caracteristicas>string</Caracteristicas>
<Precio>string</Precio>
<ValorCalificacion>int</ValorCalificacion>
<Calificacion>string</Calificacion>
<CantidadComentarios>string</CantidadComentarios>
<Comentarios>string</Comentarios>
<Destacado>boolean</Destacado>
<RefDestacado>string</RefDestacado>
<Promociones>
<PromocionWS xsi:nil="true" />
<PromocionWS xsi:nil="true" />
</Promociones>
</RestauranteWS>
</ws_Restaurantes_InicialResult>
</ws_Restaurantes_InicialResponse>
</soap12:Body>
</soap12:Envelope>

al obtener los datos resultantes los tengo que almacenar en una lista cuyos objetos tienen la siguiente estructura:

Type Restaurant (Id As Int, Nombre As String, InformacionAdicional As String, Direccion As String, Zona As String, Telefono As String, TiposCocinas As List, Caracteristicas As String, Precio As String, ValorCalificacion As Int, Calificacion As String, Destacado As Boolean, RefDestacado As String, Departamento As Int, Promociones As List, Delivery As Boolean)

Quisiera q alguien me diera una orientacion con esto, se que tengo que utilizar la libreria httputils2, si me pueden echar una mano estare muy agradecido y prometo tambien postear el codigo cuando este resuelto.
Muchas gracias a todos
 

Pablo Torres

Active Member
Licensed User
Longtime User
A ver, he llegado hasta aqui ahora...

#Region Project Attributes
#ApplicationLabel: Salir a comer
#VersionCode: 1
#VersionName: Primaria
#SupportedOrientations: portrait
#CanInstallToExternalStorage: false
#End Region

#Region Activity Attributes
#FullScreen: True
#IncludeTitle: True
#End Region

Sub Process_Globals
Dim job1 As HttpJob
Type Restaurant (Id As Int, Nombre As String,InformacionAdicional As String, Direccion As String, Zona As String, Telefono As String, Cocinas As List, Caracteristicas As String, Precio As String, ValorCalificacion As Int, Calificacion As String, Destacado As Boolean, RefDestacado As String, Departamento As Int, Promociones As List, Delivery As Boolean)
End Sub

Sub Globals
Dim URL As String
Dim XML As String
Dim Res As String
Dim intFin As Int
Dim strResult As String 'Trae inf del Resultado para validar si se tiene información
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Resto")
URL = "http://www.saliracomer.com/ws/ws_sac.asmx"
CargarDatos
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean

End Sub

Sub CargarDatos ()
Log("P")
XML = XML & "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
XML = XML & "<soap:Header/>"
XML = XML & "<soap:Body>"
XML = XML & "<web:ws_Departamentos>"
XML = XML & "<web:usr>sacws</web:usr>"
XML = XML & "<web:pwd>saliracomer.123.abc</web:pwd>"
XML = XML & "</web:ws_Departamentos>"
XML = XML & "</soap:Body>"
XML = XML & "</soap:Envelope>"
XML = XML.Replace("'", Chr(34))

job1.Initialize("JOBSOAP", Me)
job1.PostString (URL, XML)
job1.GetRequest.SetContentType("APPLICATION/soap+xml")
Log("Q")

End Sub

Sub JobDone (JOB As HttpJob)

If JOB.Success Then

strResult = JOB.GetString
Log(strResult)
GetInfo(strResult)

Else
Msgbox( JOB.errormessage , "ABG-Error")
End If
JOB.Release
End Sub

Sub GetInfo(ResultadoSoapXML As String)

End Sub



Alguien me puede echar una mano???? se los ruego
 

Pablo Torres

Active Member
Licensed User
Longtime User
A ver...

B4X:
#Region  Project Attributes
    #ApplicationLabel: ABG W CON JOBDONE Y soap12
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
  
    Dim job1 As HttpJob

End Sub

Sub Globals
  
    Dim URL As String
  Dim XML As String
    Dim usr As String
    Dim pwd As String 
    Dim strResult As String
  
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("lyoWeather")
  
    URL = "http://www.saliracomer.com/ws/ws_sac.asmx"
    usr = ********
    pwd = *******
  
  ConsumirServiciSOAP
    
End Sub

Sub ConsumirServiciSOAP()
        
    XML = XML & "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:web='http://saliracomer.com/ws'>"
    XML = XML & "<soap:Header/>"
    XML = XML & "<soap:Body>"
    XML = XML & "<web:ws_Departamentos>"
    XML = XML & "<web:usr>" & usr & "</web:usr>"
    XML = XML & "<web:pwd>" & pwd & "</web:pwd>"
    XML = XML & "</web:ws_Departamentos>"
    XML = XML & "</soap:Body>"
    XML = XML & "</soap:Envelope>"
    XML = XML.Replace("'", Chr(34))
              
  job1.Initialize("JOBSOAP", Me)
  job1.PostString (URL, XML)
    job1.GetRequest.SetContentType("APPLICATION/soap+xml")
            
End Sub

Sub JobDone (JOB As HttpJob)
  
        If JOB.Success Then

            strResult = JOB.GetString
            Log(strResult)
          
        Else
        Msgbox( JOB.errormessage , "Error")
    End If
    JOB.Release
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

[\code]

Me tira de error "INTERNAL SERVER ERROR"

Puede alguien ayudarme???
Gracias
 

Heppy

Active Member
Licensed User
Longtime User
Top