Android Question webservice with json

Radisk3

Member
Licensed User
Longtime User
Hello guys,

I have access to a webservice done in C#.
Location: http://radarweb.wk.com.br/radarwebwebservices/Areas/
It have methods I can use and have access to the bases.
I can access it using XML, for example:

B4X:
Private Sub Busca_XML
   Dim JOB As HttpJob
   Dim EndPesq as String
   Dim strXML As String = File.ReadString(File.DirAssets, "cfrt.xml")
   EndPesq="http://radarweb.wk.com.br/radarwebwebservices/Areas/Empresarial/Empresarial.svc"
   JOB.Initialize("FindM", Me)
   JOB.PostString(EndPesq, strXML)
   JOB.GetRequest.SetContentType("text/xml; charset=utf-8")
   JOB.GetRequest.SetHeader("SOAPAction", urlHearder)
   JOB.GetRequest.SetContentEncoding("gzip, deflate")
End Sub

Sub JobDone(Job As HttpJob)
   If Job.Success Then
     ....
   End If
   Job.Release
End Sub

He has access with json and there comes the question:

How do I access this type of webservice using json?
 

Jorge M A

Well-Known Member
Licensed User
Longtime User
If I understand correctly, try setting the header SetContentType to "application/json; charset=utf-8"
 
Upvote 0

Radisk3

Member
Licensed User
Longtime User
Hello,

Thank you for the return.
In my ignorance I tried to replace it but I got the return:
ResponseError. Reason: Cannot process the message because the content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'., Response:

Any tips?
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Longtime User
Okay, that means your webservice is not able to negotiate the response.
You need to deal with XML parser, pass data to map and then to json.
Look here for the library.
And don't miss the @Erel's video about webservices here.
 
Upvote 0
Top