B4J Question After Update PostString not work

victormedranop

Well-Known Member
Licensed User
Longtime User
I recently update my version of b4J, this code is not working. but was working in the old release.

B4X:
 Dim data As String = $"<?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
   <Login xmlns="http://tempuri.org/">
   <username>${username}</username>
 <password>${password}</password>
 <accountId>${userid}</accountId>
   </Login>
 </soap:Body>
 </soap:Envelope>"$

Sub connect_u(data As String)
 
 Dim j As HttpJob
 Try
 Log(data)
 j.Initialize("", Me)
 If j.IsInitialized = True Then 
 Log("ok")
 j.PostString("http://1.1.1.1:9191/Service.asmx",data)
 j.GetRequest.SetHeader("SOAPAction","http://tempuri.org/Login")
 j.GetRequest.SetContentType("text/xml; charset=utf-8")
 End If
 Catch
 Log(LastException)
 End Try
 Wait For (j) jobDone(j As HttpJob)
 If j.Success Then
 Log(j.GetString)
 End If
 j.Release
End Sub


I try it on a debian server with iptraf and never try to connect to host.

Victor
 

OliverA

Expert
Licensed User
Longtime User
Probably need to see what j.ErrorMessage contains, since j.Success is most likely not true. Till then, we'll just be guessing.
B4X:
 If j.Success Then
     Log(j.GetString)
else
     Log(j.ErrorMessage)
End If
 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
I don't belive this error attach. I really don't understand.
I'm not opening any file :mad::mad::mad::mad::mad::mad::mad::mad::mad:

(FileNotFoundException) java.io.FileNotFoundException: C:\Users\VICTOR~1\AppData\Local\Temp (Access is denied)
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
May not be related, but did you clean your project after upgrading B4j? This probably should have been giving you build errors, so it's just for trying sake.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Do you get a line number for that error? What line is causing it?
 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
I did clean up the protect. I start a new in another machine. But got the same error.
The error y when try to connect and post the file.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Actually, if you look at the source of HttpUtils2Service.bas (part of what makes the Http Job stuff tick), it uses your temp folder. Here's the code snippet
B4X:
#Else If B4J
    TempFolder = File.DirTemp
#End If

' and later

#if B4A or B4J
Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
    Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
        True, TaskId)
End Sub

I don't know what upgrading B4J would do to your access to your temp folder (it should not impact it at all).
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
But I'm not using temp folder, and is not ui application.
I understand. You directly are not, but indirectly by using jHttpUtils2 you are (I just realized your using jHttpUtils2 not okHttpUtils2). I'm attaching a non-ui app that uses your code and the jHttpUtils2 source found at https://www.b4x.com/android/forum/threads/jhttputils2-source-code.39415/ (since it's a non-ui app, the source has to be included and the library jHttpUtils2 needs to be unchecked). The only libraries that are checked for this example are jCore (version 5.8), jHttp (version 1.11) and jStringUtils (version 1.00). For me, the app works, logging a j.ErrorMessage of
Error: org.apache.http.conn.HttpHostConnectException: Connection to http://1.1.1.1:9191 refused
which is correct, since I don't have a server at 1.1.1.1

B4J Version: 5.90 (Registered), just recently upgraded
Java Version: 1.8.0_144
OS: Win10 Pro Version 1607 (OS Build 14393.1715)
 

Attachments

  • test3.zip
    3.6 KB · Views: 201
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
Yes, is working. Maybe I make a mess with the library selection. one question I receive a cookie in that connection how can I grabbed, for sending in
another call?

thanksOliverA.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

OliverA

Expert
Licensed User
Longtime User
but never release. the connection.
What connection?
HTTP? Socket? Both could be explained by some sort of connection pooling that may be implemented by the underlying open source library used (don't have time to check right now). It may even be due to the Java garbage collector that does not instantaneously release memory. What are you expecting to happen and what is not happening. You may need to open a new thread since

1) I think we fixed the issue with post string not working (the temp file issue)
2) The release may be a different issue and therefore validate a new thread. Plus I may be out of my league on this one and hopefully other people can help.
 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
my last issue was with the cookie. I couldn't read it. and I need that info to made se second request.
I stop for now, because I need to have a demo running on Monday. I start with php7 debian host and b4a and it's almost done using curl.

I start a new tread when I publish this soap web service.
victor
 
Upvote 0
Top