missing header in http post

cwt

Active Member
Licensed User
Longtime User
I am working on an app to send and receive xml to a soap server. I have the part done using HttpUtils to send xml wrapped in a soap envelope to a soap server. That works well - but it does not appear that Android is adding the http header to the post. All that is being received by the server is the soap envelope. What happened to the header?

Thanks
 

cwt

Active Member
Licensed User
Longtime User
thanks for the response but I found the problem - I had to reset the default Content-Type to text/xml - then all worked fine
 
Upvote 0

robh

Member
Licensed User
Longtime User
HttpUtils Header

thanks for the response but I found the problem - I had to reset the default Content-Type to text/xml - then all worked fine

I'm also having problems with SOAP request, I can't seem to find a property within HttpUtils to set some header details. Can you please shed some light on how you got around this issue using the HttpUtils library.

Many thanks in advance.
 
Upvote 0

deantangNYP

Active Member
Licensed User
Longtime User
Dear Experts
thanks for the response but I found the problem - I had to reset the default Content-Type to text/xml - then all worked fine

can you share your code? i am lost. i am not sure how to do it.
I am trying to upload/post a xml to a server, but i think header (Content-Type: text/xml) is missing.
How do i define it? Not sure how to do it.

The requests are created in HttpUtilsService.ProcessNextTask. You will need to modify this sub and add the required headers.

How do i modify "ProcessNextTask"? Please give me a link or example.

Please help.
 
Last edited:
Upvote 0

deantangNYP

Active Member
Licensed User
Longtime User
Please do not post duplicate questions.

Are you using HttpUtils or HttpUtils2?

I recommend you to use HttpUtils2.
You can set the content type with this code:
B4X:
Dim j As HttpJob
j.Initialize("j", Me)
j.GetRequest.SetContentEncoding("text/xml")
j.Download("...")
Dear Erel,

Is this the way todo it? I want to Upload not Download...
I got an error "java.lang.RuntimeException: Only Post / Put requests support this method."
Please advise

B4X:
Sub Button7_Click
 Dim job2 As HttpJob

 'Send a POST request
 job2.Initialize("Job2", Me)
 job2.GetRequest.SetContentEncoding("text/xml")
 job2.PostFile("http://192.168.0.101/dir/add.xml",File.DirRootExternal, "upload.xml")

End Sub

Sub JobDone (Job As HttpJob)
   If Job.Success = True Then
      Log(Job.GetString)    
     ToastMessageShow("Uploaded OKi!", False)
   Else
        'Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub
 
Last edited:
Upvote 0

deantangNYP

Active Member
Licensed User
Longtime User
hi Erel

I think the problem is solved. But it has to be in this order to avoid the error
"java.lang.RuntimeException: Only Post / Put requests support this method."
Correct?

B4X:
Dim job2 As HttpJob
 'Send a POST request
 job2.Initialize("Job2", Me)
 job2.PostFile("http://192.168.0.101/dir/add.xml",File.DirRootExternal, "upload.xml")
 job2.GetRequest.SetContentEncoding("text/xml")
 
Upvote 0
Top