Вот как мы это делаем — отправка запроса в json и обратно:
With input
.token = token
.application_id = application_id
.login = login
.locale = locale
End With
'// сериализуем объект ClientInfo в формат нотации JSON
Dim stream1 As New MemoryStream()
Dim ser As New DataContractJsonSerializer(input.GetType)
ser.WriteObject(stream1, input)
stream1.Position = 0
Dim sr As New StreamReader(stream1)
Dim json As String = sr.ReadToEnd
' // создаем клиента
Dim wc As WebClient = New WebClient()
'// отправляем POST-запрос и получаем ответ
Dim result() As Byte = wc.UploadData(wsdl, "POST", System.Text.Encoding.UTF8.GetBytes(json))
Dim t As String = Encoding.UTF8.GetString(result)
stream1.Close()
Dim stream2 As New MemoryStream
Dim sw As New StreamWriter(stream2)
sw.Write(t)
sw.Flush()
stream2.Position = 0
If t.Contains("error_detail") Then
Dim myErr As New yaError
Dim ser2 As New DataContractJsonSerializer(myErr.GetType)
' Deserialize the data and read it from the instance.
myErr = CType(ser2.ReadObject(stream2), yaError)
stream2.Close()
Return myErr
Else
Dim ser2 As New DataContractJsonSerializer(reply.GetType)
reply = ser2.ReadObject(stream2)
Return reply
End If