开发者

Android and REST Web Service Response Help

开发者 https://www.devze.com 2023-03-28 01:30 出处:网络
The problem: How to send data to and from a RESTful web service to an android phone.The data currently is sent in bytes and there 开发者_JS百科are multiple messages sent both ways until the entire mes

The problem:

How to send data to and from a RESTful web service to an android phone. The data currently is sent in bytes and there 开发者_JS百科are multiple messages sent both ways until the entire message is sent (denoted by some delimiter in byte array). It is easy to send to the web service from android using a POST to web service. The service must now send multiple responses back to android.

I am wondering if this solution would work, or if there is something better?

Suggested Solution:

After a successful post to the web service from android, the android will receive an initial response from the post function call. This response will contain a message ID. Now if that response does not have the message delimiter, then android makes a call to the POST function again with a special parameter containing it's Message ID and the web service will return the next part of the byte array. This continues until the entire message is sent.

Thanks in advance for any help. Also to note, the web service knows the phone's IP address after the first message and we must keep this connection-less (so no sockets)


REST uses a simple Request/Response mechanism. The way http works is that you send a Request, and the server sends a Response back. What you are mentioning is behaviour more like Web Sockets. You should do a little research on web sockets. They allow you to make a connection with a server from the client, and then until the connection is severed, the server can send messages to the client.

0

精彩评论

暂无评论...
验证码 换一张
取 消