tailieunhanh - Programming Java 2 Micro Edition on Symbian OS A developer’s guide to MIDP 2.0 phần 7

Các đối số requiredSecurity quy định cụ thể mức độ bảo mật cho kết nối và có thể có một trong ba giá trị quy định tại ServiceRecord:Đối số mustBeMaster cho biết thiết bị địa phương phải là bậc thầy trong các kết nối đến dịch vụ này. Nếu thiết bị giả địa phương sẵn sàng được chủ hay nô lệ trong | 2 72 MIDP CASE STUDIES expenses that have been approved or rejected by the current user acting in the budget holder role. The synchronization thread communicates with the server using the HTTP protocol. XML formatted requests that contain all the information that the device wishes to exchange are sent. After processing the request the server formats an XML response containing updates. XML is space inefficient many additional bytes are required to encode information. So why use XML in an environment where memory is at a premium and the network connections are slow XML is convenient it is easy to validate and there are many existing tools and APIs to simplify its use allowing the expense application prototype to be created in the minimum of time. The class is used for the server communication. Requests to the server use a utility method sendMessageToServer that has a single parameter containing the XML request to be sent. An HttpConnection is opened to the server URL and the XML request sent via the connection s Outputstream. The response is read into a StringBuffer before being returned to the caller. If there is an error then an exception is thrown that will eventually find its way back to the synchronization form to be presented to the user. SynchronizationThread sendMessageToServer method private String sendMessageToServer String message throws IOException ServerCommException StringBuffer sb new StringBuffer HttpConnection connection null InputStream is null open connection connection HttpConnection send message to server OutputStream os make sure we got a good response code . 200 300 if 200 300 is byte buffer new byte 512 int bytesRead 0 while -1 bytesRead buffer 0 512 new String buffer 0 bytesRead else error of some kind

TỪ KHÓA LIÊN QUAN