blog_soap.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:consuming_services_python_demos 作者: mikeckennedy 项目源码 文件源码
def get_post_response(dom, request):
    id_text = dom.find('Body/GetPost/id').text
    post = MemoryDb.get_post(id_text, get_ip(request))
    if not post:
        raise exception_response(404)

    resp_xml = """<?xml version="1.0" encoding="utf-8"?>
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
          <soap:Body>
            <GetPostResponse xmlns="http://tempuri.org/">
              <GetPostResult>
                <Id>{}</Id>
                <Title>{}</Title>
                <Published>{}</Published>
                <Content>{}</Content>
                <ViewCount>{}</ViewCount>
              </GetPostResult>
            </GetPostResponse>
          </soap:Body>
        </soap:Envelope>""".format(post.id, post.title, post.published, post.content, post.view_count)

    return Response(body=resp_xml, content_type='text/xml')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号