使用soap将mysql转至android
我很清楚android不支持mysql 但我需要连接 mysql 并从我研究的数据库中获取信息,
有 SOAP 和 REST 服务可以从 android 连接 mysql 有可能吗?然后给我一个想法,如果可能的话请举个例子
i know very well that android not support the mysql
but i need to connect mysql and get the information from database
i studied there are SOAP and REST services to connect mysql from android
is it possible?then give me one idea and if possible one example pls
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在连接或不连接数据库的情况下从数据库获取数据。您可以使用或不使用 SOAP 来获取它。服务器上的代理(通常是 CGI 脚本)代表客户端发出数据库请求。在 SOAP 中,查询和响应通常以 XML 进行编码,并且始终通过标准 Internet 方法(例如 HTTP 或 SMTP)进行传输。
非 SOAP 方法包括 CORBA、简单 RPC 和自行开发的解决方案。如果数据库对 Internet 开放,则可以直接连接到服务器上的数据库端口。
只有安全限制限制了您的操作。在只能使用邮件、HTTP 和 FTP 的环境中,SOAP 是一个很好的协议。如果客户端实际上是一个 Web 浏览器,那么 AJAX 是理想的选择。
对于典型的数据请求,您只需知道服务器上的 URL(以及相关协议)即可查询数据。例如,使用 HTTP:
服务器端脚本 chart_data.cgi 读取查询(在本例中来自 GET 请求),从数据库检索信息并将其以 XML 编码发送回到客户端,只需将 HTTP 标头和 XML 内容写入标准输出即可。 Javascript 和浏览器协议 XMLHttpRequest 使 HTML 请求和 XML 接收成为可能。
因此,即使在 Android 中,当您浏览网页并查看所有信息时,例如在亚马逊上。许多信息由亚马逊的代理从他们的数据库中检索,为客户端(Android 上的浏览器)格式化并发送回客户端。不需要 Android 特定的编码。
使用自定义远程代理(例如服务器上的 CGI 脚本)来访问远程数据库。 Android只需要与代理进行通信。
You can get the data from the database with or without connecting to it. You can get it with or without SOAP. An agent on the server, usually a CGI sript makes the database request on the client's behalf. In SOAP, the the query and response are often encoded in XML, and always transmitted by standard Internet methods such as HTTP or SMTP.
Non SOAP methods include CORBA, simple RPC, and home-grown solutions. If the database is open to the Internet, then a direct connection to the database port on the server is possible.
It's only the security restrictions that limit what you can do. In an environment where only mail, HTTP and FTP are possible, SOAP is a good protocol. If the client is actually a web browser, then AJAX is ideal.
For a typical data request, all you need to know is the URL (and associated protocol) on the server to query for the data. For example, using HTTP:
The server-side script, chart_data.cgi reads the query (from a GET request in this case), retrieves the information from the database and sends it, encoded in XML, back to the client, simply by writing the HTTTP header and XML content to standard output. It is Javascript and a browser protocol XMLHttpRequest that make the HTML request and XML receipt possible.
So even in Android, when you browse the web and see all that information, on Amazon for example. A lot of that information is retrieved by agents at Amazon from their database, formatted for the client(the browser on Android) and sent back to the client. No Android-specific coding is required.
Use a custom remote agent such as a CGI script on a server to access a remote database. Android only needs to communicate with the agent.
使用您选择的语言编写 SOAP 服务器:
调用来自Android:
当然,您不必在 SOAP 中执行此操作。您可以以任何格式(如 JSON、纯文本、XML、CSV(甚至 HTML?)...)从 Web 服务输出数据,并从 Android 中使用它。
Write a SOAP server using the language of your choice:
Call it from Android:
Of course, you don't have to do it in SOAP. You can just output the data from your web service in any format like JSON, plain text, XML, CSV, (or even HTML?) ... and consume it from Android.