[英]Web services in java me midlet
我正在嘗試使用Web服務(國家/地區詳細信息)制作Midlet。 我不確定如何顯示結果,其他一切似乎都可以正常工作。
這是用於獲取輸入信息和結果(我無法獲得)的代碼:
task = new SimpleCancellableTask();
task.setExecutable(new org.netbeans.microedition.util.Executable() {
public void execute() throws Exception {
String country = FieldCountry.getString();
result = CWS.getCurrencyByCountry(country);
System.out.println(result);
getResultBox().setString(String.valueOf(result));
}
});
在運行窗口中,我看到它獲取以下信息:
<NewDataSet>
<Table>
<Name>Norway</Name>
<CountryCode>no</CountryCode>
<Currency>Kroner</Currency>
<CurrencyCode>NOK</CurrencyCode>
</Table>
<Table>
<Name>Norway</Name>
<CountryCode>no</CountryCode>
<Currency>Kroner</Currency>
<CurrencyCode>NOK</CurrencyCode>
</Table>
</NewDataSet>
編輯
我已使用此代碼,現在可以正常工作:
task = new SimpleCancellableTask();
task.setExecutable(new org.netbeans.microedition.util.Executable() {
public void execute() throws Exception {
country CWS = new country_Stub();
String country = FieldCountry.getString();
String result = CWS.getCurrencyByCountry(country);
if (list != null)
{list = null; }
String name = result.substring(result.indexOf("<Name>")+6, result.indexOf("</Name>"));
String countryc = result.substring(result.indexOf("<CountryCode>")+13, result.indexOf("</CountryCode>"));
String currency = result.substring(result.indexOf("<Currency>")+10, result.indexOf("</Currency>"));
String currencyc = result.substring(result.indexOf("<CurrencyCode>")+14, result.indexOf("</CurrencyCode>"));
getList().append("Country name: ", null);
getList().append(name, null);
getList().append("Country code: ", null);
getList().append(countryc, null);
getList().append("Country currency: ", null);
getList().append(currency, null);
getList().append("Country currency code: ", null);
getList().append(currencyc, null);
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.