【问题标题】:Android KSOAP2 call ASMX Web ServiceAndroid KSOAP2 调用 ASMX Web Service
【发布时间】:2014-05-20 23:48:56
【问题描述】:

类 wsCall 扩展 AsyncTask {

private static final String SOAP_ACTION = "http://tempuri.org/PrivateLogin";
private static final String METHOD_NAME = "PrivateLogin";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://192.168.1.110/omoffice/service/wsomjobs.asmx";        
private Context mContext;   

public wsCall (Context context){
     mContext = context;
}

 @Override
protected void onPreExecute() {
    // TODO Auto-generated method stub
    super.onPreExecute();
}

protected String doInBackground(String... params) 
{   
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    request.addProperty("userid","poma");           
    request.addProperty("pw","1");
    request.addProperty("azienda","1");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);             
    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);               
        SoapObject response = (SoapObject) envelope.bodyIn;
        return "OK";

在 androidHttpTransport.call(SOAP_ACTION, envelope) 中我收到此错误:java.net.ProtocolException: unexpected end of stream

有人帮帮我吗?

谢谢 马可

【问题讨论】:

    标签: android asmx ksoap2


    【解决方案1】:

    你确定你使用的SOAP版本是10吗??

    尝试使用SoapPrimitive response = (SoapPrimitive) envelope.getResponse(); 而不是SoapObject response = (SoapObject) envelope.bodyIn;

    【讨论】:

    • 我试过了,但错误在这一行之前。我收到错误:androidHttpTransport.call(SOAP_ACTION,信封)。
    • 尝试将这一行 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10); 更改为 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    猜你喜欢
    • 1970-01-01
    • 2018-01-11
    • 2014-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多