【问题标题】:Accessing SharePoint Web Service from Android从 Android 访问 SharePoint Web 服务
【发布时间】:2014-03-11 07:02:46
【问题描述】:

我正在尝试从我的 Android 应用程序访问共享点网络服务。

我使用 KSoap 访问 Web 服务,但每次它都在下面一行抛出错误。

“androidHttpTransport.call(SOAP_ACTION,信封);”

所以我尝试使用以下链接,但它返回“故障字符串”。

http://www.robertkuzma.com/2011/07/manipulating-sharepoint-list-items-with-android-java-and-ntlm-authentication/

请帮助我是应用端还是服务器端的问题。

提前致谢。

【问题讨论】:

  • 你有使用Ksoap webservice获取数据吗?

标签: android web-services sharepoint ksoap2


【解决方案1】:

试试这个代码:

public static String call(Context c, SoapObject request, String NAMESPACE,
            String METHOD_NAME, String SOAP_ACTION) throws IOException,
            XmlPullParserException {
        Log.i(WebCalls, "URL " + CommonVariable.URL);
        Log.i(WebCalls, "Method Name " + METHOD_NAME);
        Log.i(WebCalls, "request Name " + request);
        String SoapResult = null;
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

        envelope.setOutputSoapObject(request);

        envelope.dotNet = true;

        HttpTransportSE androidHttpTransport = new HttpTransportSE(
                CommonVariable.URL);

        // this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION, envelope);

        // Get the SoapResult from the envelope body.
        if (envelope.bodyIn instanceof SoapFault) {
            SoapResult = ((SoapFault) envelope.bodyIn).faultstring;
        } else {
            SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
            SoapResult = resultsRequestSOAP.getProperty(0).toString();
        }

        Log.i(WebCalls, "Response " + SoapResult);

        return SoapResult;
    }

【讨论】:

  • 嗨 dipali 感谢您的回复,我使用相同的代码,但我在这里遇到异常:“androidHttpTransport.call(SOAP_ACTION,envelope);”异常是:“org.xmlpull.v1.XmlPullParserException:意外类型(java.io.InputStreamReader@40d16600 中的位置:END_DOCUMENT null@1:1)”
  • @hcp 你传递了正确的命名空间、url、soap 动作吗?
  • 私有静态最终字符串 NAMESPACE = "tempuri.org" ;私有静态最终字符串 URL = "MyWCFApp/Service.svc";
  • 是的,我只通过了正确的。我的 NAMESPACE 是:“schemas.microsoft.com/sharepoint/soap”,SOAP ACTION 将类似于:NAMESPACE/METHODNAME
  • 好的,谢谢,我会尽快更改并更新状态。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-18
  • 2011-12-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多