我想从Blackbrry应用程序中调用.Net webservice。如何从我的应用程序调用webservice以及哪个协议是用户以及我必须使用哪个jar文件来调用webservice。以及如何从Blackberry的webservice获得响应?
答案 0 :(得分:0)
你可以使用这样的东西(你可能需要设置正确的请求标题和cookie):
connection = (HttpConnection) Connector.open(url
+ ConnectionUtils.getConnectionString(), Connector.READ_WRITE);
connection.setRequestProperty("ajax","true");
connection.setRequestProperty("Cookie", "JSESSIONID=" + jsessionId);
inputStream = connection.openInputStream();
byte[] responseData = new byte[10000];
int length = 0;
StringBuffer rawResponse = new StringBuffer();
while (-1 != (length = inputStream.read(responseData))) {
rawResponse.append(new String(responseData, 0, length));
}
int responseCode = connection.getResponseCode();
if (responseCode != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + responseCode);
}
responseString = rawResponse.toString();