Very basic webservice Consumption

jroriz

Active Member
Licensed User
Longtime User
I' using B4A for 1 week, and everything is very new to me. I am very happy with this app.

I tried to find something in the forum, but I can not find an example of how to consume a basic webservice.

It seems that I have to pass a XML string first, I am very confused.

webservice: WebService Web Service
Method: HelloWorld
Parameter: d (string)

Webservice code (very simple):

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function HelloWorld (d As String) As String
Return "Parameter value: " & d
end Function

end Class

That's all . Any help?
 

jroriz

Active Member
Licensed User
Longtime User
I'm new at B4a (very pleased so far), but only know to create and consume web services (SOAP) using ASP.NET.

What would be the best type of webservice to create using ASP.NET that would be easily consumed in B4a, and which method to use, or some such. I've seen all the examples that use the HTTP library and HTTPUtils, but without success.

Thanks in advance, and congratulations for the excellent product.
 
Upvote 0

jroriz

Active Member
Licensed User
Longtime User
Solved - .NET web services

Answering my own question.

Just in case anyone comes here ...

Your web services written in. NET are ALMOST READY to be consumed in B4a.

The main difference is that in WS written in .NET GET method is disabled by default.

See the differences to consume a WS in .NET and B4a:

. NET
- Reference the WS;
- Instantiate and consume the WS, calling the method and passing the parameters;
- Receive returned values​​.

B4A
- There are no references;
- The WS method is called with the parameters in the URL. Eg: "http://www.somepage.com/wstst.asmx?param1=value1";
- The hole xml page is returned (not just one value), and you have to FIND what you care about in the string returned;
- As stated above, you will have to enable the GET method. To do this, in the system.web section of web.config, add:

**** <webServices>
****** <protocols>
******** <add name="HttpGet"/>
****** </ protocols>
**** </ webServices>

Correct me if I'm wrong.

Code attached.
 

Attachments

  • testes.zip
    364.3 KB · Views: 513
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Urgent assistance needed

hi,

i am newto b4a, looks nice so far...

for the past few weeks i've been banging my head to the wall with a very basic task - consuming a web service.

i've tried all examples and modified them and still it did not work.

i am using the latest version of b4a
tried on the emulator

there is a web service created with vb.net to .asmx
there is a function in the web service that takes two parameters and returns back as result an integer

can any one please try to assist ?
a working demo or code sample will be MUCH appreciated

i gave it up as i got into a deadend

thanks
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
Hi,
Can you post the URL details and parameters for your web service and I will have a look at it, I use web service a lot using HttpUtils and it works very well.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Dear Pals,
after banging my head so much i gave it another last try - and cracked it - now i got it all working like charm.
the secret was very simple - it does not even look close to what i was expecting like in normal .Net, here it required XML post, once i got that into my thik head it was all going smooth.
so thank you for the good will, i really appreciate it

now my next task is how to parse the returning XML ?
i see the XML in the debugger and it is correct, is there an easy way or function to get a particular parameter from an XML structure ?

OMG - now i like it even more :)
 
Upvote 0

lagore

Active Member
Licensed User
Longtime User
Have a look at http://www.b4x.com/forum/basic4android-getting-started-tutorials/6866-xml-parsing-xmlsax-library.html that explains how to parse XML, if the return was very simple with say only 1 item you could get a substring of the return using the XML tags, so for "<TITLE>Greatest Hits</TITLE>" the start of the data is the index of <TITLE> + 7 and the end index is </TITLE>
B4X:
Dim DataString, ReturnString As String
DataString = ReturnString.SubString2(ReturnString.IndexOf("<TITLE>") + 7,ReturnString.IndexOf("</TITLE>"))
as I said if there are a few returns then stick with the XML parser.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
guys, you are all saints :)
thanks so much for your assistance
i will now go and drill on the XML

since you were so kind, and gave me a helping finger, i will try now to grab the whole hand :) - can i use in any way sqlite db ?
any samples for it ?

as much as i look further into b4a i like it more and more
very good development environment
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
on another topic - keyboard

hi,

if it is not too much - can any one hekp on how to control the screen when the keyboard is popped up ?
i mean - if i edit a text field on top of the form and the keyboard is being openned it is ok but if the text field is in the mid form or bottom the keyboard actually hides the field. i saw on other apps that the form scrolls or folds to show the edited field - how do i do it ?

thanks so much...
 
Upvote 0
Top