- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我尝试从使用 PasswordText WSS 类型的 Web 服务获取信息。首先,我使用 soapUI 对其进行了测试并成功获取了数据。然后我在Java上实现了认证,写了SecurityHandler:
public final class SecurityHandler implements SOAPHandler<SOAPMessageContext> {
...
@Override
public boolean handleMessage(SOAPMessageContext messageContext) {
boolean outInd = (Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outInd) {
try {
WSSecUsernameToken builder = new WSSecUsernameToken();
builder.setPasswordType(WSConstants.PASSWORD_TEXT);
builder.setUserInfo(_username, _password);
builder.addNonce();
builder.addCreated();
Document doc = messageContext.getMessage().getSOAPPart().getEnvelope().getOwnerDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
builder.build(doc, secHeader);
} catch (Exception e) {
LOGGER.error("Unable to handle SOAP message", e);
return false;
}
}
return true;
}
...
}
我用 XMLUtils.PrettyDocumentToString(doc)
检查了 doc 对象,发现它看起来像是 soupUI 发送的 XML - 所有身份验证信息(登录名、密码、随机数和创建时间)都已到位, Security
标记的 mustUnderstand 属性为真。
然后我遇到了错误:
javax.xml.ws.soap.SOAPFaultException:MustUnderstand header :[{ http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd }安全性]不理解
我找到了从 Security
标记中删除 mustUnderstand 属性的建议,但没有帮助。你有什么想法吗?
附言
Web 服务端点在 HTTPS 上。
来自 WSDL 的策略部分:
<wsp:Policy wsu:Id="BasicHttpBinding_RelateService_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding>
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Lax/>
</wsp:Policy>
</sp:Layout>
<sp:IncludeTimestamp/>
</wsp:Policy>
</sp:TransportBinding>
<sp:SignedSupportingTokens>
<wsp:Policy>
<sp:UsernameToken
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssUsernameToken10/>
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SignedSupportingTokens>
<sp:Wss10>
<wsp:Policy/>
</sp:Wss10>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
soapUI 请求:
<soapenv:Envelope xmlns:ns="http://api.example.com/RelateService/1.0"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-37"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>username</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
password
</wsse:Password>
<wsse:Nonce
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
li/0YK2wxrmrHL7Cg+etdQ==
</wsse:Nonce>
<wsu:Created>2012-02-21T08:59:10.262Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ns:RetrieveCustomerByEmail>
<ns:email>xxx@example.com</ns:email>
<ns:firstName/>
<ns:lastName/>
</ns:RetrieveCustomerByEmail>
</soapenv:Body>
</soapenv:Envelope>
我的要求:
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<wsse:Security 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"
S:mustUnderstand="1">
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>username</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
password
</wsse:Password>
<wsse:Nonce
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
+jeleKO9zr0/wLjAIYcmSg==
</wsse:Nonce>
<wsu:Created>2012-02-21T09:42:03.760Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</S:Header>
<S:Body>
<ns5:RetrieveCustomerByEmail xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"
xmlns:ns2="http://schemas.datacontract.org/2004/07/XXX.Service"
xmlns:ns3="http://schemas.datacontract.org/2004/07/XXX.Service.Relate.Contract"
xmlns:ns4="http://schemas.datacontract.org/2004/07/XXX.Service.Dto"
xmlns:ns5="http://api.example.com/RelateService/1.0"
xmlns:ns6="http://schemas.microsoft.com/2003/10/Serialization/">
<ns5:email>xxx@example.com</ns5:email>
<ns5:firstName/>
<ns5:lastName/>
</ns5:RetrieveCustomerByEmail>
</S:Body>
</S:Envelope>
最佳答案
当服务不处理 header 时,您可能会遇到此错误。该服务需要实现一个带有 getHeaders() 的 SOAPHandler 来解析 header 。对于上述故障正确的实现方式如下
@Override
public Set<QName> getHeaders() {
QName securityHeader = new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
"Security");
HashSet<QName> headers = new HashSet<QName>();
headers.add(securityHeader);
return headers;
}
当服务实际上不安全时,也有可能得到这个,但客户端正在尝试使用安全配置(可能使用 XWSS 安全配置)为此,只需从浏览器检查已发布的 wsdl 并确保它包含预期的安全策略(将 ?wsdl 附加到其端点 URL)
关于java - SOAP 故障异常 "MustUnderstand headers (oasis-200401-wss-wssecurity-secext-1.0.xsd) are not understood",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9364428/
我一直在尝试各种 Java Web 服务堆栈(CXF、Metro 和 Spring-WS),并得出的结论是,它们中没有一个比 Spring 的 SimpleJaxWsServiceExporter 的
我正在尝试用 java 创建一个 Soap 客户端,我必须使用我的私钥对 Soap 消息进行签名。 我正在使用配置了 WS-Security 的 SoapUI 获取响应。 我已经使用 wsimport
我正在尝试为一个 SOAP 服务组装一个小型 CXF 客户端,该服务在其 wsdl 中具有 SignedSupportingTokens ws-security 策略。我已配置CXF客户端如下
我正在尝试使用基于 Java 的 Web 服务,但每次我尝试连接时都会收到这样的错误: org.apache.ws.security.WSSecurityException: The security
问题的第 1 部分: 使用 npm Soap,我尝试对以下端点 var url 进行 SOAP 调用。 var sslRootCAs = require('ssl-root-cas/latest')
我正在尝试请求这项内部服务,负责该服务的团队表示它需要用户名 + 密码并使用证书加密。 我想到使用这个模块node-soap并且我在文档中找到了这个: 1- https://github.com/vp
我尝试从使用 PasswordText WSS 类型的 Web 服务获取信息。首先,我使用 soapUI 对其进行了测试并成功获取了数据。然后我在Java上实现了认证,写了SecurityHandle
最近几天一直在为这个错误而苦苦挣扎 Authentication of type {http://service.soap.xcompany.com}AuthenticationHeader had
我正在使用 jax-ws 从 JAVA 调用使用 WS-Security 的 SOAP 服务。问题是响应包含一些 MustUnderstand header ,并且我收到 Element notund
我正在使用 .net 中开发的 Web 服务,该服务接受用户名和密码作为 SOAP header 的一部分。我创建了 SOAPHandler 来创建 header 。 我打印了如下消息: x
Web 服务托管在没有 Internet 连接的服务器上 我正在使用 SOAPUI 访问 Web 服务 url 并进行测试 但得到以下错误信息任何帮助真的很感激
我浏览了以下链接:SOAPFaultException "MustUnderstand headers (oasis-200401-wss-wssecurity-secext-1.0.xsd) are
我是一名优秀的程序员,十分优秀!