首页 / 浏览问题 / 云GIS / 问题详情
利用api发布三维缓存服务失败
18EXP 2023年10月25日
import requests
import json

host = '192.168.221.186'

def getToken(session, user, password):
    url = f"http://{host}:8090/iserver/services/security/tokens.rjson"
    data = {
        "userName": user,
        "password": password,
        "clientType": "NONE",
        "expiration": 10
    }
    headers = {"Content-Type": "application/json"}
    response = session.post(url, data=json.dumps(data), headers=headers)
    if response.status_code == 200:
        token = response.text
        # 登录成功后的操作
        print("登录成功")
        # 可以在这里添加其他操作
    else:
        print("登录失败")
        # 可以在这里处理登录失败的情况
    return token


def getWorkSpace(session, token, host):
    url1 = 'http://' + host + ':8090/iserver/manager/providers.rjson?token=' + token
    data1 = {"config":{"configFile":"/home/fanqy/data/Production_3/Data/Config_1/Combine.scp","clipRegion":'null'},
             "type":"com.supermap.services.providers.LocalRealspaceProvider",
             "name":"local3DCache-Config18"} #发送post请求
    headers = {"Content-Type": "application/json"}
    response1 = session.post(url1, data=json.dumps(data1), headers=headers)

    url2 = 'http://' + host + ':8090/iserver/manager/components.rjson?token=' + token
    data2 = {"interfaceNames": "rest",
             "name": "3D-local3DCache-Config18",
             "providers": "local3DCache-Config18",
             "type": "com.supermap.services.components.impl.RealspaceImpl",
             "config": {}}
    response2 = session.post(url2, data=json.dumps(data2), headers=headers)
    if response1.status_code == 200:
        created_services = response1.json()
        print(created_services)
        for service_info in created_services:
            print(f"Service Type: {service_info['serviceType']}")
            print(f"Service Address: {service_info['serviceAddress']}")
    else:
        print(f"Failed to create services. Status code: {response1.text}")
    if response2.status_code == 200:
        created_services = response2.json()
        print(created_services)
        for service_info in created_services:
            print(f"Service Type: {service_info['serviceType']}")
            print(f"Service Address: {service_info['serviceAddress']}")
    else:
        print(f"Failed to create services. Status code: {response2.text}")

报错信息是:Failed to create services. Status code: {
    "succeed": false,
    "error": {
        "code": 400,
        "errorMsg": "创建服务提供者的参数为空"
    }
}请问应该怎么处理?

1个回答

您好,服务提供者参数为空存在两种情况,

1.您所使用的是正式许可,但没有购买三维模块(试用许可不存在该问题,试用许可具有所有模块授权)

2.服务请求体部分参数错误,准确说是缓存路径地址错误,建议您核对数据路径地址对于iServer所在的机器是否正确。

(建议您可以使用网页版浏览器登陆这个iserver,发一个三维服务使用f12查看参数差异与您有什么不同)

希望可以帮助到您。
9,488EXP 2023年10月26日
...