Python:如何解析肥皂要求?

发布于 2025-02-12 18:16:31 字数 1065 浏览 3 评论 0 原文

但是,我有以下肥皂要求

<env:Envelope
    xmlns:env="http://www.w3.org/2003/05/soap-envelope">
    <env:Header/>
    <env:Body>
        <ns2:authenticateUserResponse
            xmlns:ns2="http://www.orionhealth.com/com.orchestral.portal.webservice.api_7_2.user/">
            <ns2:return>
                <ns2:authenticated>true</ns2:authenticated>
                <ns2:authoritativeUserId>fusion.support</ns2:authoritativeUserId>
            </ns2:return>
        </ns2:authenticateUserResponse>
    </env:Body>
</env:Envelope>

对我的生命,我看不到它

root = ET.fromstring(string_above_here)
    prefix_map = {
        "env": "http://www.w3.org/2003/05/soap-envelope",
        "ns2": "http://www.orionhealth.com/com.orchestral.portal.webservice.api_7_2.user/",
        }
    return jsonify(root.findall(".//env:Envelope/env:Body/ns2:authenticateUserResponse/ns2:return/ns2:authenticated",prefix_map))

如何返回 agen验证的值?

谢谢

I have the following SOAP request

<env:Envelope
    xmlns:env="http://www.w3.org/2003/05/soap-envelope">
    <env:Header/>
    <env:Body>
        <ns2:authenticateUserResponse
            xmlns:ns2="http://www.orionhealth.com/com.orchestral.portal.webservice.api_7_2.user/">
            <ns2:return>
                <ns2:authenticated>true</ns2:authenticated>
                <ns2:authoritativeUserId>fusion.support</ns2:authoritativeUserId>
            </ns2:return>
        </ns2:authenticateUserResponse>
    </env:Body>
</env:Envelope>

However for the life of me, I can't see to parse it

root = ET.fromstring(string_above_here)
    prefix_map = {
        "env": "http://www.w3.org/2003/05/soap-envelope",
        "ns2": "http://www.orionhealth.com/com.orchestral.portal.webservice.api_7_2.user/",
        }
    return jsonify(root.findall(".//env:Envelope/env:Body/ns2:authenticateUserResponse/ns2:return/ns2:authenticated",prefix_map))

How would I return the value of authenticated?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥醉 2025-02-19 18:16:31

这似乎已经做到了

root = ET.fromstring(rhapsody.authenticate_user(u,p))
prefix_map = {
    "env": "http://www.w3.org/2003/05/soap-envelope",
    "ns2": "http://www.orionhealth.com/com.orchestral.portal.webservice.api_7_2.user/",
    }

if root.find(".//env:Text",prefix_map) is None:
    return root.find(".//ns2:authenticated",prefix_map).text
else:
    return root.find(".//env:Text",prefix_map).text

This seem to have done the trick

root = ET.fromstring(rhapsody.authenticate_user(u,p))
prefix_map = {
    "env": "http://www.w3.org/2003/05/soap-envelope",
    "ns2": "http://www.orionhealth.com/com.orchestral.portal.webservice.api_7_2.user/",
    }

if root.find(".//env:Text",prefix_map) is None:
    return root.find(".//ns2:authenticated",prefix_map).text
else:
    return root.find(".//env:Text",prefix_map).text
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文