iOS Question PostMultipart.SendMultipartJob

Rokiu86

Member
Licensed User
Longtime User
Hi.

I've been looking for the "PostMultipart Module" for b4i. I couldn't find it, and i decided to modify the subrutine SendMulipartJob of B4A, but after two days of work i cant't fix all the problems.

My target was send a map objet to a WebService (aspx), but i finally create a simple class called KeyValue: (Here the def)

B4X:
'Class module
Sub Class_Globals
   
    Private key As String
    Private value As String
   
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(parKey As String, parValue As String)
    key=parKey
    value=parValue
End Sub

Public Sub getKey As String
    Return key
End Sub

Public Sub getValue As String
    Return value
End Sub

Here is Sub SendMultipartJob edited. The problem is in the last 3 lines.

ERROR:
Parsing code. Error
Error parsing program.
Error description: Syntax error.
Occurred on line: 39
job.GetRequest.

In B4i, set, SetContentType and SetContentEncoding, where are declarated?

B4X:
Sub SendMultipartJob (JobName As String, TargetModule As Object, Url As String, Parametros() As KeyValue)
   Dim boundary As String
   boundary = "---------------------------1461124740692"
   Dim stream As OutputStream
   stream.InitializeToBytesArray(20)
   Dim EOL As String
   EOL = Chr(13) & Chr(10) 'CRLF constant matches Android end of line character which is chr(10).
   Dim b() As Byte
   Dim a As String


    If Parametros.Length<>0 Then
    For i=0 To Parametros.Length-1

        Dim kv As KeyValue
        kv=Parametros(i)
               
        Log("key= " & kv.getkey & " value= " & kv.getvalue)  
        a="--" & boundary & EOL & "Content-Disposition: form-data; name=" & QUOTE & kv.getkey & QUOTE & EOL & EOL & kv.getvalue & EOL
        b = a.GetBytes("UTF8")
         stream.WriteBytes(b, 0, b.Length)
        Next
   End If
   a=EOL & "--" & boundary & "--" & EOL
   b = a.GetBytes("UTF8")
   stream.WriteBytes(b, 0, b.Length)
   b = stream.ToBytesArray
   Dim job As HttpJob
   job.Initialize(JobName, TargetModule)
   job.PostBytes(Url, b)
   job.GetRequest.set
   job.GetRequest.SetContentType("multipart/form-data; boundary=" & boundary)
   job.GetRequest.SetContentEncoding("UTF8")
End Sub

I need help to send map to WebService.aspx or to fix the problem in the edited method.

Thanks a lot.
 

Rokiu86

Member
Licensed User
Longtime User
Hi.

ihttp.xml version of the IDE was 1.0.0. I changed it to v.1.0.1!!!!

But I have the same problem at line:
job.GetRequest.set
When I tip the second "." the IDE don't show me method "set" (see image 1).

Someone can help me? Maybe another way to connect to WebService(aspx).

Thanks.
 

Attachments

  • IMAGE1.png
    IMAGE1.png
    49.1 KB · Views: 340
Upvote 0

Rokiu86

Member
Licensed User
Longtime User
The metod is in the first post, second code block.

Until you pass me the version ihttp.xml, I had errors on the last three lines of code. Since I changed the ihttp.xml I only have issues on the third line from the end. (job.GetRequest.set) (no count "End sub").

I've been looking for the "PostMultipart Module" for b4i. I couldn't find it, and i decided to modify the subrutine SendMulipartJob of B4A, but after two days of work i cant't fix all the problems.
 
Upvote 0
Top