我的提问 我要提问

匿名发表 2018-01-14 23:00:05

阿里云上 webservice接口利用ip无法访问,只能通过localhost访问

云栖社区 编程语言 网络与数据通信 linux python 前端与交互设计 WebService

在阿里云上利用python 的soaplib包搭建webservice接口,在其他本地机子能通过ip访问,在部署到阿里云上时只能通过http://localhost:7789/?wsdl才能访问

-*- coding: utf-8 -*-

import soaplib
from soaplib.core.service import rpc, DefinitionBase
from soaplib.core.model.primitive import String, Integer, Boolean
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array
from soaplib.core.service import soap
from soaplib.core.model.clazz import ClassModel

from soaplib.core.util.wsgi_wrapper import run_twisted

import task1_learn
import task1_sham

class HelloWorldService(DefinitionBase):
@soap(String, _returns=Array(String))
def get_privacy(self, columns):
pri_list = task1_learn.web_post1(columns)

    return pri_list

if name == '__main__':
try:
from wsgiref.simple_server import make_server
soap_application = soaplib.core.Application([HelloWorldService], 'tns','webservice')
wsgi_application = wsgi.Application(soap_application)
server = make_server('localhost',7789, wsgi_application)
server.serve_forever()
except ImportError:
print "Error: example server code requires Python >= 2.5"

回答(3)

黄黄黄abc 0

webservice接口搭建参照如下链接:https://yq.aliyun.com/ziliao/122608?accounttraceid=6c3db9d5-b9c2-4a62-a10e-2caf867b4364
检查过7789端口发现已开,目前也毫无头绪

nothingfinal 0

使用tcp调试助手测试一下端口是否打开

pwdking 0

调整下阿里云对应机器的安全组策略,开放 7789 端口可对外访问

相关问题