- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 Apache axis 1.4 创建了 Web 服务客户端。我正在访问的 wcf 服务是 STS 服务,需要 AppliesTo 参数及其返回的 SAML token 。我在搜索时浏览了各种博客和网站,以及我是如何找到这个的kanbancoding Part 3因此,我仔细检查并在代码中进行了更改,但现在我得到了org.apache.cxf.ws.policy.PolicyException:没有任何策略替代方案可以得到满足。我的
最佳答案
经过多次尝试和错误,我弄清楚我到底需要什么来调用 WCF STS 服务。我在 Docs.Oasis O Oasis WS Trust 1.3 上找到了一份文档。其中详细解释了需要在肥皂消息中发送哪些数据,并且在 kanbancoding 的帮助下是的。这是我调用STS的方法
private static void getSecurityToken() {
try {
// Use the empty constructor – no need to specify wsdl
SecurityTokenService src = new SecurityTokenService();
// Pull the class used to negotiate WS Trust directly from the
// SecurityTokenService
IWSTrust13Sync trust = src.getBasicHttpBindingIWSTrust13Sync();
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(IWSTrust13Sync.class);
factory.setAddress(ServiceURL);
IWSTrust13Sync service = (IWSTrust13Sync) factory.create();
// Obtain a reference to the CXF endpoint using the ClientProxy helper:
Client client = ClientProxy.getClient(service);
// Set up logging if desired
client.getOutInterceptors().add(new LoggingOutInterceptor());
client.getInInterceptors().add(new LoggingInInterceptor());
client.getRequestContext().put("com.sun.xml.ws.connect.timeout", 1 * 60 * 1000);
client.getRequestContext().put("com.sun.xml.ws.request.timeout", 5 * 60 * 1000);
// Specify the user we want to authenticate
client.getRequestContext().put("ws-security.username", UserName);
client.getRequestContext().put("ws-security.password", Password);
HTTPConduit http = (HTTPConduit) client.getConduit();
http.getAuthorization().setUserName(UserName);
http.getAuthorization().setPassword(Password);
http.getClient().setConnectionTimeout(36000);
http.getClient().setAllowChunking(false);
RequestSecurityTokenType token = new RequestSecurityTokenType();
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element tokenType = document.createElementNS("http://docs.oasis-open.org/ws-sx/ws-trust/200512",
"TokenType");
tokenType.setTextContent("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
token.getAny().add(tokenType);
Element requestType = document.createElementNS("http://docs.oasis-open.org/ws-sx/ws-trust/200512",
"RequestType");
requestType.setTextContent("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue");
token.getAny().add(requestType);
Document appliesTodoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element appliesTo = appliesTodoc.createElementNS("http://schemas.xmlsoap.org/ws/2004/09/policy",
"AppliesTo");
Element endPoint = appliesTodoc.createElementNS("http://schemas.xmlsoap.org/ws/2004/08/addressing",
"EndpointReference");
Element address = appliesTodoc.createElementNS("http://schemas.xmlsoap.org/ws/2004/08/addressing",
"Address");
address.setTextContent("http://localhost");
endPoint.appendChild(address);
appliesTo.appendChild(endPoint);
token.getAny().add(appliesTo);
//Now specify what claims we want back.
Document claimsDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element claims = claimsDoc.createElementNS("http://docs.oasis-open.org/ws-sx/ws-trust/200512", "Claims");
claims.setAttribute("Dialect", "http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice");
// Add claims to token request
//token.getAny().add(claims);
RequestSecurityTokenResponseCollectionType result = service.trust13Issue(token);
//parseResponse(result);
List<RequestSecurityTokenResponseType> response = result.getRequestSecurityTokenResponse();
Iterator<RequestSecurityTokenResponseType> itr = response.iterator();
while (itr.hasNext()) {
RequestSecurityTokenResponseType obj = itr.next();
List<Object> responseObject = obj.getAny();
Iterator<Object> ObjItr = responseObject.iterator();
while (ObjItr.hasNext()) {
System.out.println("Result " + ObjItr.next());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
但没有完全成功地实现我想要的,但是是的,我在 Apache CFX Log 中得到响应,而不是在结果对象中。
关于java - 策略异常 : None of the policy alternatives can be satisfied in WCF Service Call,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22450568/
这个问题在这里已经有了答案: Why does the print function return None? (1 个回答) 关闭 6 年前。 我正在学习理解。我得到了 print(x) 部分(我
我以为我理解了 Python 中的这两个单例值,直到我看到有人在代码中使用 return l1 or l2,其中 l1 和 l2 都是链表对象,并且(s)他想如果不为 None 则返回 l1,否则返回
我希望在 IPython Notebook 中使用列表理解生成枚举字符串列表。它有效,但给了我一个我不理解的奇怪输出。 cols = [] [cols.append('Value'+str(hour)
这个问题在这里已经有了答案: Why does the expression 0 >> import dis >>> def a(): ... return None is None is N
《Learning Python 5th》第608页有示例代码: >>> list(print(x.upper(), end=' ') for x in 'spam') S P A M [None,
我对此进行了搜索并遇到了列表返回函数,但我仍然不明白。 我试图理解为什么 Print 函数到另一个函数返回以下内容: 生日快乐 生日快乐 无 无 我的代码: def happy(): prin
除非我疯了 if None not in x 和 if not None in x 是等价的。有首选版本吗?我想 None not in 更像英语,因此更像 pythonic,但 not None i
尝试绘制 k-NN 分类器的决策边界但无法这样做得到 TypeError: '(slice(None, None, None), 0)' is an invalid key h = .01 # st
我正在尝试将可变大小的序列输入 LSTM。因此我使用生成器且批量大小为 1。 我有一个嵌入的 (sequence_length,)-input-tensor,并输出 (batch_size,equen
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Is there any way to know if the value of an argument i
我正在尝试根据环境变量的返回值进行条件赋值。 self._TBLFilePath = iTBLFilePath or os.environ.get("CDO_TBLPATH") + os.enviro
我正在使用 marshmallow 2.0.0rc2 验证 HTTP 请求的输入数据,并在 HTTP 响应上将 SQLAlchemy 模型加载到 JSON。我偶然发现了两个问题: 首先,在通过 HTT
我想将我设置为 None 的变量与 is 进行比较,但它失败了。 当我使用 == 将此变量与 None 进行比较时,它起作用了。 这就是我所说的变量: print type(xml.a) -> 因为
我最近遇到了这种语法,我不知道有什么区别。 如果有人能告诉我其中的区别,我将不胜感激。 最佳答案 答案解释here . 引用: A class is free to implement compari
尝试使用 BorutaPy 进行特征选择。但出现 TypeError: '(slice(None, None, None), array([0, 1, 2, 3, 4]))' 是无效键。 from s
我见过使用 [] 的代码片段, [None] , None或 ()作为 placeholder 的形状, 那是 x = tf.placeholder(..., shape=[], ...) y = t
是否有逻辑推理可以解释为什么下面的 Ansible playbook 中的两个 debug 任务分别输出 "NONE" 和 "FALSE"并且不是两者都“NONE”? - hosts: 'all'
我有一个函数,它可以返回两个整数的元组或(None, None)的元组: (出于本问题的目的,我们假设此返回格式是执行此操作的唯一方法,并且无法更改) from typing import Tuple
问题: 如何遍历字典并从中删除 None 键或值? 这是我尝试过的: 代码: import copy def _ignore(data): copied_data = copy.deepcop
什么是简洁的 python 表达方式 if : # do a bunch of stuff once 最佳答案 为什么不简单, None not in lst 关于python - 简明地说 "
我是一名优秀的程序员,十分优秀!