gpt4 book ai didi

android org.xmlpull.v1.xmlpullparserexception expected start_tag http//schemas.xmlsoap.org/soap/envelope/envelope 位置开始标记

转载 作者:行者123 更新时间:2023-11-30 03:25:07 27 4
gpt4 key购买 nike

我正在为 android 中的 DBConnection 起诉 asp.net webservice (visual studio 2008)。

运行成功。

我的安卓代码是:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final AlertDialog ad=new AlertDialog.Builder(this).create();


TextView tv=(TextView)findViewById(R.id.tvArray);

Button btnCall=(Button)findViewById(R.id.btnCall);

btnCall.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

CallSoap cs=new CallSoap();

try
{
String name=cs.Call();
Toast.makeText(getApplicationContext(), name, Toast.LENGTH_LONG).show();
}
catch(Exception ex)
{
ad.setMessage(ex.getMessage());
}
}
});

}

和调用方法:

import java.util.ArrayList;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.widget.Toast;

public class CallSoap
{
public final String SOAP_ACTION ="http://tempuri.org/GetData";


public final String OPERATION_NAME = "GetData";

public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

public final String SOAP_ADDRESS = "http://10.0.2.2:8080/Service1.asmx";

public CallSoap()
{
}


public String Call()
{
SoapObject req=new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
//envelope.headerOut = security; // this is an Element[] created before
envelope.encodingStyle = SoapEnvelope.ENC;
envelope.setAddAdornments(false);
envelope.implicitTypes = false;
envelope.setOutputSoapObject(req);

HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
Object response=null;


try
{
httpTransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse();
//Toast.makeText(this, "this is my Toast message!!! =)", Toast.LENGTH_LONG).show();
}
catch (Exception exception)
{
response=exception.toString();
}
return response.toString();
}

}

当我点击应用程序上的按钮时出现错误:

android org.xmlpull.v1.xmlpullparserexception expected start_tag http //schemas.xmlsoap.org/soap/envelope/ envelope position start tag

我在堆栈上有很多关于这个的问题。

我发现一般是服务方法写错了。

但就我而言,我检查了所有这些。一切都是对的。

您还可以检查:我有我正在运行的服务的快照,其中给出了每件事:

enter image description here

请帮帮我。

最佳答案

我认为你必须输入端口号而不是 8080

关于android org.xmlpull.v1.xmlpullparserexception expected start_tag http//schemas.xmlsoap.org/soap/envelope/envelope 位置开始标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18355392/

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