微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SOAP 请求因错误而失败 验证消息的安全性时发生错误

如何解决SOAP 请求因错误而失败 验证消息的安全性时发生错误

被 SOAP 请求困住了。

我用来发出请求的代码

def get_body():
    import datetime
    today_datetime = datetime.datetime.today() - datetime.timedelta(minutes=1)
    expires_datetime = today_datetime + datetime.timedelta(minutes=5)
    body = """
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <s:Header>
            <a:Action s:mustUnderstand="1">http://edd.ca.gov/IFsetService/Ping</a:Action>
            <a:MessageID>urn:uuid:{}</a:MessageID>
            <a:ReplyTo>
                <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
            </a:ReplyTo>
            <a:To s:mustUnderstand="1">https://fsettestprod.edd.ca.gov/fsetwcfproxywebservice/fsetservice.svc</a:To>
            <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-wssecurity-secext-1.0.xsd">
                <u:Timestamp u:Id="{}">
                    <u:Created>{}</u:Created>
                    <u:Expires>{}</u:Expires>
                </u:Timestamp>
                <o:Usernametoken u:Id="{}">
                    <o:Username>xxxxxxxxx</o:Username>
                    <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-usernametoken-profile-1.0#PasswordText">xxxxxx</o:Password>
                </o:Usernametoken>
            </o:Security>
        </s:Header>
        <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <Ping xmlns="http://edd.ca.gov/"/>
        </s:Body>
    </s:Envelope>"""
    body = body.format(uuid.uuid4(),uuid.uuid4(),today_datetime.strftime("%Y-%m-%dT%H:%M:%sZ"),expires_datetime.strftime("%Y-%m-%dT%H:%M:%sZ"),uuid.uuid4())
    return body

headers = {"content-type" : "text/xml"}
res = requests.post(url,data=get_body(),headers=headers)

错误

--uuid:4bef2eb8-ccb6-4c06-8c85-526b0fcf07e2+id=545
Content-ID: <http://tempuri.org/0>
Content-transfer-encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2004/08/addressing/fault</a:Action><a:RelatesTo>urn:uuid:2f5ce100-17c7-49f8-9bfe-9d5319c28566</a:RelatesTo><a:To s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:To></s:Header><s:Body><s:Fault><faultcode xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</faultcode><faultstring xml:lang="en-US">An error occurred when verifying security for the message.</faultstring></s:Fault></s:Body></s:Envelope>
--uuid:4bef2eb8-ccb6-4c06-8c85-526b0fcf07e2+id=545--

WSDL 链接https://fsettestprod.edd.ca.gov/fsetwcfproxywebservice/fsetservice.svc?wsdl

我使用的凭据是正确的,但请求仍然失败。

在这里遗漏了一些标题吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?