一尘不染

ksoap2 org.xmlpull.v1.xmlpullparserException预期的start_tag错误

java

以下是我编写的用于验证用户登录凭据的代码。使用.net编写的Web服务

private static final String SOAP_ACTION = "http://tempuri.org/getCredentials";
private static final String OPERATION_NAME = "getCredentials";
private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
private static final String SOAP_ADDRESS = "http://myStaticIP:portNo/WebSiteName/CommunicationInterface.asmx";

SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);
request.addProperty("username",Username);
request.addProperty("password", Password);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httptransport = new HttpTransportSE(SOAP_ADDRESS);

try
{
    httptransport.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
String value = result.toString();
value_LoginWS = value;
val = value;
login_status = Boolean.valueOf(result.toString());

Log.v("CS return value: -", result.toString());
return value;
}
catch (Exception e) 
{
     Log.v("Exception Soap" , e.toString());
}

符合"httptransport.call(SOAP_ACTION, envelope)" 我的exception说法

"org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>
@1:7 in java.io.InputStreamReader@41afb3f0)" <br/><br/>

我不知道错误是什么。这段代码非常适合模拟器(更改staticIP to 10.0.2.2:portNo)。

请帮我解决这个问题。

谢谢。


阅读 206

收藏
2020-09-08

共1个答案

一尘不染

我发现这个问题的答案是,在SOAP_ADDRESS字符串中,删除/
WebSiteName部分,它可以正常工作。我已经在我的android设备中对此进行了测试。完美运作。

更正后的字符串应如下所示:

private static final String SOAP_ADDRESS = "http://myStaticIP:portNo/CommunicationInterface.asmx";

其中CommunicationInterface.asmx是Web服务名称。其他静态变量保持不变。

注意:当网站托管在IIS中时使用。

2020-09-08