aspose file tools*
The moose likes Android and the fly likes 1 more problem with web services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "1 more problem with web services" Watch "1 more problem with web services" New topic
Author

1 more problem with web services

Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

Good morning,
i have a web service, live on the web, it can be accessed by a browser by www.mytest.gr/serv/myservice.asmx. Its a .NET web service.


When i try this code it returns
04-07 12:06:21.177: ERROR/error message getData(6344): expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@1:6 in java.io.InputStreamReader@43ba3ad0)

if i put the url on the web browser(on android device and on my laptop) it works great. It returns my string from the web service. When i try to access it through my application it returns the error above..

cant figure out what is wrong..

one more thing,
this is returned from the web service, copy paste from firefox browser on laptop,

<string>[{"CategoryID":1,"CategoryName":"Βραχιόλια"},{"CategoryID":6,"CategoryName":"Δαχτυλίδι"},{"CategoryID":4,"CategoryName":"Καρφίτσες"},{"CategoryID":7,"CategoryName":"Κολιέ με σύρμα"},{"CategoryID":8,"CategoryName":"Κολιέ με χρωματιστά κορδόνια"},{"CategoryID":12,"CategoryName":"Μαρτυρικά"},{"CategoryID":5,"CategoryName":"Σετ"},{"CategoryID":9,"CategoryName":"Σκουλαρίκια κρίκοι"},{"CategoryID":11,"CategoryName":"Σκουλαρίκια με ημιπολύτιμες πέτρες"},{"CategoryID":10,"CategoryName":"Σκουλαρίκια μόνο μέταλλο"}]</string>
Bill Mote
Ranch Hand

Joined: Feb 04, 2010
Posts: 44
You do not have a well formed JSON string as your output. http://www.jsonlint.com is very helpful.



<string></string> is incorrect ... here's my JSON string output:

Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

good morning,
the JSON string is valid. I use KSOAP2 to get the JSON string from the web service. The weird thing is that i have a web service for other application, same concept, different data, and works perfectly. I cant seem to get the error message. Something else, when calling a web service that is hosted live on a web server, do i have to use the domain name or the actual ip address??

thanks again.
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

Good morning,
Because i see that using KSOAP2 brings up errors. One question, i have a database(access for now), i need to create some web services(.NET web services written in VB.NET). Could you give me your opinion what is the best way to get data from the database to my android application? Is there a better,easier way than the path i am following now?

Thanks in advance...
Pratik Goswami
Ranch Hand

Joined: Mar 02, 2009
Posts: 136

Hi,

For getting Web Service data I have used this approach rather going with KSOAP. (For KSOAP I had to add 2 classes to make it work, let me know if you need those classes)


The following line will give you JSON formatted data, then feed this JSON data to parsing logic.


Hope it will help you.

Thanks
Pratik Goswami


iOS * Android Developer
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

Good morning,
Well the errors where not coming from my code. The code was working, my website hosting company didn't give me a dedicated IP, so my webservice couldn't find the service. So everything OK. One more question though, i need to send some data(JSON format), that i can do, but with this data i need to send an image that is at a folder in my web server, how can i send it with the other data as one JSON object? To be more specific, i have this JSON object,
PID-int
PName-string
Pdescr-string
PPrice-float
PImage-image

how can i send an image through?

thanks in advance
 
Consider Paul's rocket mass heater.
 
subject: 1 more problem with web services