Yeah, i look that but i don't understand how use correctly...There are two examples attached in the link you posted in the first post.
I recommend you to go over the HttpUtils tutorial and examples. If it doesn't work for you please post your code and we will help you.
<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://142.114.2.131/Sitios/">
<string>Ericka</string>
<string>Martin</string>
<string>Damian</string>
<string>Juliana</string>
</ArrayOfString>
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim PostUrl As String
PostUrl = "http://142.114.2.131/Sitios/HolaMundo/HolaMundo.asmx?op=Lista"
Dim parser As SaxParser
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Lista As ListView
Dim TxtBox1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
HttpUtils.CallbackActivity = "Main"
End Sub
Sub Activity_Resume
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub TxtBox1_EnterPressed
Dim parametro As String
parametro = TxtBox1.Text
LlamarFuncion(parametro)
End Sub
Sub LlamarFuncion(parametro As String)
ProgressDialogShow("Buscando. . .")
HttpUtils.PostString("POST Job1", PostUrl, parametro)
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
End Sub
Sub UrlDone(Url As String)
Log(Url & " done")
ProgressDialogHide
End Sub
Sub JobDone (Job As String)
Select Job
Case "POST Job1"
Dim cadena As InputStream
If HttpUtils.IsSuccess(PostUrl) Then
cadena = HttpUtils.GetInputStream(PostUrl)
'Log(HttpUtils.GetString("http://www.b4x.com/print.php"))
parser.Parse(cadena, "Parser")
cadena.Close
End If
End Select
HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
For i = 0 To parser.Parents.Size
Lista.AddSingleLine(parser.Parents.Get(i))
Next
End Sub
The service only accept one String as parameter... but, it's ok the code?Error 500 means that the server has encountered some error. It might be that you are sending the wrong values. As your server is not publicly accessible I cannot know why it happens.
OkYour code looks fine. You can remove the UrlDone sub and hide the progress dialog in JobDone. UrlDone is useful when you have multiple Urls in a single job. In fact there is a bug in your code as UrlDone will not fire if there was an error. It only fires for successful Urls. In the case of an error the progress dialog will not be hidden.
The error said:PostUrl = "http://142.114.2.131/Sitios/HolaMundo/HolaMundo.asmx?op=Lista"
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code>
<soap:Reason><soap:Text xml:lang="en">
[B]Server was unable to process request. --> Data at the root level is invalid. Line 1, position 1.[/B]
</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:Envelope>
A Runtime Error appear.PostUrl = "http://142.114.2.131/Sitios/HolaMundo/HolaMundo.asmx/Lista"
<%@ WebService Language="VB" Class="HolaMundoWebSVB" %>
<WebService( _
Namespace:="http://142.114.2.131/Sitios/", _
Description:="Hola, aqui puedes observar los primeros Web Services creados por Fabian Garcia :D")> _
Public Class HolaMundoWebSVB
<WebMethod(Description:="Devuelve una lista")> _
Public Function Lista(ByVal parametro As String) As List(Of String)
Dim a As New List(Of String)
a.Add("Fabian")
a.Add("Eduardo")
a.Add("Victor")
a.Add("Alicia")
a.Add("Iliana")
If parametro = "Team" Then
Return a
End If
Dim b As New List(Of String)
b.Add("Ericka")
b.Add("Martin")
b.Add("Damian")
b.Add("Juliana")
Return b
End Function
End Class
<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://142.114.2.131/Sitios/">
<string>Ericka</string>
<string>Martin</string>
<string>Damian</string>
<string>Juliana</string>
</ArrayOfString>
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim PostUrl As String
PostUrl = "http://142.114.2.131/Sitios/HolaMundo/HolaMundo.asmx?op=Lista"
Dim parser As SaxParser
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Lista As ListView
Dim TxtBox1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
HttpUtils.CallbackActivity = "Main"
End Sub
Sub Activity_Resume
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub TxtBox1_EnterPressed
Dim parametro As String
parametro = TxtBox1.Text
LlamarFuncion(parametro)
End Sub
Sub LlamarFuncion(parametro As String)
ProgressDialogShow("Buscando. . .")
HttpUtils.PostString("POST Job1", PostUrl, parametro)
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
End Sub
Sub UrlDone(Url As String)
Log(Url & " done")
ProgressDialogHide
End Sub
Sub JobDone (Job As String)
Select Job
Case "POST Job1"
Dim cadena As InputStream
If HttpUtils.IsSuccess(PostUrl) Then
cadena = HttpUtils.GetInputStream(PostUrl)
'Log(HttpUtils.GetString("http://www.b4x.com/print.php"))
parser.Parse(cadena, "Parser")
cadena.Close
End If
End Select
HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
For i = 0 To parser.Parents.Size
Lista.AddSingleLine(parser.Parents.Get(i))
Next
End Sub
Your server expects a soap message. This is an xml message. You are sending it the wrong value. You should send an XML string as the parameter (the exact format depends on your server setttings).
<%@ WebService Language="VB" Class="HolaMundoWebSVB" %>
<WebService( _
Namespace:="http://142.114.2.131/Sitios/", _
Description:="Hola, aqui puedes observar los primeros Web Services creados por Fabian Garcia :D")> _
Public Class HolaMundoWebSVB
<WebMethod(Description:="Devuelve una lista")> _
Public Function Lista(ByVal parametro As String) As List(Of String)
Dim a As New List(Of String)
a.Add("Fabian")
a.Add("Eduardo")
a.Add("Victor")
a.Add("Alicia")
a.Add("Iliana")
If parametro = "Team" Then
Return a
End If
Dim b As New List(Of String)
b.Add("Ericka")
b.Add("Martin")
b.Add("Damian")
b.Add("Juliana")
Return b
End Function
End Class
<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://142.114.2.131/Sitios/">
<string>Ericka</string>
<string>Martin</string>
<string>Damian</string>
<string>Juliana</string>
</ArrayOfString>
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim PostUrl As String
PostUrl = "http://142.114.2.131/Sitios/HolaMundo/HolaMundo.asmx?op=Lista"
Dim parser As SaxParser
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Lista As ListView
Dim TxtBox1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
HttpUtils.CallbackActivity = "Main"
End Sub
Sub Activity_Resume
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub TxtBox1_EnterPressed
Dim parametro As String
parametro = TxtBox1.Text
LlamarFuncion(parametro)
End Sub
Sub LlamarFuncion(parametro As String)
ProgressDialogShow("Buscando. . .")
HttpUtils.PostString("POST Job1", PostUrl, parametro)
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
End Sub
Sub UrlDone(Url As String)
Log(Url & " done")
ProgressDialogHide
End Sub
Sub JobDone (Job As String)
Select Job
Case "POST Job1"
Dim cadena As InputStream
If HttpUtils.IsSuccess(PostUrl) Then
cadena = HttpUtils.GetInputStream(PostUrl)
'Log(HttpUtils.GetString("http://www.b4x.com/print.php"))
parser.Parse(cadena, "Parser")
cadena.Close
End If
End Select
HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
For i = 0 To parser.Parents.Size
Lista.AddSingleLine(parser.Parents.Get(i))
Next
End Sub
Your server expects a soap message. This is an xml message. You are sending it the wrong value. You should send an XML string as the parameter (the exact format depends on your server setttings).
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?