运行我通过 KSOAP2 调用 Web 服务的 android 项目时出现以下错误。
“预期:END_TAG{ http://schemas.xmlsoap.org/soap/envelope/ }正文(位置:END_TAGhttp://schemas.xmlsoap.org/soap/envelope/}s:fault>@1:742 in java。 io.InputStreamReader@44ea98d0"
这是我的java代码:
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());
}
}
}