现在,我正在使用android中的点网络web服务,使用的方法是SOAP.This正是我试图使用的web服务。
"http://54.251.60.177/TMSOrdersService/TMSDetails.asmx“这个web服务实际上是以xml格式撤回数据。
此web服务的输入值为
FromDate : 01/01/2012
ToDate : 07/07/2012
在将这些输入值输入到编辑文本框后,当我单击显示空白屏幕的“调用”按钮时,我在logcat上也找不到任何东西。
Logcat
09-11 11:11:41.314: D/AndroidRuntime(442): Shutting down VM
09-11 11:11:41.323: D/dalvikvm(442): Debugger has detached; object registry had 1 entries
09-11 11:11:41.374: I/AndroidRuntime(442): NOTE: attach of thread 'Binder Thread #3' failed
09-11 11:11:41.844: D/AndroidRuntime(450): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
09-11 11:11:41.844: D/AndroidRuntime(450): CheckJNI is ON
09-11 11:11:41.974: D/AndroidRuntime(450): --- registering native functions ---
09-11 11:11:42.034: I/jdwp(450): Ignoring second debugger -- accepting and dropping
09-11 11:11:42.524: I/ActivityManager(75): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.test_webservice/.Test_webservice }
09-11 11:11:42.584: D/AndroidRuntime(450): Shutting down VM
09-11 11:11:42.604: D/dalvikvm(450): Debugger has detached; object registry had 1 entries
09-11 11:11:42.714: I/AndroidRuntime(450): NOTE: attach of thread 'Binder Thread #3' failed
09-11 11:11:48.973: D/dalvikvm(178): GC_EXPLICIT freed 438 objects / 20576 bytes in 100ms请给我建议?
发布于 2012-09-11 07:13:59
我不知道你是否在使用ksoap2,但是我编写并测试了这个函数,它运行得很好,我得到了值。希望它有帮助:
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public void getTMSChart(String FromDate, String ToDate)
{
System.setProperty("http.keepAlive", "false");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
String namespace = "http://tempuri.org/";
String url = "http://54.251.60.177/TMSOrdersService/TMSDetails.asmx";
String method = "GetTMSChart";
SoapObject request = new SoapObject(namespace, method);
request.addProperty("FromDate", FromDate);
request.addProperty("ToDate", ToDate);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
try {
androidHttpTransport.call(namespace + method, envelope);
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject root = (SoapObject) ((SoapObject)(result).getProperty(0)).getProperty("NewDataSet");
int tablesCount = root.getPropertyCount();
for (int i = 0; i < tablesCount; i++)
{
SoapObject table = (SoapObject) root.getProperty(i);
int propertyCount = table.getPropertyCount();
for (int j = 0; j < propertyCount; j++)
{
String orderNo = table.getPropertyAsString("Order_No");
int freightRate = Integer.parseInt(table.getPropertyAsString("Freight_Rate"));
int marginPercent = Integer.parseInt(table.getPropertyAsString("Margin_Percent"));
// whatever you do with these values
}
}
}
catch (Exception e) {
}
}发布于 2012-09-11 06:17:21
web服务实际上没有返回所有提交的日期的有效输出。通过试用错误,web服务返回有效的输出
FromDate: 01/09/2012
ToDate: 05/09/2012
编辑:
使用上述值,我可以获得以下xml:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetTMSChartResponse xmlns="http://tempuri.org/">
<GetTMSChartResult>
<NewDataSet xmlns="">
<Table>
<Order_No>OR00000004</Order_No>
<Freight_Rate>225</Freight_Rate>
<Margin_Percent>87</Margin_Percent>
</Table>
</NewDataSet>
</GetTMSChartResult>
</GetTMSChartResponse>https://stackoverflow.com/questions/12363312
复制相似问题