android - org.xmlpull.v1.XmlPullParserException : expected: START_TAG {http://schemas. xmlsoap.org/soap/envelope/}信封

标签 android web-services soap wsdl

我试图在我的应用程序中访问 soap api 以进行登录,但出现上述错误,任何人都可以告诉我哪里出错了,这是我第一次使用 soap api。 这是我的 Soap 代码:-

Vector<Object> args = new Vector<Object>();
			Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
			hashtable.put("Email", "mss.siddhart28@gmail.com");
			hashtable.put("Password", "siddharth");
			args.add(hashtable);
			SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
					SoapEnvelope.VER11);
			envelope.dotNet = true;
			envelope.xsd = SoapSerializationEnvelope.XSD;
			envelope.enc = SoapSerializationEnvelope.ENC;
			(new MarshalHashtable()).register(envelope);
			HttpTransportSE androidHttpTransport = new HttpTransportSE(
					"http://tempuri.org/", 15000);
			androidHttpTransport.debug = true;
			String result = "";
			try {

				SoapObject request = new SoapObject("http://tempuri.org", "call");
				request.addProperty("resourcePath", "User_Login");
				 request.addProperty("args", args);

				envelope.setOutputSoapObject(request);
				androidHttpTransport.call("call", envelope);
				envelope.setOutputSoapObject(request);
				result = envelope.getResponse().toString();
				Toast.makeText(MainActivity.this, "envelope is" + envelope, Toast.LENGTH_LONG).show();
				System.out.println("result signup: " + result);
			} catch (EOFException e) {
				e.printStackTrace();
				return "restart";
			}

这是我的 wsdl :-

POST /w4w/w4wservice.asmx HTTP/1.1
Host: 64.31.2.58
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/User_Login"

<?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>
    <User_Login xmlns="http://tempuri.org/">
      <Email>string</Email>
      <Password>string</Password>
    </User_Login>
  </soap:Body>
</soap:Envelope>

任何帮助将不胜感激。

谢谢

最佳答案

我终于解决了我的问题.. 我在这里发布代码,以便其他人可以获得帮助。

private   String SOAP_ACTION = "http://tempuri.org/User_Login";
	private   String METHOD_NAME = "User_Login";
	private   String NAMESPACE = "http://tempuri.org/";
	private   String URL = "http://64.31.2.58:8080/w4w/w4wservice.asmx";

public String logIn() {
			
			SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
					SoapEnvelope.VER11);
			envelope.dotNet = true;
			envelope.xsd = SoapSerializationEnvelope.XSD;
			envelope.enc = SoapSerializationEnvelope.ENC;
			(new MarshalHashtable()).register(envelope);
			HttpTransportSE androidHttpTransport = new HttpTransportSE(
					URL, 15000);
			androidHttpTransport.debug = true;
			String result = "";
			try {

				SoapObject request = new SoapObject(NAMESPACE,
						METHOD_NAME);
				request.addProperty("Email", Email);
				request.addProperty("Password", Password);

				envelope.setOutputSoapObject(request);
				androidHttpTransport.call(SOAP_ACTION, envelope);
				result = envelope.getResponse().toString();
				
				System.out.println("result signup: " + result);
			} catch (EOFException e) {
				e.printStackTrace();
				return "restart";
			} catch (SoapFault e) {
				e.printStackTrace();
				if (e.getMessage()
						.contains("Session expired. Try to re-login.")) {
					return "restart";
				}
				return "Email Already Exists";
			} catch (NullPointerException e) {
				e.printStackTrace();
				return "restart";
			} catch (Exception e) {
				e.printStackTrace();
				return "";
			}
			System.out.println("registration result :" + result);
			return result;

		}

关于android - org.xmlpull.v1.XmlPullParserException : expected: START_TAG {http://schemas. xmlsoap.org/soap/envelope/}信封,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31177154/

相关文章:

Android:更改菜单分隔符的左右边距

python - Zeep - 关闭主机验证

android - android中的图形绘制库

android - 在 Google Play 之外更新 Android 应用程序

java - JAXWS 和 session

c# - 是否使用Web服务或HttpHandler来提供图像?

git - 使用 GitHub blob api 获取文件的所有版本

web-services - Visual Studio 2013 使用有效的 wsdl 文件创建服务数据源时出错

java - 客户端 Axis 1.2 中 JDK5 Enum 的自定义序列化

java - 具有 CustomAdapter 的 Fragment 中的 OnItemClickListener 不起作用