Android Question Fichier SSL et WEB Service

Daniel Gagnon 1961

Member
Licensed User
Bonjour,

Je tente de me connecter via HTTPJOB sur un webservice sécurisé.

J'ai pris un exemple d'un membre et modifier son code pour mon service web

https://www.b4x.com/android/forum/threads/soap-textbox-info.19961/#post-155159

Toutefois la connexion et le POST est impossible car il faut un fichier SSL.

Donc voici ma question

J'ai finalement les fichiers SSL ( *.cer,*.p7b,*.pfx, *.csr et *.pem)

Est-ce que je peux prendre un de ces fichiers et le mettre en "dirasset" ?

Si oui comment j'y fais référence pour lancer le POST REQUEST ?

Si non comment puis-je utiliser le SSL dans un httpjob ?

Merci de votre aide


---------------------------------------------------------------------------------------------------------------

Hello,

I try to connect via HTTPJOB on a secure webservice .

I took an example of a member and modify its code to my web service

https://www.b4x.com/android/forum/threads/soap-textbox-info.19961/#post-155159

However connection and POST is impossible because it takes a SSL file.

So my question

I finally have the SSL files (* .cer , * . P7b * . Pfx , .csr * and * .pem )

Do I take one of these files and to " DIRASSET " ?

If so how I refer to start the POST REQUEST ?

If not how do I use SSL in a httpjob ?

Thank you for your help
 

Daniel Gagnon 1961

Member
Licensed User
Yes Erel

the message log are no peer ssl

The web service return this message Error: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate

The web service is intranet and the access is by VPN

I take a example of httpjop to do the request

I can make the request in my cell directly in chrome browser and I receive the result in google browser

Probably this method is not the best ...

I tried to show the result in a webview but the webview not accept this url I dont know why too

In the forum i read a lot of examples and i was try a lot but nothing really do a return on xml response
or convert the inner html in xml

So this morning i'm gonna try to copy in the clipboard the response to import in a xlm files

Thank's



upload_2016-8-3_7-28-15.png
 
Upvote 0

Daniel Gagnon 1961

Member
Licensed User
This is the example code of the module

the reponse is empty because no peer ssl ....

Dim j As HttpJob
j.Initialize("", Me)

Dim msg As String = File.ReadString(File.DirAssets, "TOTO.xml")
msg = msg.Replace("$NOM$", "Gagnon")


j.PostString("https://xxx.intranet.xxx.xxxx/Services/Servicesxxxx.asmx/ObtenirRenseignementxxxxx?password=MYPASSWORD&nom=Gagnon&prenom=&pieceIdentite=&noCertificat=&dateNaissance=&immatriculation=&commentaire=" , msg)

j.GetRequest.SetContentType("application/soap+xml; charset=utf-8")

Dim reponse As String
reponse =j.GetString
Log(reponse)
 
Upvote 0

Daniel Gagnon 1961

Member
Licensed User
This is the response in the log window with hc.InitializeAcceptAll

With Postman I can post the request directly and i receive the results

With Phone browser in intent I see the result with the adress and request directly to web service in a google page

My VPN connection is Ok

But Can you tell me if i can extract or converse the result from a phone intent
to text file or xml ? With clipboard maybe ...



LogCat connected to: 7e8eb467
--------- beginning of /dev/log/system--------- beginning of /dev/log/main~i:** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<STYLE type="text/css">
BODY { font: 8pt/12pt verdana }
H1 { font: 13pt/15pt verdana }
H2 { font: 8pt/12pt verdana }
A:link { color: red }
A:visited { color: maroon }
</STYLE>
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>
<h1>You are not authorized to view this page</h1>
You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept.
<hr>
<p>Please try the following:</p>
<ul>
<li>Contact the Web site administrator if you believe you should be able to view this directory or page.</li>
<li>Click the <a href="javascript:location.reload()">Refresh</a> button to try again with different credentials.</li>
</ul>
<h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.<br>Internet Information Services (IIS)</h2>
<hr>
<p>Technical Information (for support personnel)</p>
<ul>
<li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>401</b>.</li>
<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr),
and search for topics titled <b>About Security</b>, <b>Authentication</b>, and <b>About Custom Error Messages</b>.</li>
</ul>
</TD></TR></TABLE></BODY></HTML>
JobName = Job1, Success = false
Error: Unauthorized
 
Upvote 0

Daniel Gagnon 1961

Member
Licensed User
Hi Erel

Yes I set the user name and the PW

But I made an app for desktop with VB6 to call this web service

I use a similar code for this web service

Example:

Dim req As XMLHTTPRequest
Set req = New XMLHTTPRequest
req.Open "POST", urlService, False
req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.setRequestHeader "Content-Length", Len(strCritere)
req.send "password=" & MYPASSWORD & "&latitude=" & strLatitude & "&longitude=" & strLongitude & "&distance=" & strDistance
Dim resp As DOMDocument
Dim resp2 As DOMDocument
Set resp = New DOMDocument
resp.loadXML req.responseXML.XML
139: Set resp2 = New DOMDocument
140: resp2.loadXML resp.Text
 
Upvote 0

Daniel Gagnon 1961

Member
Licensed User
My user name is in my pc because to log pc on network I need to enter my user name to open session


Dim req As XMLHTTPRequest
Set req = New XMLHTTPRequest
req.Open "POST", urlService, False
req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.setRequestHeader "Content-Length", Len(strCritere)
req.send "password=" & MYPASSWORD & "&latitude=" & strLatitude & "&longitude=" & strLongitude & "&distance=" & strDistance
Dim resp As DOMDocument
Dim resp2 As DOMDocument
Set resp = New DOMDocument
resp.loadXML req.responseXML.XML
Set resp2 = New DOMDocument
resp2.loadXML resp.Text


this example is to locate each item inside a buffer and the app keep only item inside this buffer in km

with resp.text en made a xml file to create a list of find item and I convert all of them in KML from the "resp.text"

In Urlservice is the formula to call the request .

Thank's again to your help

Daniel
 
Upvote 0
Top