B4J Question Error content-type http request (b4j,b4a)

victormedranop

Well-Known Member
Licensed User
Longtime User
I having a extarnge error when I try to consume an soap web service.
The response from the server Is :

Cannot process the message because the content type 'application/x-www-form-urlencoded' was not the expected type 'text/xml; charset=utf-8'., Response:

but my code clearly use text/xml

B4X:
#Region Project Attributes 
 #MainFormWidth: 600
 #MainFormHeight: 600 
#End Region
Sub Process_Globals
 Private fx As JFX
 Private MainForm As Form
 Private Button_buy As Button
 Private Button_cancel As Button
 Dim data As String
 Dim consorcion As String = "7ED0981F-4"
 Dim username As String 
 Dim password As String 
 
End Sub

Sub AppStart (Form1 As Form, Args() As String)
 MainForm = Form1
 MainForm.RootPane.LoadLayout("main") 'Load the layout file.
 MainForm.Show
 username = "7@52C98A-4237-8"
 password = "D6F38DBB-41@8-9"
 data = $"<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:ResultadoSorteos>
         <!--Optional:-->
         <tem:strFecha>2018-05-05</tem:strFecha>
         <!--Optional:-->
         <tem:formato></tem:formato>
      </tem:ResultadoSorteos>
   </soapenv:Body>
</soapenv:Envelope>"$
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
 Return True
End Sub

Sub check_Estatus(Query As String)
 Log(Query)
 Dim j As HttpJob
 j.Initialize("", Me)
 j.PostString("http://test.nowyouseeme.net/LotteryAuthService.svc", Query)
 j.GetRequest.SetHeader("Content-Type", "text/xml; charset=utf-8")
 j.GetRequest.SetHeader("Accept-Encoding", "gzip,deflate")
 j.GetRequest.SetHeader("SOAPAction", "http://tempuri.org/ILotteryAuthService/ResultadoSorteos")
 j.GetRequest.SetHeader("Operation", "ResultadoSorteos")
 j.GetRequest.SetHeader("StrUsuario",username)
 j.GetRequest.SetHeader("StrPassword",password)
 Wait For (j) JobDone(j As HttpJob)
 If j.Success Then
  Log(j.GetString)
 Else
  Log(j.GetString)
  LogError("Error en process")
 End If
 j.Release
End Sub
Sub ListView1_SelectedIndexChanged(Index As Int)
 
End Sub
Sub Button_cancel_Click
 
End Sub
Sub Button_buy_Click
 check_Estatus(data)
End Sub

I TRy with SoapUI and works.
Some assistance here.

Victor
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…