Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-can';t从WCF数据服务检索$metadata_Android_Wcf Data Services_Restlet - Fatal编程技术网

Android-can';t从WCF数据服务检索$metadata

Android-can';t从WCF数据服务检索$metadata,android,wcf-data-services,restlet,Android,Wcf Data Services,Restlet,我正在使用Restlet Framework 2.1.2,在我的Android应用程序中,我尝试从WCF数据服务检索数据并接收LogCat错误消息: Starting the HTTP client Get the metadata for http://Server.domain.local:82/northdata.svc/ at http:// Server.domain.local:82/northdata.svc/$metadata GC_CONCURRENT freed 1154K,

我正在使用Restlet Framework 2.1.2,在我的Android应用程序中,我尝试从WCF数据服务检索数据并接收LogCat错误消息:

Starting the HTTP client Get the metadata for http://Server.domain.local:82/northdata.svc/ at http:// Server.domain.local:82/northdata.svc/$metadata GC_CONCURRENT freed 1154K, 56% free 2966K/6727K, external 1625K/2137K, paused 4ms+6ms Can't get the metadata for http://Server.domain.local:82/northdata.svc/ java.io.IOException: Unable to create customized SAX source ... 我将替换HTTP客户端:

Engine.getInstance().getRegisteredClients().clear();
Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null));
并使用以下模式:

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy); 
我使用AsyncTask,我的代码:

protected String doInBackground(Object... params) {
        {

        try {

            NorthdataService service = new NorthdataService();
            Query<Customers> queryCustomers = service
                    .createCustomersQuery("/Customers");
            }

        } catch (Exception e) {
            // return e;
        }
        return customers;
    }
受保护字符串doInBackground(对象…参数){
{
试一试{
NorthdataService服务=新的NorthdataService();
查询queryCustomers=service
.createCustomerQuery(“/Customers”);
}
}捕获(例外e){
//返回e;
}
返回客户;
}
可能是什么?如何从$metadata检查\获取数据

另外,我在Android内部浏览器中打开了我的数据服务链接,它打开了。

我解决了我的问题:
1.我创建了新的Android项目
2.将文件从Restlet Framework复制到libs文件夹(在我的项目中):

org.restlet.jar
org.restlet.ext.atom.jar
org.restlet.ext.html.jar
org.restlet.ext.httpclient.jar
org.restlet.ext.net.jar
org.restlet.ext.odata.jar
org.restlet.ext.ssl.jar
org.restlet.ext.xml.jar

3.创建新包“northwindmodel”
4.为WCF数据服务导入自动生成的java类 5.添加权限:

使用权限android:name=“android.permission.INTERNET”
使用权限android:name=“android.permission.WRITE\u EXTERNAL\u STORAGE”
使用权限android:name=“android.permission.READ\u EXTERNAL\u STORAGE”
使用权限android:name=“android.permission.ACCESS\u NETWORK\u STATE”

6.在onCreate中输入代码:

 NorthdataService service = new NorthdataService();
    Query<Customers> query = service.createCustomersQuery("/Customers"); 

    Log.d(log_tag, query.toString());

    for (Customers cust : query){
        Log.d(log_tag, "Customer Name - " + cust.getContactName());
    }
NorthdataService服务=新的NorthdataService();
Query Query=service.createCustomerQuery(“/Customers”);
Log.d(Log_标记,query.toString());
对于(客户:查询){
Log.d(Log_标签,“客户名称-”+cust.getContactName());
}
在此之前,我做了同样的事情,但问题在重新创建项目后得到了解决

 NorthdataService service = new NorthdataService();
    Query<Customers> query = service.createCustomersQuery("/Customers"); 

    Log.d(log_tag, query.toString());

    for (Customers cust : query){
        Log.d(log_tag, "Customer Name - " + cust.getContactName());
    }