0

现在我正在通过 SOAP 方法在 android 中使用 dot net web 服务。这就是我要使用的确切 web 服务。

“http://54.251.60.177/TMSOrdersService/TMSDetails.asmx”这个web服务实际上是在获取xml格式的数据

此 Web 服务的输入值是

FromDate : 01/01/2012

截止日期 : 07/07/2012

将这些输入值输入编辑文本框后,当我单击“调用”按钮显示空白屏幕时,我在 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

请问有什么建议吗?

4

2 回答 2

2

我不知道你是否使用 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-11T07:13:59.897 回答
0

Web 服务实际上没有返回所有提交日期的有效输出。由于试错,Web 服务返回了有效的输出

FromDate: 01/09/2012

截止日期:2012 年 5 月 9 日

编辑:

使用上述值,我可以获得以下 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>

于 2012-09-11T06:17:21.393 回答