Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid : Ksoap2 org.xmlpull.v1.XmlPullParserException
    primarykey
    data
    text
    <p>I am new in using KSOAP2 with android and im having aproblem</p> <p>i have seen similar posts regarding the same issue but none helped me with my error</p> <p>I am trying to connect to a web service (WSDL) that returns the username i am logged in with. When i open the web service URL in any browser, it first asks for username and password then it returns this username to me, in the code im not sure how do i send this username and password. i want help in this too</p> <p>below is my code :</p> <pre><code>package com.example.webservicetest; import org.ksoap2.SoapEnvelope; import org.ksoap2.SoapFault; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.app.Activity; import android.app.Dialog; import android.app.ProgressDialog; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; public class AndroidWSClientActivity extends Activity { static final int CONNECTING_PROGRESS_DIALOG = 0; private static final String TAG = "MeGetCurrentUserId"; private static final String WSDL_URL = "http://IP:8010/sap/bc/srt/wsdl/srvc_000C293D85161ED39484844BDA759A86/wsdl11/allinone/ws_policy/document?sap-client=200&amp;sap-user=*********&amp;sap-password=********"; private static final String WS_NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style"; private static final String WS_METHOD_NAME = "MeGetCurrentUserId"; private static final String soapAction = "urn:sap-com:document:sap:soap:functions:mc-style:ZUSER_ID:MeGetCurrentUserIdRequest";//"urn:sap-com:document:sap:soap:functions:mc-style:ZME_GET_CURRENT_USER_ID3:MeGetCurrentUserIdRequest"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_android_wsclient); new GetUserNameTask().execute(); } private String parseSOAPResponse(SoapObject response) { String result = null; SoapObject usernameResult = (SoapObject) response .getProperty("MeGetCurrentUserIdResponse"); if (usernameResult != null) { for (int i = 0; i &lt; usernameResult .getPropertyCount(); i++) { SoapObject unameDescription = (SoapObject) usernameResult .getProperty(i); String Username = unameDescription .getPrimitivePropertySafelyAsString("Username"); Log.i(TAG, Username); result = Username; } } return result; } private class GetUserNameTask extends AsyncTask&lt;Void, Void, String&gt; { @Override protected void onPreExecute() { showDialog(CONNECTING_PROGRESS_DIALOG); } @Override protected String doInBackground(Void... params) { String result=null; final String str = null; try { SoapObject request = new SoapObject(WS_NAMESPACE, WS_METHOD_NAME); MarshalBase64 mbase = new MarshalBase64(); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.bodyOut = request; envelope.encodingStyle = SoapSerializationEnvelope.ENV; envelope.dotNet = true; envelope.setOutputSoapObject(request); androidHttpTransport = new HttpTransportSE(WSDL_URL); mbase.register(envelope); androidHttpTransport.call(soapAction, envelope); Log.d(TAG, "HTTP REQUEST:\n" + androidHttpTransport.requestDump); Log.d(TAG, "HTTP RESPONSE:\n" + androidHttpTransport.responseDump); final SoapPrimitive resp = (SoapPrimitive)envelope.getResponse(); Log.d(TAG, "HTTP resp:\n" + resp); Object resonse=envelope.getResponse(); String output = resonse.toString(); if (envelope.bodyIn instanceof SoapObject) { // SoapObject = SUCCESS SoapObject soapObject = (SoapObject) envelope.bodyIn; result = parseSOAPResponse(soapObject); Log.v("result", "result = "+result); } else if (envelope.bodyIn instanceof SoapFault) { // SoapFault = // FAILURE SoapFault soapFault = (SoapFault) envelope.bodyIn; try { throw new Exception(soapFault.getMessage()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } return ""; } @Override protected void onPostExecute(String response) { removeDialog(CONNECTING_PROGRESS_DIALOG); } } @Override protected Dialog onCreateDialog(int id) { switch (id) { case CONNECTING_PROGRESS_DIALOG: { ProgressDialog loadingDialog = new ProgressDialog(this); loadingDialog.setMessage("Connecting"); loadingDialog.setIndeterminate(true); loadingDialog.setCancelable(false); return loadingDialog; } } return null; } } </code></pre> <p>I get the following error :</p> <pre><code>11-19 15:30:46.520: W/System.err(29600): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG &lt;{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style'&gt;@1:687 in java.io.InputStreamReader@408e2840) 11-19 15:30:46.520: W/System.err(29600): at org.kxml2.io.KXmlParser.require(KXmlParser.java:2037) 11-19 15:30:46.520: W/System.err(29600): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:128) 11-19 15:30:46.520: W/System.err(29600): at org.ksoap2.transport.Transport.parseResponse(Transport.java:100) 11-19 15:30:46.520: W/System.err(29600): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:197) 11-19 15:30:46.520: W/System.err(29600): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95) 11-19 15:30:46.520: W/System.err(29600): at com.example.webservicetest.AndroidWSClientActivity$GetUserNameTask.doInBackground(AndroidWSClientActivity.java:95) 11-19 15:30:46.520: W/System.err(29600): at com.example.webservicetest.AndroidWSClientActivity$GetUserNameTask.doInBackground(AndroidWSClientActivity.java:1) 11-19 15:30:46.520: W/System.err(29600): at android.os.AsyncTask$2.call(AsyncTask.java:252) 11-19 15:30:46.520: W/System.err(29600): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 11-19 15:30:46.520: W/System.err(29600): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 11-19 15:30:46.520: W/System.err(29600): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081) 11-19 15:30:46.520: W/System.err(29600): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574) 11-19 15:30:46.520: W/System.err(29600): at java.lang.Thread.run(Thread.java:1020) </code></pre> <p>the error is in this line</p> <pre><code>httpTransport.call(soapAction, envelope); </code></pre> <p>here's my WSDL</p> <pre><code>This XML file does not appear to have any style information associated with it. The document tree is shown below. &lt;wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:n1="urn:sap-com:document:sap:rfc:functions" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"&gt; &lt;wsdl:documentation&gt; &lt;sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl"/&gt; &lt;/wsdl:documentation&gt; &lt;wsp:UsingPolicy wsdl:required="true"/&gt; &lt;wsp:Policy wsu:Id="BN_BN_ZME_GET_CURRENT_USER_ID"&gt; &lt;saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/&gt; &lt;saptrnbnd:OptimizedMimeSerialization xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/&gt; &lt;wsp:ExactlyOne xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"&gt; &lt;wsp:All&gt; &lt;sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"&gt; &lt;wsp:Policy&gt; &lt;sp:TransportToken&gt; &lt;wsp:Policy&gt; &lt;sp:HttpsToken&gt; &lt;wsp:Policy&gt; &lt;sp:HttpBasicAuthentication/&gt; &lt;/wsp:Policy&gt; &lt;/sp:HttpsToken&gt; &lt;/wsp:Policy&gt; &lt;/sp:TransportToken&gt; &lt;sp:AlgorithmSuite&gt; &lt;wsp:Policy&gt; &lt;sp:Basic128Rsa15/&gt; &lt;/wsp:Policy&gt; &lt;/sp:AlgorithmSuite&gt; &lt;sp:Layout&gt; &lt;wsp:Policy&gt; &lt;sp:Strict/&gt; &lt;/wsp:Policy&gt; &lt;/sp:Layout&gt; &lt;/wsp:Policy&gt; &lt;/sp:TransportBinding&gt; &lt;/wsp:All&gt; &lt;/wsp:ExactlyOne&gt; &lt;wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/&gt; &lt;/wsp:Policy&gt; &lt;wsp:Policy wsu:Id="BN_BN_ZME_GET_CURRENT_USER_ID_SOAP12"&gt; &lt;saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/&gt; &lt;saptrnbnd:OptimizedMimeSerialization xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/&gt; &lt;wsp:ExactlyOne xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"&gt; &lt;wsp:All&gt; &lt;sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"&gt; &lt;wsp:Policy&gt; &lt;sp:TransportToken&gt; &lt;wsp:Policy&gt; &lt;sp:HttpsToken&gt; &lt;wsp:Policy&gt; &lt;sp:HttpBasicAuthentication/&gt; &lt;/wsp:Policy&gt; &lt;/sp:HttpsToken&gt; &lt;/wsp:Policy&gt; &lt;/sp:TransportToken&gt; &lt;sp:AlgorithmSuite&gt; &lt;wsp:Policy&gt; &lt;sp:Basic128Rsa15/&gt; &lt;/wsp:Policy&gt; &lt;/sp:AlgorithmSuite&gt; &lt;sp:Layout&gt; &lt;wsp:Policy&gt; &lt;sp:Strict/&gt; &lt;/wsp:Policy&gt; &lt;/sp:Layout&gt; &lt;/wsp:Policy&gt; &lt;/sp:TransportBinding&gt; &lt;/wsp:All&gt; &lt;/wsp:ExactlyOne&gt; &lt;wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/&gt; &lt;/wsp:Policy&gt; &lt;wsp:Policy wsu:Id="IF_IF_zME_GET_CURRENT_USER_ID"&gt; &lt;sapsession:Session xmlns:sapsession="http://www.sap.com/webas/630/soap/features/session/"&gt; &lt;sapsession:enableSession&gt;false&lt;/sapsession:enableSession&gt; &lt;/sapsession:Session&gt; &lt;sapcentraladmin:CentralAdministration xmlns:sapcentraladmin="http://www.sap.com/webas/700/soap/features/CentralAdministration/" wsp:Optional="true"&gt; &lt;sapcentraladmin:BusinessApplicationID&gt;000C293D85161EE392C16B764ABA0F3C&lt;/sapcentraladmin:BusinessApplicationID&gt; &lt;/sapcentraladmin:CentralAdministration&gt; &lt;/wsp:Policy&gt; &lt;wsp:Policy wsu:Id="OP_IF_OP_MeGetCurrentUserId"&gt; &lt;sapcomhnd:enableCommit xmlns:sapcomhnd="http://www.sap.com/NW05/soap/features/commit/"&gt;false&lt;/sapcomhnd:enableCommit&gt; &lt;sapblock:enableBlocking xmlns:sapblock="http://www.sap.com/NW05/soap/features/blocking/"&gt;true&lt;/sapblock:enableBlocking&gt; &lt;saptrhnw05:required xmlns:saptrhnw05="http://www.sap.com/NW05/soap/features/transaction/"&gt;no&lt;/saptrhnw05:required&gt; &lt;saprmnw05:enableWSRM xmlns:saprmnw05="http://www.sap.com/NW05/soap/features/wsrm/"&gt;false&lt;/saprmnw05:enableWSRM&gt; &lt;/wsp:Policy&gt; &lt;wsdl:types&gt; &lt;xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions"&gt; &lt;xsd:simpleType name="char12"&gt; &lt;xsd:restriction base="xsd:string"&gt; &lt;xsd:maxLength value="12"/&gt; &lt;/xsd:restriction&gt; &lt;/xsd:simpleType&gt; &lt;/xsd:schema&gt; &lt;xsd:schema xmlns:n0="urn:sap-com:document:sap:rfc:functions" attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"&gt; &lt;xsd:import namespace="urn:sap-com:document:sap:rfc:functions"/&gt; &lt;xsd:element name="MeGetCurrentUserId"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence/&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; &lt;xsd:element name="MeGetCurrentUserIdResponse"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="Username" type="n0:char12"/&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; &lt;/xsd:schema&gt; &lt;/wsdl:types&gt; &lt;wsdl:message name="MeGetCurrentUserId"&gt; &lt;wsdl:part name="parameters" element="tns:MeGetCurrentUserId"/&gt; &lt;/wsdl:message&gt; &lt;wsdl:message name="MeGetCurrentUserIdResponse"&gt; &lt;wsdl:part name="parameter" element="tns:MeGetCurrentUserIdResponse"/&gt; &lt;/wsdl:message&gt; &lt;wsdl:portType name="zME_GET_CURRENT_USER_ID"&gt; &lt;wsdl:documentation&gt; &lt;sapdoc:sapdoc xmlns:sapdoc="urn:sap:esi:documentation"&gt; &lt;sapdoc:docitem docURL="http://edr-aioexp.edraky.local:8010/sap/bc/esdt/docu/sd_text?sap-client=200&amp;sd_name=ZME_GET_CURRENT_USER_ID"/&gt; &lt;/sapdoc:sapdoc&gt; &lt;/wsdl:documentation&gt; &lt;wsp:Policy&gt; &lt;wsp:PolicyReference URI="#IF_IF_zME_GET_CURRENT_USER_ID"/&gt; &lt;/wsp:Policy&gt; &lt;wsdl:operation name="MeGetCurrentUserId"&gt; &lt;wsp:Policy&gt; &lt;wsp:PolicyReference URI="#OP_IF_OP_MeGetCurrentUserId"/&gt; &lt;/wsp:Policy&gt; &lt;wsdl:input message="tns:MeGetCurrentUserId"/&gt; &lt;wsdl:output message="tns:MeGetCurrentUserIdResponse"/&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:portType&gt; &lt;wsdl:binding name="ZME_GET_CURRENT_USER_ID" type="tns:zME_GET_CURRENT_USER_ID"&gt; &lt;wsp:Policy&gt; &lt;wsp:PolicyReference URI="#BN_BN_ZME_GET_CURRENT_USER_ID"/&gt; &lt;/wsp:Policy&gt; &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt; &lt;wsdl:operation name="MeGetCurrentUserId"&gt; &lt;soap:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:zME_GET_CURRENT_USER_ID:MeGetCurrentUserIdRequest" style="document"/&gt; &lt;wsdl:input&gt; &lt;soap:body use="literal"/&gt; &lt;/wsdl:input&gt; &lt;wsdl:output&gt; &lt;soap:body use="literal"/&gt; &lt;/wsdl:output&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:binding&gt; &lt;wsdl:binding name="ZME_GET_CURRENT_USER_ID_SOAP12" type="tns:zME_GET_CURRENT_USER_ID"&gt; &lt;wsp:Policy&gt; &lt;wsp:PolicyReference URI="#BN_BN_ZME_GET_CURRENT_USER_ID_SOAP12"/&gt; &lt;/wsp:Policy&gt; &lt;wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt; &lt;wsdl:operation name="MeGetCurrentUserId"&gt; &lt;wsoap12:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:zME_GET_CURRENT_USER_ID:MeGetCurrentUserIdRequest" style="document"/&gt; &lt;wsdl:input&gt; &lt;wsoap12:body use="literal"/&gt; &lt;/wsdl:input&gt; &lt;wsdl:output&gt; &lt;wsoap12:body use="literal"/&gt; &lt;/wsdl:output&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:binding&gt; &lt;wsdl:service name="ZME_GET_CURRENT_USER_ID"&gt; &lt;wsdl:port name="ZME_GET_CURRENT_USER_ID" binding="tns:ZME_GET_CURRENT_USER_ID"&gt; &lt;soap:address location="http://edr-aioexp.edraky.local:8010/sap/bc/srt/rfc/sap/zme_get_current_user_id/200/zme_get_current_user_id/zme_get_current_user_id"/&gt; &lt;/wsdl:port&gt; &lt;wsdl:port name="ZME_GET_CURRENT_USER_ID_SOAP12" binding="tns:ZME_GET_CURRENT_USER_ID_SOAP12"&gt; &lt;wsoap12:address location="http://edr-aioexp.edraky.local:8010/sap/bc/srt/rfc/sap/zme_get_current_user_id/200/zme_get_current_user_id/zme_get_current_user_id"/&gt; &lt;/wsdl:port&gt; &lt;/wsdl:service&gt; &lt;/wsdl:definitions&gt; </code></pre> <p>knowing that we mapped the IP <code>edr-aioexp.edraky.local</code> to real ip that i am using in my URL</p> <p>can anyone help me please ?</p> <p><strong>EDIT</strong></p> <p>I am not getting this response from ANDROID,</p> <p>this web service exists on SAP system . when tested on the SAP system, this response appears, but on android i receive no response.</p> <p>REQUEST</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;SOAP-ENV:Header&gt; &lt;sapsess:Session xmlns:sapsess="http://www.sap.com/webas/630/soap/features/session/"&gt; &lt;enableSession&gt;true&lt;/enableSession&gt; &lt;/sapsess:Session&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:MeGetCurrentUserId xmlns:ns1='urn:sap-com:document:sap:soap:functions:mc-style'&gt; &lt;/ns1:MeGetCurrentUserId&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>RESPONSE</p> <pre><code>&lt;soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;soap-env:Header/&gt; &lt;soap-env:Body&gt; &lt;n0:MeGetCurrentUserIdResponse xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style"&gt; &lt;Username&gt;EAB_SAMIR&lt;/Username&gt; &lt;/n0:MeGetCurrentUserIdResponse&gt; &lt;/soap-env:Body&gt; &lt;/soap-env:Envelope&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload