0

这是完整的代码.. 运行应用程序后,屏幕变为空白。没有输出。我添加了 http:10.0.2.2 因为我正在使用

爪哇

package com.example.final_mobile;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.os.StrictMode;
import android.widget.TextView;

public class AndroidClassActivity extends Activity {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
        .permitAll().build();
private static final String SOAP_ACTION = "http://srfsolution.com/GetClients";

private static final String OPERATION_NAME = "GetClients";

private static final String WSDL_TARGET_NAMESPACE = "http://srfsolution.com/";

private static final String SOAP_ADDRESS = 
    "http://10.0.2.2:8080/Web_Service/WebService.asmx?wsdl";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    StrictMode.setThreadPolicy(policy);
    TextView textView = new TextView(this);

    setContentView(textView);

    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
            OPERATION_NAME);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;

    envelope.setOutputSoapObject(request);

    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);

    try

    {

        httpTransport.call(SOAP_ACTION, envelope);

        Object response = envelope.getResponse();

        textView.setText(response.toString());

    }

    catch (Exception exception)

    {

        textView.setText(exception.toString());

    }

}
}

xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".AndroidClassActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

</

wsdl

POST /Web_Service/WebService.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://srfsolution.com/GetClients"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

 <soap:Body>
  <GetClients xmlns="http://srfsolution.com/">
  <driverid>string</driverid>
  </GetClients>
 </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"     
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
   <GetClientsResponse xmlns="http://srfsolution.com/">
  <GetClientsResult>
    <driverid>string</driverid>
    <scheduleid>string</scheduleid>
    <clientid>string</clientid>
    <clientname>string</clientname>
  </GetClientsResult>
 </GetClientsResponse>
  </soap:Body>
</soap:Envelope>
4

1 回答 1

0

尝试设置输入数据。看起来您没有设置请求参数。例如,

 SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);

 request.addProperty("driverid", "MYAPPDRIVER01");
于 2013-07-23T17:08:05.080 回答