Pessoal, boa tarde.
Eu havia feito um web service onde eu retornava um DataSet que depois era consumido via SOAP no Android.
Como ficou extremamente pesado e me indicaram utilizar JSON, estou alterando.
[code] <WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function GetClientes2(ByVal representante As Integer)
Dim wCampos As String = “”, wCondicao As String = ""
Dim dr As DataSet = Nothing
Dim jss As New JavaScriptSerializer
Dim jsonString As String
’Dim jsonString As String = jss.Serialize(DataSet1.GetXML())
Try
If fBuscaRelacao(representante, C_TAB_CLIENTE) Then
dr = wsDados.execSelectDataSet("SELECT Identificacao, RazaoSocial, NomeFantasia, Inscricao, Contato, Obs, Representante, TabelaPreco FROM Cliente WHERE Representante = " & representante & " AND Sincronizado = 0")
If Not dr Is Nothing Then
wCondicao = "Representante = " & representante
wCampos = "DataUltSincronizacao = " & wsDados.dataSql(CDate(Date.Today)) & ", Sincronizado = " & 1
wsDados.execUpdate("Cliente", wCampos, wCondicao)
End If
End If
Catch ex As Exception
fExtornaImportacao(representante, C_TAB_CLIENTE)
'Return dr
jsonString = jss.Serialize(dr.GetXml())
Return jsonString
Finally
fAtualizaRelacao(representante, C_TAB_CLIENTE)
End Try
jsonString = jss.Serialize(dr.GetXml())
Return jsonString
End Function[/code]
Mas o retorno pelo browser saí dessa maneira:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
"\u003cNewDataSet\u003e\r\n \u003ctabelaTemp\u003e\r\n \u003cIdentificacao\u003e8268\u003c/Identificacao\u003e\r\n \u003cRazaoSocial\u003eDROGATEM MEDICAMENTOS E PERFUMARIA LTDA\u003c/RazaoSocial\u003e\r\n \u003cNomeFantasia\u003eDROGATEM MEDICAMENTOS E PERFUMARIA LTDA\u003c/NomeFantasia\u003e\r\n \u003cInscricao\u003e24878241000104\u003c/Inscricao\u003e\r\n \u003cContato /\u003e\r\n \u003cObs /\u003e\r\n \u003cRepresentante\u003e114\u003c/Representante\u003e\r\n \u003cTabelaPreco\u003e78\u003c/TabelaPreco\u003e\r\n \u003c/tabelaTemp\u003e\r\n \u003ctabelaTemp\u003e\r\n \u003cIdentificacao\u003e8649\u003c/Identificacao\u003e\r\n \u003cRazaoSocial\u003eDROGATEM MED. PERF. ITUMBIARA LTDA\u003c/RazaoSocial\u003e\r\n \u003cNomeFantasia\u003eDROGATEM MED. PERF. ITUMBIARA LTDA\u003c/NomeFantasia\u003e\r\n \u003cInscricao\u003e24878241000449\u003c/Inscricao\u003e\r\n \u003cContato /\u003e\r\n \u003cObs /\u003e\r\n \u003cRepresentante\u003e114\u003c/Representante\u003e\r\n \u003cTabelaPreco\u003e78\u003c/TabelaPreco\u003e\r\n \u003c/tabelaTemp\u003e\r\n \u003ctabelaTemp\u003e\r\n \u003cIdentificacao\u003e8650\u003c/Identificacao\u003e\r\n \u003cRazaoSocial\u003eDROGATEM MEDICAMENTOS E PERFUMARIA LTDA\u003c/RazaoSocial\u003e\r\n \u003cNomeFantasia\u003eDROGATEM MEDICAMENTOS E PERFUMARIA LTDA\u003c/NomeFantasia\u003e\r\n \u003cInscricao\u003e24878241000368\u003c/Inscricao\u003e\r\n \u003cContato /\u003e\r\n \u003cObs /\u003e\r\n
É gigante então copiei apenas uma parte…
Alguém tem ideia do que falta eu mudar ou se não é possível eu fazer essa conversão direta da maneira que eu estou tentando?
Obrigado desde já.