1

When I run the program below I got the following exception in logcat:

eclipse:02-17 18:33:35.254: WARN/System.err(608): 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:sap:soap:functions:mc-style'>@1:686 in java.io.InputStreamReader@40554888)

Where can I append User Name and Password?

package com.venkat.pack;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class SOAPClientActivity extends Activity {
    private static final String SOAP_ACTION = "Z_CUSTOMER_LOOKUP";
    private static final String METHOD_NAME = "Z_CUSTOMER_LOOKUP";
    private static final String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
    private static final String URL = "http://*********:8000/sap/bc/srt/wsdl/srvc_14DAE9C8D79F1EE193CF0AB8FEE64345/wsdl11/allinone/ws_policy/document?sap-client=*****"; //this is my wsdl url.

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button btTest = (Button) this.findViewById(R.id.btTest);
        btTest.setOnClickListener(btTestListener);
        
        
    //whenever click the button 
    }
    
    public Button.OnClickListener btTestListener = new Button.OnClickListener() {
        public void onClick(View v) {
            try {
                
                
                // Create SOAP request
                SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.setOutputSoapObject(request);
                HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                androidHttpTransport.call(SOAP_ACTION, envelope);

                // Get response from envelope
                Object result = envelope.getResponse();

                // Display result
                Toast.makeText(SOAPClientActivity.this, result.toString(),
                        50000).show();

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
}

2 Answers 2

0

SAP allows the parameters sap-user and sap-password to be appended as URL parameters (as it does with sap-client). Try that, it should solve the problem.

2
  • I added the Username and password as Url parameter the fallowing url private static final String URL ="http://*********:****/sap/bc/srt/wsdl/srvc_14DAE9C8D79F1EE193CF0AB8FEE64345/wsdl11/allinone/ws_policy/document?sap-client=*****&UserName=*******&password=******"; I got the fallowing Excxeption:02-24 12:37:44.159: WARN/System.err(530): java.net.SocketTimeoutException 02-24 12:37:44.159: WARN/System.err(530): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:130)
    – Venkat
    Feb 24, 2012 at 7:07
  • You should change the parameter "UserName" to "sap-user" and "password" to "sap-password". Feb 24, 2012 at 13:01
0

In your case you need call SAP webservice with basic authentication. Use HttpTransportBasicAuth insted of HttpTransportSE see the example below showing how to call HttpTransportBasicAuth

  HttpTransportBasicAuth aht = new  HttpTransportBasicAuth(url, username, password); 

Let us know if it works or need more info.

1
  • When i i got the fallowing exception:02-08 17:58:20.084: E/AndroidRuntime(438): java.lang.NoClassDefFoundError: javax.microedition.io.Connector how can i resolveit?
    – Venkat
    Feb 21, 2012 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.