0
我试图与网络服务(国家详细信息)的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);
}
});
好吧,我试图了解分析,但对我来说还是扑朔迷离。我通过查看另一个类似的代码使我的程序工作。所以我不确定我使用了什么样的解析?无论如何,我很高兴它工作(代码编辑后) – tarja