开发者社区> 问答> 正文

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

黄黄黄abc 2018-01-14 23:00:05 1821

在阿里云上利用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"
网络架构 Python
分享到
取消 提交回答
全部回答(3)
添加回答

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题