如何使用Python解析原始HTTP请求(从其内容中获取Soap XML)?

时间:2016-03-16 07:08:52

标签: python http post soap

我的原始http POST请求里面有Soap消息:

                POST / HTTP/1.1
                Host: localhost
                Content-Type: application/soap+xml; charset=utf-8
                Content-Length: 431

                <?xml version="1.0" encoding="utf-8"?>
                <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
                    <soap12:Body>
                    </soap12:Body>
                </soap12:Envelope>

我想使用已经实现的Python库从这个原始数据中获取XML内容(SOAP消息)。并且也很高兴获得HTTP请求其他内容(Http版本,主机,内容类型......)我试图搜索它,但没有成功。

我知道我能用简单的方法在字符串中找到"<?xml version=" 它将指示XML消息的开头,并且在读取到原始请求结束后将获得完整的肥皂消息。但这不是一个非常优雅的解决方案。

有关可用库或工具的任何想法吗?

0 个答案:

没有答案