我正在尝试配置MF容器以使用Cloudant。并通过数据代理从移动应用程序查询模糊。
我按照说明在容器上配置数据代理: http://www-01.ibm.com/support/knowledgecenter/?lang=en#!/SSHS8R_7.1.0/com.ibm.worklight.deploy.doc/deploy/t_configure_data_proxy.html
我将文件/ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/env/server.env配置为具有以下值:
publicKeyServerUrl=HTTP_CONTAINER_PUBLIC_IP_PORT/MF_PROJECT_CONTEXT_ROOT
文件/ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/config/dataproxy.xml具有以下值:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed Materials - Property of IBM 5725-I43 (C) Copyright IBM Corp.
2015, 2015. All Rights Reserved. US Government Users Restricted Rights -
Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM Corp. -->
<server description="new server">
<!-- Enable features -->
<featureManager>
<!-- Data proxy features -->
<feature>jaxrs-1.1</feature>
<feature>jndi-1.0</feature>
<feature>usr:OAuthTai-1.0</feature>
<!-- -->
</featureManager>
<!-- OAuth TAI For Data Proxy -->
<!--OAuth TAI For Data Proxy. -->
<usr_OAuthTAI cacheSize="1000" id="myOAuthTAI">
<securityConstraint httpMethods="All" securedURLs="datastore" scope="cloudant"/>
</usr_OAuthTAI>
<!-- -->
<!-- -->
<webApplication contextRoot="datastore" id="imf-data-proxy" location="imf-data-proxy.war" name="imf-data-proxy">
<application-bnd>
<security-role name="TAIUserRole">
<special-subject type="ALL_AUTHENTICATED_USERS" />
</security-role>
</application-bnd>
<classloader delegation="parentLast">
<commonLibrary>
<fileset dir="${wlp.install.dir}/lib" includes="com.ibm.ws.crypto.passwordutil*.jar"/>
</commonLibrary>
</classloader>
</webApplication>
<!-- -->
<!-- Declare the JNDI properties for the MobileFirst Data Proxy.
Note: These jndi properties are not required if a bluemix app is bound to the container when startserver.sh or startservegroup.sh is executed.
Also, uncomment the entry publicKeyServerUrl in server.env and fill in the correct URL.
<jndiEntry jndiName="datastore/CloudantProxyDbAccount" value='"hostname"'/>
<jndiEntry jndiName="datastore/CloudantProtocol" value='"http"'/>
<jndiEntry jndiName="datastore/CloudantPort" value='"80"'/>
<jndiEntry jndiName="datastore/CloudantProxyDbAccountUser" value='"cloudantuser"'/>
<jndiEntry jndiName="datastore/CloudantProxyDbAccountPassword" value='"cloudantpassword"'/>
-->
</server>
然后我运行了脚本prepareserver并启动服务器。
当我打开http://CONTAINER_PUBLIC_IP:9080/datastore
时,我得到以下回复,这似乎很好:
{&#34; imfdata&#34;:&#34; OK&#34;&#34;版本&#34;:&#34; 1.0&#34;}
我在这个容器上运行了bluelist示例,但我无法让它运行。它抛出以下异常:
2015-10-08 00:05:34.055 bluelist-objective-c [37850:708865] ***由于未被捕获的异常终止应用程序&#39;来自代理的致命异常&#39;,原因:&#39;无法创建远程数据库todosdb。错误:错误域= NSURLErrorDomain代码= -1001&#34;请求超时。&#34; UserInfo = {NSUnderlyingError = 0x7fcf72e6efa0 {错误域= kCFErrorDomainCFNetwork代码= -1001&#34;请求超时。&#34; UserInfo = {NSErrorFailingURLStringKey = IP_PF_CONTAINER:9080 / datastore / api / v1 / apps / default / todosdb,NSErrorFailingURLKey = IP_PF_CONTAINER:9080 / datastore / api / v1 / apps / default / todosdb,_kCFStreamErrorCodeKey = -2102,_kCFStreamErrorDomainKey = 4,NSLocalizedDescription =请求超时。}},NSErrorFailingURLStringKey = HTTP_CONTAINER_PUBLIC_IP_PORT / datastore / api / v1 / apps / default / todosdb,NSErrorFailingURLKey = http://134.168.13.219:9080/datastore/api/v1/apps/default/todosdb,_ kCFStreamErrorDomainKey = 4,_kCFStreamErrorCodeKey = -2102,NSLocalizedDescription =请求超时。}& #39;
这是从运行此代码的iPhone simultator抛出的:
[manager remoteStore:dbname completionHandler:^(CDTStore *store, NSError *error) {...
我已将Objective C代码中的cloudantProxyURL设置为以下内容:
CONTAINER_PUBLIC_IP:9080/MF_PROJECT_CONTEXT_ROOT
知道问题出在哪里?我想在没有安全的情况下进行故障排除。我可以通过IMFDataManager API和数据代理对Cloudant进行未经身份验证的调用吗?或者用户必须进行身份验证?
===============
我可以在调用[manager remoteStore]之前通过调用适配器来强制执行身份验证,并且身份验证成功。我仍然得到一个错误 当我运行以下代码连接到Cloudant上的数据库并从中查询时。 [manager remoteStore]是抛出错误的那个:
IMFDataManager * manager = [IMFDataManager initializeWithUrl:@&#34; HTTP_HOST_PORT / datastore&#34;];
// Get reference to data manager
//manager = [IMFDataManager sharedInstance];
NSString *dbname = @"orders_db";
// Create remote store
[manager remoteStore:dbname completionHandler:^(CDTStore *store, NSError *error) {
if(error){
// Handle error
NSLog(@"Error: %@ %@", error, [error userInfo]);
}else{
CDTStore *remotedatastore = store;
NSLog(@"Successfully created store");
}
}];
我收到此错误:
2015-10-09 02:14:39.029 bluelist-objective-c [2655:52223]错误:错误域= NSURLErrorDomain代码= -1012&#34;(null)&#34; UserInfo = {NSErrorFailingURLStringKey = http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db,NSUnderlyingError = 0x7fa270c27270 {Error Domain = kCFErrorDomainCFNetwork Code = -1012&#34;(null)&#34; UserInfo = {_ kCFURLErrorAuthFailedResponseKey = {url = http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db}}},NSErrorFailingURLKey = http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db} { NSErrorFailingURLKey =&#34; http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db&#34 ;; NSErrorFailingURLStringKey =&#34; http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db&#34 ;; NSUnderlyingError =&#34;错误域= kCFErrorDomainCFNetwork代码= -1012 \&#34;(null)\&#34; UserInfo = {_ kCFURLErrorAuthFailedResponseKey = {url = http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db}}&#34 ;; }
=====
另一点,当我使用SSH登录容器并在/opt/ibm/wlp/usr/servers/worklight/server.xml中显示server.xml时,我找不到添加OAuth TAI的行。根本没有。
答案 0 :(得分:0)
上述异常表示访问数据代理组件的授权不成功。
是否可以修改dataproxy.xml以提供正确的securedUrls参数。 securedURL的值应为“/ datastore / *”而不是“datastore”。更新的代码段位于:
<usr_OAuthTAI cacheSize="1000" id="myOAuthTAI">
<securityConstraint httpMethods="All" securedURLs="/datastore/*" scope="cloudant"/>
</usr_OAuthTAI>
让我知道dataproxy是否可以正常使用。