【发布时间】:2012-12-22 13:32:44
【问题描述】:
我正在开发一个用于连接到 Tridion 2011 SP1 核心服务的 Android 应用程序。 到目前为止,我已经使用 wsclient 从核心服务 wsdl 创建了 Android WS Stub。
导入了那些允许访问所有核心服务方法的存根。
我现在可以通过 Android 应用程序向 Tridion 进行身份验证,但是一旦我尝试执行最基本的 Web 服务调用,例如 getApiVersion(),我就会收到错误消息:
ReflectionHelper*java.lang.NoSuchFieldException: GetApiVersionResult.
我想知道有没有其他人设法创建一个与核心服务通信的 java android 应用程序?
有趣的是,如果我将代码作为 java 应用程序运行,使用 wsimport stubs 一切都很好。
任何帮助表示赞赏。这里有一个代码 sn-p 供参考:
要连接到 Tridion:
class TridionConnect extends AsyncTask<String, Integer, String> {
// Called to initiate the background activity
@Override
protected String doInBackground(String... statuses) {
try {
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username", "password".toCharArray());
}
});
url = new URL("http://tridion-server/webservices/CoreService2011.svc?wsdl");
System.out.println(String.format("Get Service"));
service = new CoreService2011();
System.out.println(String.format("Get Client"));
client = service.getBasicHttp();
return "Authenticated To Tridion";
} catch (Exception e) {
Log.e("Authentication failure", e.toString());
e.printStackTrace();
return "Failed to authenticate";
}
}
// Called when there's a status to be updated
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
// Not used in this case
}
// Called once the background activity has completed
@Override
protected void onPostExecute(String result) { //
Toast.makeText(FullscreenActivity.this, result, Toast.LENGTH_LONG).show();
area.setText("Authenticated to Tridion OK");
}
}
获取 ApiVersion
client.getApiVersion();
UserData currentUser = client.getCurrentUser();
System.out.println(String.format("'%s' %s", currentUser.getTitle(), currentUser.getId()));
【问题讨论】:
-
嗨艾伦,一般来说最好将整个异常传递给
Log.e,而不仅仅是toString:Log.e("TridionConnect", "Authentication Failure", e); -
我刚刚看到您已经说过代码在常规程序中运行良好。在那种情况下,它可能是真正的 JVM/JRE 和 Dalvik 之间的差异。但如果不重现您的问题,我无法确定。
-
我现在得出的结论是,如上所述,这是不可能的。我现在正在研究另一种解决方案。
-
您是否也发现了为什么这是不可能的。如果将来有人想尝试相同的方法,那可能会有所帮助,因为……事情会发生变化。顺便说一句:我之前完全忘了说,但我从 Android 客户端连接到 Tridion 内容交付 (OData) 服务没有问题。它为在本机应用程序中使用 Web 内容提供了一个很好的用例。
-
问得好,您是否有兴趣提交Area 51 Tridion specific proposal。如果有时间,请使用同一个 SO 帐户注册。
标签: android tridion tridion-2011