获得以下错误,同时通过ksoap2在android系统调用Web服务(.SVC) [英] Getting following error while calling a web service(.svc) in android through ksoap2

查看:283
本文介绍了获得以下错误,同时通过ksoap2在android系统调用Web服务(.SVC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我收到以下错误,同时运行我的Andr​​oid项目中,我打电话是通过KSOAP2.Please web服务提供给我一些资料,关于这个错误。

Guys I am getting the following error while running my android project in which I m calling a webservice through KSOAP2.Please provide me some information to regarding this error.

料:END_TAG {} http://schemas.xmlsoap.org/soap/envelope/机构(位置:END_TAG @ 1:742 java.io.InputStreamReader@44ea98d0

我的继承人的java code: -

Heres my java code:-

public class LoginWebService extends Activity{

private static final String NAMESPACE = "http://tempuri.org/" ;
private static final String URL = "http://192.168.1.103/InspectWcf/InspectServiceWcf.svc";
private static final String CheckUserAuthentication_SOAP_ACTION = 
        "http://tempuri.org/IInspectService/CheckUserAuthenticationResponse";
private static final String METHOD_NAME = "CheckUserAuthentication";
EditText useridText,passText;
TextView errorText;
Button loginButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    useridText = (EditText)findViewById(R.id.userEditText);
    passText = (EditText)findViewById(R.id.passEditText);
    errorText = (TextView)findViewById(R.id.errorTextView);
    loginButton = (Button)findViewById(R.id.loginButton);

    loginButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            CheckAuthentication();
        }
    });
}

public void CheckAuthentication(){
    SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);
//  SoapObject parameter = new SoapObject(NAMESPACE, "CheckUserAuthentication");

    request.addProperty("username", "survaa");
    request.addProperty("password", "survaa");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    Log.d("envelope",envelope.toString());
    envelope.dotNet=true;
    envelope.setOutputSoapObject(request);

    Log.d("envelope", envelope.toString());
    HttpTransportSE httpt = new HttpTransportSE(URL);
    Log.d("httpt",httpt.toString());
    try{
        httpt.call(CheckUserAuthentication_SOAP_ACTION , envelope);
        Log.d("httpt",httpt.toString());

        SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
    //  String str = result.toString();
    //  Log.d("result", result.toString());
        if(result != null){
            errorText.setText("Correct UserId or Password");

        }
        else{
            errorText.setText("Invalid UserId or Password");

        }
    }
    catch(Exception e){

        errorText.setText(e.getMessage());

    }
}

}

感谢名单中andvance。

Thanx in andvance.

推荐答案

好吧,有两个选项:

一)错误与命名空间,SOAP_ACTION,METHOD_NAME字符串。但是,如果您选中它们,然后:

a) The error is related to the NAMESPACE, SOAP_ACTION, METHOD_NAME strings. But if you have checked them, then:

二)错误与您的Web服务。

b) The error is related to your web service.

有关我的经验(Ksoap2和Axis2)预期:END_TAG错误出现时,客户端已成功地发送请求,但一直没有叫GETRESPONSE()方法

For my experience (Ksoap2 and Axis2) the "expected:END_TAG" error comes when the client has succesfully sent the request but hasn't called the getResponse() method.

你有任何工具来检查SOAP消息的交换?
可以使用的tcpdump,例如,以监视SOAP传输

Do you have any tool to check the interchange of SOAP messages? You can use tcpdump, for example, to monitor the SOAP traffic:

$sudo tcpdump -i eth0 -A -s 8080 -l 'dst host localhost and port 8080'

(eth0和8080端口,你也许不同)

(eth0 and port 8080 maybe different for you)

如果您的Web服务将返回原始对象(整型,布尔型等),你可以使用:

If your web service is returning a primitive object (int, boolean, etc) you can use:

Object response = envelope.getResponse();

如果返回一个复杂的对象(字符串,等等),那么:

If is returning a complex object (String, etc) then:

SoapObject response = (SoapObject)envelope.getResponse();

(对不起,我的英文)。

(Sorry for my English).

这篇关于获得以下错误,同时通过ksoap2在android系统调用Web服务(.SVC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆