Android Question PostString unsopported media type

Jimmy Erazo

New Member
Licensed User
Longtime User
Hi,

I'm new at B4A, I'm trying to connect to a web service using httputils2, and when I make the post get the error "Unsupported media type", next my code:

B4X:
Sub cmd_ingresar_Click
        Dim XML As String
        XML = XML & "<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"">"
        XML = XML & "<soap12:Body>"   
        XML = XML & "<Usuario_Ingresar xmlns=""http://samecuador.com/"">"
        XML = XML & "<usuario>SUPERVISOR</usuario>"
        XML = XML & "<clave>AMARNA</clave>"
        XML = XML & "<compania>1</compania>"
        XML = XML & "<sucursal>1</sucursal>"
        XML = XML & "</Usuario_Ingresar>"   
        XML = XML & "</soap12:Body>"
        XML = XML & "</soap12:Envelope>"   
        Dim URL As String= "http://192.168.1.2/mobile/mobile.asmx"
       
        Dim job As HttpJob
        job.Initialize("JOB1", Me)
        job.PostString (URL, XML)
End Sub

Sub JobDone (Job As HttpJob)
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    If Job.Success = True Then
          Select Job.JobName
            Case "JOB1"
                Msgbox(Job.GetString,"Respuesta")
          End Select
      Else
          Msgbox(Job.ErrorMessage,"Error: ")
       End If   
    Job.Release
End Sub

Thanks
 

Jimmy Erazo

New Member
Licensed User
Longtime User
I found it, I had to add this line after Poststring:

job.GetRequest.SetContentType("application/soap+xml")

Now it works,

Thanks anyway.
 
Upvote 0
Top