Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:34:48+00:00 2026-06-02T17:34:48+00:00

I have to connect a SAP web service. Here is my code but it

  • 0

I have to connect a SAP web service. Here is my code but it warns:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG @1:7 in java.io.InputStreamReader@40e3fe98)

Here is my full code to connect with username and password.

final static String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
final static String METHOD_NAME = "ZmblHucremalzemelistesi";
final static String SOAP_ACTION = "";
final static String URL = "http://xxx.xxx.xxx.xxx:1080/sap/bc/srt/wsdl/bndg_4F969242EA785040E10080008D0B0B03/wsdl11/allinone/ws_policy/document?sap-client=010";


private void testWS() {
    // TODO Auto-generated method stub


    SoapObject reSoapObject = new SoapObject(NAMESPACE, METHOD_NAME);
    SoapSerializationEnvelope soaSerializationEnvelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);

    reSoapObject.addProperty("ILgort", "H12");

    soaSerializationEnvelope.setOutputSoapObject(reSoapObject);
    soaSerializationEnvelope.headerOut = new Element[1]; 
    soaSerializationEnvelope.headerOut[0] = buildAuthHeader(); 

    HttpTransportSE httpTransportSE = new HttpTransportSE(URL);

    try {

        httpTransportSE.call(SOAP_ACTION, soaSerializationEnvelope);

        Object response = soaSerializationEnvelope.getResponse();

        tv.setText(response.toString());

    } catch (IOException e) {
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    }


}

private Element buildAuthHeader() { 

    Element h = new Element().createElement(NAMESPACE, "AuthHeader"); 
    Element username = new Element().createElement(NAMESPACE, "user"); 
    username.addChild(Node.TEXT, "testuser"); 
    h.addChild(Node.ELEMENT, username); 
    Element pass = new Element().createElement(NAMESPACE, "pass"); 
    pass.addChild(Node.TEXT, "testpwd"); 
    h.addChild(Node.ELEMENT, pass); 

    return h; 
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:34:49+00:00Added an answer on June 2, 2026 at 5:34 pm

    Try this:

    final static String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
        final static String METHOD_NAME = "ZmblHucremalzemelistesi";
        final static String SOAP_ACTION = "";
        final static String URL = "http://xxx.xxx.xxx.xxx:1080/sap/bc/srt/wsdl/bndg_4F969242EA785040E10080008D0B0B03/wsdl11/allinone/ws_policy/document?sap-client=010";
    
        private static final String USERNAME = "YOUR_USERNAME";
        private static final String PASSWORD = "YOUR_PASSWORD";
    
        private void testWS() {
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            request.addProperty("ILgort", "H12");
    
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);
    
            AuthTransportSE androidHttpTransport = new AuthTransportSE(URL, USERNAME, PASSWORD);
            androidHttpTransport.debug = true;
    
            try {
                androidHttpTransport.call(SOAP_ACTION, envelope);
                SoapObject response = (SoapObject) envelope.getResponse();
                // if it did not work, try this:
                // SoapObject response = (SoapObject) envelope.bodyIn;
    
                tv.setText(response.toString());
    
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    

    And AuthTransportSE class is:

    import java.io.IOException;
    
    import org.ksoap2.transport.HttpTransportSE;
    import org.ksoap2.transport.ServiceConnection;
    import org.ksoap2.transport.ServiceConnectionSE;
    
    public class AuthTransportSE extends HttpTransportSE{
        private String username;
        private String password;
    
        public AuthTransportSE(String url, String username, String password) {
            super(url);
            this.username = username;
            this.password = password;       
        }
    
        protected ServiceConnection getServiceConnection() throws IOException {
            ServiceConnection midpConnection = new ServiceConnectionSE(url);
            addBasicAuthentication(midpConnection);
            return midpConnection;
        }
    
        protected void addBasicAuthentication(ServiceConnection midpConnection) throws IOException {
            if (username != null && password != null) {
                StringBuffer buf = new StringBuffer(username);
                buf.append(':').append(password);
                byte[] raw = buf.toString().getBytes();
                buf.setLength(0);
                buf.append("Basic ");
                org.kobjects.base64.Base64.encode(raw, 0, raw.length, buf);
                midpConnection.setRequestProperty("Authorization", buf.toString());
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to connect to a third party web service that provides no wsdl
I have a .NET web service I have to connect to, and unfortunately, I
I have a Grails web service running and I have to connect to it
I've the following class. It has the code to connect to SAP in its
I have to connect to server(servlet on tomcat) always running and process the http
I have facebook connect setup for an app but I am not sure how
Hiall I have to connect to a 3rd party soap service, so i don't
Here we have the Connect(); function: public static void Connect(string username, string password, string
I have to connect in .NET to a service which can be accesed with
I have to connect to a poorly implemented server that only understands Content-Type (capital-T)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.