gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 01:48:17 27 4
gpt4 key购买 nike

你好,我是 webservice 的新手,我正在使用 SOAP 服务并在本地主机上运行但出现此错误这是我的代码:public class Neteesh extends Activity{

private static final String URL = "http://localhost:7642/Service1.asmx";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String METHOD_NAME = "HelloWorld";

private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

TextView textView = new TextView(this);

setContentView(textView);


new LongOperation().execute("");
}


private class LongOperation extends AsyncTask<String, Void, String>
{

@Override
protected String doInBackground(String... HelloWorldResult)
{
// TODO Auto-generated method stub

String value = new String();
System.out.println("Inside getLognoperation method...........");
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("billId", HelloWorldResult);

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet=true;
soapEnvelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse();
value = resultString.toString();
System.out.println("This getAccountsNames xmls is : "+value);
} catch (Exception e) {
e.printStackTrace ();
}
return value;
}
}
}

这是我的日志:

  11-16 11:11:48.371: W/System.err(1324): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <HTML>@2:7 in java.io.InputStreamReader@4101fc30) 
11-16 11:11:48.371: W/System.err(1324): at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
11-16 11:11:48.371: W/System.err(1324): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
11-16 11:11:48.381: W/System.err(1324): at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
11-16 11:11:48.381: W/System.err(1324): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
11-16 11:11:48.381: W/System.err(1324): at com.example.helloworldwebservice.Neteesh$LongOperation.doInBackground(Neteesh.java:55)
11-16 11:11:48.381: W/System.err(1324): at com.example.helloworldwebservice.Neteesh$LongOperation.doInBackground(Neteesh.java:1)
11-16 11:11:48.381: W/System.err(1324): at android.os.AsyncTask$2.call(AsyncTask.java:287)
11-16 11:11:48.381: W/System.err(1324): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-16 11:11:48.391: W/System.err(1324): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-16 11:11:48.391: W/System.err(1324): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-16 11:11:48.404: W/System.err(1324): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-16 11:11:48.404: W/System.err(1324): at java.lang.Thread.run(Thread.java:856)
11-16 11:11:48.404: W/System.err(1324): [ 11-16 11:11:48.404 1324: 1337 I/expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG Exception

如果我的结构有误,请编辑问题,如何解决。我需要字符串响应在 web 服务中的哪一个。请帮忙提前谢谢..

最佳答案

由于Android模拟器在虚拟机上运行所以你必须使用这个

private static final String URL = "http://10.0.2.2:7642/Service1.asmx";

代替

private static final String URL = "http://localhost:7642/Service1.asmx";

然后

protected String doInBackground(String... HelloWorldResult) 
{
.....
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("billId", HelloWorldResult[0]);
.....
}

正如你现在正在尝试的那样......

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com