问题
I do a mobile application which the user can use it get the required place’s number. The user must select the appropriate city and category to get the place’s information. All the information stored in the database.
What I want to know that ..
1) What is the benefit from the web service?
2) How to connect the web service and MySQl database?
3) How to connect the web service and mobile application to get the information from the database?
回答1:
1) Benefits. You didn't mentioned other options, but if you are talking about some custom server-side implementation, the benefits are numerous:
- It's easy to connect to web service from J2ME.
- Multiple connection sessions at one time.
- You can use web service from different applications and different technologies.
- No issues with authentication and authorization.
- You just call method from ws and in response you get easy-to-parse XML.
2) Web service - MySQL:
- You have to create a Tomcat or IIS web service.
- From web service code connect to MySQL, call a query and return the result.
For Tomcat and Java web service:
Getting started with Web Services Using Apache Axis Developing and Deploying Java Web Services with MySQL on Apache Tomcat and Axis on Windows JDBC for MySQL
For IIS and C#/.NET web service: CodeProject:Your first C# Web Service by Chris Maunder How to connect to MySQL 5.0. via C# .NET and the MySQL Connector/Net
3) J2ME - web service (with JAX-RPC) 1. generate stub from web service WDDL using J2ME Wireless Toolkit 2. add stub to your project, import stub namespace, set connection properties and call stub methods How to build and run a J2ME Web service application? Web Services APIs for J2ME, Part 1: Remote service invocation API
来源:https://stackoverflow.com/questions/757503/connect-web-server-with-database-and-j2me