B4A Library OkHttp - Replaces the Http library

luke2012

Well-Known Member
Licensed User
Longtime User
yes.

Ideally the webservices does return only a json-string with the result answer(s)

B4X:
    job.PostString("http://www.targetsite.org/webservice.php", "firstname=John&lastname=Doe")

The above (web service call) method could be considered cross-platform (Java / PHP / .Net) ?
 

johnaaronrose

Active Member
Licensed User
Longtime User
Converting to OkHttp, on compiling I get:
B4A version: 5.80
Parsing code. Error
Error parsing program.
Error description: HttpUtils2Service is declared twice. You should either remove the library reference or the code module.

HttpUtils2Service is a Service module. It has no Library entry, as would be shown in the Libraries Manager. Any ideas for the message?
 

Attachments

  • JewishWorld.zip
    43 KB · Views: 372

johnaaronrose

Active Member
Licensed User
Longtime User
@DonManfred When I click the Libraries Manager tab, neither httpjob nor httputilsservice is shown in the list. OkHttp & OkHttpUtils are shown with ticks against them. There are entries for HTTP & HttpUtils2, but neither of them have ticks: should I remove those entries (if so, how)? I have HttpJob as a Class module and HttpUtils2Service as a Service module in my project. I have entries of OkHttp & OkHttpUtils2 in the Libraries Manager list with ticks against them.
 

johnaaronrose

Active Member
Licensed User
Longtime User
@manfred I switched to using OkHttp etc as Erel said (in first post on this thread):
"The current Http library is based on the Android version of Apache HttpClient. Google has stopped updating this SDK a long time ago and they are removing it from Android M. This means that it is a good time now to switch to a different implementation.
Note that if you are using HttpUtils2 (as you should) it is also based on Http library.
The OkHttp library is based on the OkHttp SDK: http://square.github.io/okhttp/"
and because my app no longer worked: I haven't used it for at least a year and I haven't updated it for approx 3 years.

I am using the standard HttpJob Class module. Should it be in Additional Libraries or somewhere else rather than me copying the source? As you say, I have customized the original HttpUtils2Service service module's source as I have coding in to display a progress bar.

The Libraries Manager tab's list has entries for HTTP & HttpUtils2, but neither of them have ticks: should I remove those entries (if so, how)?
 

DonManfred

Expert
Licensed User
Longtime User
I have customized the original HttpUtils2Service service module's source as I have coding in to display a progress bar.
Yes, i noticed.
Using modified version you should make sure to UPADATE the modules to have the newest ones. Download the newest okhttputils source modules (See Post #1 in this Thread). AND do the needed changes for your progress here TOO.
Use the "new" two modules then...
 

DonManfred

Expert
Licensed User
Longtime User
Please start a NEW thread in the questions forum for any further questions...
Upload the updated project in the new thread if you still dont get it to work.
Also post the link to the library you are using... I get a message of a missing library (i dont have this lib)
 

johnaaronrose

Active Member
Licensed User
Longtime User
I'm confused. Erel says in his first post on this thread "OkHttp and OkHttpUtils2 libraries are included in the IDE.". So as I haven't downloaded them either as .zip (let alone installed these) or as Additional Library entries (which would presumably be have .jar & .xml files), but they are in the Library Manager's tab list with ticks, so therefore they are recent versions as I'm using B4A 5.80.
 

johnaaronrose

Active Member
Licensed User
Longtime User
What do you suggest as a title for a NEW Thread?
 

johnaaronrose

Active Member
Licensed User
Longtime User
Yes, they are in the library tab.
BUT you are using a customized version of the old library...
Download the newest source (see post #1) and do the changes you made in the old one again in the new sources... Use the new modules then.
I don't understand what you mean by a customized version of the old library. As I said before, I have ticks against OkHttp & OkHttpUtils2 (but no ticks against HTTP & HttpUtils2) in the Library Manager tab's list. So is that correct?
I have a modules for HttpJob & HttpUtils2Service. Am I correct in stating that I need to take the new versions of these from Erel's post #1 and amend them in the same way as I previously amended them?
 

DonManfred

Expert
Licensed User
Longtime User
I have a modules for HttpJob & HttpUtils2Service. Am I correct in stating that I need to take the new versions of these from Erel's post #1 and amend them in the same way as I previously amended them?
Correct. You do not need to mark the library in the libary tab (okhttputils2) as you are using the source of it (the two modules).

Any further question; Please create a new thread in the questions forum. I´ll not give any more answers here.
 

OliverA

Expert
Licensed User
Longtime User

Jmu5667

Well-Known Member
Licensed User
Longtime User


Hi Martin

I would be interested in know more about SAML as it has been requested by one of our clients. As I yet I have no knowledge. Can you suggest any info to read and maybe an example of the url used in the sample code.

Thanks in advance

John.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…