basic web service help needed.

hpd71

Member
Licensed User
Longtime User
Hi,

I have managed to get some decent progress by looking through other posts, and have been able to get so close... yet feel I am probably so far...

I have reviewed and used some of the code from this post (http://www.b4x.com/forum/basic4andr...ndroid-web-services-now-simple.html#post50919) as well as adding in the following section into my web.config file on my asp.net web services web.config file
<webServices>
<protocols>
<add name ="HttpGet"/>
</protocols>
</webServices>

So everything see to at least compile and run.

The problem is I have a single web service (ns_sx.asmx) but it contains many web methods... I want to call one called validateLogin and pass in a string. The web service returns a string value (passing in pin, get back username)

My code in the b4a app is(called on a button press event) :

HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("job1",ServerUrl)


my jobdone code is:

Dim s As String
If HttpUtils.IsSuccess(ServerUrl) Then
s = HttpUtils.GetString(ServerUrl)
Msgbox (s,"result")
Else
Msgbox ("nope","failed")

End If

what I get back in the message box, is the html code for the page that would show in my browser.. it shows a list of the operations available in that webservice....

So I think it works, its just not calling the validateLogin operation, or passing in a string, or getting one back..

I did try to add op=validatelogin to the url, which made a difference, but of course without passing the parameter to it, it does not work.

Thanks for any assistance...
 

hpd71

Member
Licensed User
Longtime User
Still not got this WS working... help!!!

I don't seem to be having any luck.... sorry.

So my updated B4A code is now...

ServerUrl = "http://192.168.0.62/mpxweb/ns_mpxinvservice.asmx?op=ValidateLogin&pinCode=hd1971&"

HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("job1",ServerUrl)

then when the response comes back into 'jobdone' function i do the following:

Dim s As String
If HttpUtils.IsSuccess(ServerUrl) Then
s = HttpUtils.GetString(ServerUrl)
Msgbox (s,"result")
Else
Msgbox ("nope","failed")

End If


In the message box that shows the s string, I get the html for the page that is dislayed by the IIS server that lists all the operations. Its not actually 'calling' the validatelogin function at all. I have attached an example of the screen msgbox string.

I feel like I am so close to cracking this, its frustrating...

I don't know if this is also relevant, but looking at posts/help on this topic on this site, that has been some reference to having in my web.config file a section for <webServices> for httpget..

I have never been able to get this to work as its unrecognised.... so its not in my web config...

Thanks for any help....
 

Attachments

  • mpxws.jpg
    mpxws.jpg
    70.4 KB · Views: 297
Upvote 0

hpd71

Member
Licensed User
Longtime User
Newbie.

I am a newbie at B4A so not sure of what the options are for send and getting data from a SQL Server.

I need to be able to retrieve result sets, as well as single values, and send data from the app to be saved in the SQL server.

I have been stuck on this for a few weeks (on and off it) and not getting anywhere...

I still am not sure if going via the web service is the best idea, but it does seem to make a lot of sense to do it this way..

Thanks
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
Hi,
Can you correctly access the web service using a regular browser on a PC, if you can then use Firefox and either 'Firebug' or 'Live HTTP Headers' to get all of the Post/Get details then use this info in B4A to form your HttpUtils POST request. I have used this technique on a few occasions to great effect when trying to log on a secure company site on a new app.
 
Upvote 0

hpd71

Member
Licensed User
Longtime User
web service

I am new to all this, so I am a bit lost.

I can access the web service and see a list of the available operations, but not sure how to call a single operation from the browser(IE or Safari)

Can I ask/beg for you to take a quick look at the web service in your browser/tool to help.. Just look to see if it operation validatelogin is working. I know that the other operations work as they are already in use by remote systems.

I don't want to post the URL here, so is there a way i can private message you the url..

Thanks!
 
Upvote 0
Top