soap - 如何使用从 wsdl 生成的 jaxws-wsimport 发送 saml 请求
问题描述
SecurityTokenService service = new SecurityTokenService();
SecurityTokenServicePortTypeIssue port = service.getISTSIssue();
// TODO initialize WS operation arguments here
RequestSecurityTokenType issueRequest = new RequestSecurityTokenType();
LifetimeType lifetime = new LifetimeType();
/*
* Derive the token creation date and time. Use a GregorianCalendar to establish the current time, then use a DatatypeFactory to map the time data to XML. */
DatatypeFactory dtFactory = DatatypeFactory.newInstance();
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
XMLGregorianCalendar xmlCalendar = dtFactory.newXMLGregorianCalendar(cal);
AttributedDateTime created = new AttributedDateTime();
created.setValue(xmlCalendar.toXMLFormat());
/*
* Specify a time interval for token expiration (specified in milliseconds).
*/
AttributedDateTime expires = new AttributedDateTime();
xmlCalendar.add(dtFactory.newDuration(30 * 60 * 1000));
expires.setValue(xmlCalendar.toXMLFormat());
/*
* Set the created and expires fields in the lifetime object.
*/
lifetime.setCreated(created);
lifetime.setExpires(expires);
/*
* Set the token request fields.
*/
issueRequest.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
issueRequest.setRequestType("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue");
issueRequest.setLifetime(lifetime);
RequestSecurityTokenResponseType result = port.issueRST(issueRequest);
System.out.println("Result = " + result);
} catch (Exception ex) {
System.out.println(ex);
}
请告诉我我做错了什么。这是我在运行此代码 com.sun.xml.internal.ws.fault.ServerSOAPFaultException 后遇到的错误:客户端从服务器收到 SOAP 错误:客户端错误请查看服务器日志以查找有关失败确切原因的更多详细信息。
解决方案
推荐阅读
- python - 使用子进程运行批处理文件
- python - 如何使用 Python 覆盖 CSV 文件中的特定行
- git - TeamCity 基于上次提交构建特定容器
- android - 使用Handler和Runnable的正确方法是什么?
- ssl - ArangoDB 与 letsenrcypt 证书一起使用
- go - 如何检测当前 Go 进程是否在无头(非 GUI)环境中运行?
- visual-studio-2012 - 如何在 VisualStudio 2012 中向工具栏项添加图标?
- python - 将元组作为键的字典转换为包含键和值的元组
- angularjs - 在AngularJS中重置选择标签
- spring - S3:将文件放置在多个目标存储桶中的出站适配器