0

I have a problem trying to connect a Web Service made in SAP with Android. I know That are already a lot of questions with this Thread, but I tried a lot of solutions and nothing worked. I'm having this Exception in the androidHttpTransport.call:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@1:7 in java.io.InputStreamReade

And this is the code:

@SuppressLint("NewApi")
public class MainActivity extends Activity {

private String METHOD_NAME = "ZWS_NOMBRE_SOC";
// our webservice method name
private String NAMESPACE = "urn:sap-com:document:sap:rfc:function";
// Here package name in webservice with reverse order.
private String SOAP_ACTION = NAMESPACE + METHOD_NAME;
// NAMESPACE + method name
private static final String URL = "http://10.0.1.20:8000/sap/bc/srt/rfc/sap/zws_nombre_soci/100/zws_nombre_soci/zws_nombre_soci"; //"http://10.0.1.20:8000/sap/bc/srt/wsdl/srvc_E41F136236A01ED1A2AC083464D902B8/wsdl11/allinone/standard/document?sap-client=100";
private HttpTransportSE androidHttpTransport;

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
            .permitAll().build();
    StrictMode.setThreadPolicy(policy);

    try {
        TextView lb = (TextView) findViewById(R.id.lb1);
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("IV_BUKRS", "0001");
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true;


        envelope.setOutputSoapObject(request);

        androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true; 



        androidHttpTransport.call(SOAP_ACTION, envelope);
        Object result = envelope.getResponse();
        ;
        lb.setText(result.toString());

    } catch (Exception e) {

        e.printStackTrace();
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;

    }

}
4

0 回答 0