node.js - 来自 SOAPUI 的 SOAP 请求的 SOAP 信封丢失/无效

标签 node.js xml soap soapui

我正在 NodeJS 上使用 soap 包生成一个 SOAP 信封,生成的信封如下:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:i0="http://tempuri.org/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:tns="http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:q1="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:q2="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:q3="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:q4="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:q5="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:q6="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:q7="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:q8="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
    <soap:Header>
        <Action>http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue</Action>
        <MessageID>urn:uuid:568d575f-6760-4fd7-837d-04c610abcff4</MessageID>
        <To>https://kpsv2test.saglik.gov.tr/STS/STSService.svc</To>
        <ReplyTo>
            <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
        </ReplyTo>
        <SorgulayanKimlikNo>10774881040</SorgulayanKimlikNo>
        <wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsu:Timestamp wsu:Id="Timestamp-2021-02-26T13:15:20Z">
                <wsu:Created>2021-02-26T13:15:20Z</wsu:Created>
                <wsu:Expires>2021-02-26T13:25:20Z</wsu:Expires>
            </wsu:Timestamp>
            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-2021-02-26T13:15:20Z">
                <wsse:Username>test_user2</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Twm=x5Gb</wsse:Password>
                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">r9V/OHo2DbI7hLmw+a2fpt12qZI=</wsse:Nonce>
            </wsse:UsernameToken>
        </wsse:Security>
    </soap:Header>
    <soap:Body>
        <q7:RequestSecurityToken xmlns:q7="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
            <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
                <EndpointReference>
                    <Address>https://kpsv2test.saglik.gov.tr/Router/RoutingService.svc</Address>
                </EndpointReference>
            </wsp:AppliesTo>
            <trust:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer</trust:KeyType>
            <trust:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</trust:RequestType>
        </q7:RequestSecurityToken>
    </soap:Body>
</soap:Envelope>

我将此请求复制并粘贴到 SOAPUI,但 SOAPUI 给出以下错误。

ERROR:org.apache.xmlbeans.XmlException: Missing/Invalid SOAP Envelope, expecting [{http://www.w3.org/2003/05/soap-envelope}Envelope]
   org.apache.xmlbeans.XmlException: Missing/Invalid SOAP Envelope, expecting [{http://www.w3.org/2003/05/soap-envelope}Envelope]
    at com.eviware.soapui.impl.wsdl.support.soap.SoapUtils.getHeaderElement(SoapUtils.java:147)
    at com.eviware.soapui.impl.wsdl.support.wsa.WsaUtils.getHeader(WsaUtils.java:133)
    at com.eviware.soapui.impl.wsdl.support.wsa.WsaUtils.createNewWSAddressingRequest(WsaUtils.java:288)
    at com.eviware.soapui.impl.wsdl.support.wsa.WsaUtils.addWSAddressingRequest(WsaUtils.java:281)
    at com.eviware.soapui.impl.wsdl.submit.filters.WsaRequestFilter.filterAbstractHttpRequest(WsaRequestFilter.java:54)
    at com.eviware.soapui.impl.wsdl.submit.filters.AbstractRequestFilter.filterRequest(AbstractRequestFilter.java:33)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.filterRequest(HttpClientRequestTransport.java:322)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:184)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:119)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:835)

我不明白问题出在哪里。你能帮我吗?

最佳答案

这是 SOAP 版本不匹配,服务器期望版本 1.2,但客户端正在发送 1.1 (I am confused about SOAP namespaces)。 您需要从服务器实现(此处:基于构造请求)wsdl 并确保使用版本 1.2

关于node.js - 来自 SOAPUI 的 SOAP 请求的 SOAP 信封丢失/无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66387242/

相关文章:

mysql - 在 Nodejs 路由中执行多个查询

android - 如何更改SwitchCompat的字体系列?

xml - 用于获取默认命名空间的 XPath 表达式

java - 自动生成的 Web 服务调用因解码错误而失败?

.net - 如何从 AfterReceiveReply 中的 WCF 消息中提取错误代码

ssl - 将 DER 转换为 PEM,结果文件中没有关键部分

javascript - 无法使用 Node.js、Express 和 EJS 显示图像

javascript - Google API - 未找到文件 ID - 但返回的数据对应于我输入的folderId

node.js - Heroku、Node、Express、SSL 的 ERR_SSL_PROTOCOL_ERROR

c# - 带有命名空间的 XML 数据绑定(bind)