Im trying to use ksoap2 with a webservice in android but I think i cannot get a respond from the webservice. Anyone knows why i get this error? "org.xmlpull.v1.XmlPullParserException: expected: START_TAG"
my code is:
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());
}
}
}
my complete error is :
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
I'm stuck in this error and I cant go any further. Please help!
EDIT: I HAVE SOLVED THIS. PLEASE READ MY ANSWER BELOW ON COMMENTS AND ANSWERS. I HOPE I'LL BE HELPFUL FOR SOMEONE IN SOMEWAY.
NAMESPACE+"/"+METHOD_NAME. If this doesn't work then tell me I will help you further.WSDLor any message related to that service.