【问题标题】:Connection Establishment between Android and SAP SOAP WebservicesAndroid 和 SAP SOAP Web 服务之间的连接建立
【发布时间】:2012-04-23 05:50:00
【问题描述】:

我想从 android 应用程序连接 SAP SOAP Web 服务,我正在使用以下代码,但出现异常。当我调试代码时,调用方法 id 未执行。我正在使用 URL 中附加的用户名和密码。

package com.veee.pack;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import java.io.IOException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.os.Bundle;

public class WeservicesExampleActivity extends Activity {
       @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
             final String METHOD_NAME = "Z_CUSTOMER_LOOKUP1";
         final String SOAP_ACTION = "http://********************:8000/sap/bc/srt/rfc/sap/z_customer_lookup1/800/z_customer_lookup1/z_customer_lookup1_bind/Z_CUSTOMER_LOOKUP1";
         final String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
         final String URL = "http://******************:8000/sap/bc/srt/wsdl/srvc_14DAE9C8D79F1EE196F1FC6C6518A345/wsdl11/allinone/ws_policy/document?sap-client=800&sap-user=***************&sap-password=************";

//here i made the request

            SoapObject request =new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("Input", "1460");


        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.dotNet=true;
        envelope.setOutputSoapObject(request);

        AndroidHttpTransport httpTransport=new AndroidHttpTransport(URL);
      httpTransport.debug = true;
      try {
  //here call the services method.
            httpTransport.call(SOAP_ACTION, envelope);

//calling the services 

        SoapPrimitive result = (SoapPrimitive) envelope.getResponse();


        System.out.println("Result" + result.toString());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
       }

       }
 I got the following  Exception

04-23 10:50:04.744: WARN/System.err(442): 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@40546f50)

请帮助我克服这个异常,我尝试了一些使用 i ksop2 的示例得到了成功输出。

【问题讨论】:

标签: android web-services soap sap android-ksoap2


【解决方案1】:

嗨,Venkatasubbaiah Atluru,

您在 URL 中传递参数类似于 http://abc.com/xyz/api/sap-client=800&sap-user=******&sap -password=*****"

但是在请求中传递参数, 比如 request.addProperty("sap-client", "800"); request.addProperty("sap-user", "*"); request.addProperty("sap-password", "*");

你的问题会解决的......

如果您有任何疑问,请告诉我......

享受编程……

【讨论】:

    猜你喜欢
    • 2012-04-24
    • 1970-01-01
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-22
    • 2021-02-06
    • 1970-01-01
    相关资源
    最近更新 更多