gpt4 book ai didi

java - "org.xmlpull.v1.XmlPullParserException: expected: START_TAG"错误

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

我试图在 android 中将 ksoap2 与网络服务一起使用,但我认为我无法从网络服务获得响应。任何人都知道为什么我会收到此错误?“org.xmlpull.v1.XmlPullParserException:预期:START_TAG”

我的代码是:

public class ANDROIDsapActivity extends Activity {
/** Called when the activity is first created. */
private static final String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
private static final String URL = "http://192.168.2.5:8000/sap/bc/srt/wsdl/bndg_E0DFBFD4F407C3F1A6A000155D02060A/wsdl11/allinone/ws_policy/document?sap-client=500";
private static final String SOAP_ACTION = "zws_get_customer";
private static final String METHOD_NAME = "ZfGetCustomers";
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.textView1);

SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("IM_NAME","M");

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.setOutputSoapObject(Request);

soapEnvelope.encodingStyle = SoapSerializationEnvelope.ENC2003;
soapEnvelope.bodyOut = Request;
soapEnvelope.dotNet = true;
soapEnvelope.encodingStyle = SoapSerializationEnvelope.XSD;

// AndroidHttpTransport aht = new AndroidHttpTransport(URL);
HttpTransportSE aht = new HttpTransportSE(URL);
aht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
headers.add(new HeaderProperty("Authorization", "basic " +
Base64.encode("username:password".getBytes())));

try {
aht.call(SOAP_ACTION, soapEnvelope,headers);
SoapPrimitive resultString = (SoapPrimitive) soapEnvelope.getResponse();
tv.setText("Status: " + resultString);
} catch (Exception e) {
// TODO: handle exception
tv.setText(e.toString());
}
}
}

我的完整错误是:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG  
{http://schemas.xmlsoap.org/soap/envelope/} Envelope
(position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions
targetNamespace='urn:sap-com:document:sapsoap:functions:mc-style'>
@1:630 in java.io.InputStreamReader@43e50a10

我陷入了这个错误,无法继续。请帮忙!

编辑:我已经解决了这个问题。请阅读下面关于评论和答案的我的回答。我希望我能以某种方式对某人有所帮助。

最佳答案

我已经通过更改 Web 服务样式解决了我的问题。如果要集成 SAP 和 android,请使用 Restful webservice 系统而不是 SOAP。

关于java - "org.xmlpull.v1.XmlPullParserException: expected: START_TAG"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7433573/

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