我一直在使用 ksoap 库来使用 .net Web 服务。
我遇到了这种错误
“预计:START_TAG{http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/}信封(位置:START_TAG @1:7 in java.io.InputStreamReader@40d0c7d8)"
我已经到处寻找但找不到任何好的帮助。
这是我尝试使用网络服务的代码。
public class WebInvoke {
private static final String NAMESPACE = "http://tempuri.org/" ;
private static final String METHOD_NAME = "login";
private static final String SOAP_ACTION = NAMESPACE + METHOD_NAME;
private static final String URL = "http://10.0.2.2/Service1.asmx";
private final SoapSerializationEnvelope envelope;
public WebInvoke()
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo quotesProperty = new PropertyInfo();
quotesProperty.setName("UserName");
quotesProperty.setValue("admin");
quotesProperty.setType(String.class);
request.addProperty(quotesProperty);
quotesProperty = new PropertyInfo();
quotesProperty.setName("Password");
quotesProperty.setValue("a");
quotesProperty.setType(String.class);
request.addProperty(quotesProperty);
Log.e("Request Assign", request.toString());
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
Log.e("Envelope Assign", envelope.toString());
}
public String Fetch()
{
String result = "";
HttpTransportSE httpRequest = new HttpTransportSE(URL);
try
{
envelope.xsd = SoapSerializationEnvelope.XSD;
envelope.enc = SoapSerializationEnvelope.ENC;
httpRequest.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
Log.e("httpRequest.call", "httpRequest.call");
httpRequest.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
result = response.toString();
}
catch(Exception e)
{
//e.printStackTrace();
Log.e("httpRequest.call Exception", e.getMessage());
}
return result;
}
}
尝试获得更好的代码。你的代码听起来有点笨拙。
“org.xmlpull.v1.XmlPullParserException:预期:START_TAG”错误 https://stackoverflow.com/questions/5791337/org-xmlpull-v1-xmlpullparserexception-预期开始标签错误
检查这个。
使用 .netcode 检查您的方法名称和 url
在 C# appcode 文件中排除 app_html.offline,因为它不允许任何数据库项目运行。
希望对你有帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)