本文整理了Java中javax.xml.ws.Binding.getHandlerChain()
方法的一些代码示例,展示了Binding.getHandlerChain()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.getHandlerChain()
方法的具体详情如下:
包路径:javax.xml.ws.Binding
类名称:Binding
方法名:getHandlerChain
[英]Gets a copy of the handler chain for a protocol binding instance. If the returned chain is modified a call to setHandlerChainis required to configure the binding instance with the new chain.
[中]获取协议绑定实例的处理程序链的副本。如果修改了返回的链,则需要调用SetHandlerChain以使用新链配置绑定实例。
代码示例来源:origin: stackoverflow.com
final Binding binding = ((BindingProvider) servicePort).getBinding();
List<Handler> handlerList = binding.getHandlerChain();
if (handlerList == null)
handlerList = new ArrayList<Handler>();
handlerList.add(new SecurityHandler());
binding.setHandlerChain(handlerList); // <- important!
代码示例来源:origin: stagemonitor/stagemonitor
@Advice.OnMethodExit
private static void setHandlerChain(@Advice.Return Object portOrDispatch) {
if (portOrDispatch instanceof BindingProvider) {
final Binding binding = ((BindingProvider) portOrDispatch).getBinding();
final List<Handler> handlerChain = binding.getHandlerChain();
if (handlerChain != null) {
binding.setHandlerChain(handlerChain);
} else {
binding.setHandlerChain(new ArrayList<Handler>());
}
}
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test
public void test() throws Exception {
QName serviceName = new QName("http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld", "HelloWorldService");
Service service = Service.create(new URL("http://localhost:" + getPort()), serviceName);
HelloWorldService helloWorldService = service.getPort(HelloWorldService.class);
assertThat(helloWorldService).isInstanceOf(BindingProvider.class);
final BindingProvider bindingProvider = (BindingProvider) helloWorldService;
boolean clientHandlerFound = false;
for (Handler handler : bindingProvider.getBinding().getHandlerChain()) {
if (handler instanceof TracingClientSOAPHandler) {
clientHandlerFound = true;
}
}
assertThat(clientHandlerFound).overridingErrorMessage("No %s found in %s",
TracingClientSOAPHandler.class.getSimpleName(),
bindingProvider.getBinding().getHandlerChain()).isTrue();
}
代码示例来源:origin: stackoverflow.com
// HandlerChain installieren
Binding binding = ((BindingProvider) port).getBinding();
List hchain = binding.getHandlerChain();
if (hchain == null) {
hchain = new ArrayList();
}
hchain.add(new HTTPUserAgentHandler());
binding.setHandlerChain(hchain);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public Set<QName> getUnderstoodHeaders() {
Set<QName> understood = new HashSet<>();
for (Handler<?> h : getBinding().getHandlerChain()) {
if (h instanceof SOAPHandler) {
Set<QName> headers = CastUtils.cast(((SOAPHandler<?>) h).getHeaders());
if (headers != null) {
understood.addAll(headers);
}
}
}
return understood;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public Set<QName> getUnderstoodHeaders() {
Set<QName> understood = new HashSet<>();
for (Handler<?> h : getBinding().getHandlerChain()) {
if (h instanceof SOAPHandler) {
Set<QName> headers = CastUtils.cast(((SOAPHandler<?>) h).getHeaders());
if (headers != null) {
understood.addAll(headers);
}
}
}
return understood;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public Set<QName> getUnderstoodHeaders() {
Set<QName> understood = new HashSet<>();
for (Handler<?> h : getBinding().getHandlerChain()) {
if (h instanceof SOAPHandler) {
Set<QName> headers = CastUtils.cast(((SOAPHandler<?>) h).getHeaders());
if (headers != null) {
understood.addAll(headers);
}
}
}
return understood;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleFault(SoapMessage message) {
if (binding.getHandlerChain().isEmpty()) {
return;
}
if (getInvoker(message).getProtocolHandlers().isEmpty()) {
return;
}
if (getInvoker(message).isOutbound()
&& !chainAlreadyContainsSAAJ(message)) {
SAAJ_OUT.handleFault(message);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(T message) {
if (binding.getHandlerChain().isEmpty()) {
return;
}
MessageContext context = createProtocolMessageContext(message);
HandlerChainInvoker invoker = getInvoker(message);
invoker.setProtocolMessageContext(context);
invoker.invokeProtocolHandlers(isRequestor(message), context);
onCompletion(message);
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(SoapMessage message) {
if (binding.getHandlerChain().isEmpty()) {
return;
}
if (getInvoker(message).getProtocolHandlers().isEmpty()) {
return;
}
checkUnderstoodHeaders(message);
if (getInvoker(message).isOutbound()) {
//The SOAPMessage might be set from the outchain, in this case,
//we need to clean it up and create a new SOAPMessage dedicated to fault.
message.setContent(SOAPMessage.class, null);
SAAJ_OUT.handleMessage(message);
message.getInterceptorChain().add(ending);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
if (binding.getHandlerChain().isEmpty()) {
return;
}
HandlerChainInvoker invoker = getInvoker(message);
if (invoker.getLogicalHandlers().isEmpty()) {
return;
}
XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
Document doc = DOMUtils.newDocument();
message.setContent(Node.class, doc);
W3CDOMStreamWriter writer = new W3CDOMStreamWriter(doc);
// set up the namespace context
try {
writer.setNamespaceContext(origWriter.getNamespaceContext());
} catch (XMLStreamException ex) {
// don't set the namespaceContext
}
// Replace stax writer with DomStreamWriter
message.setContent(XMLStreamWriter.class, writer);
message.put(ORIGINAL_WRITER, origWriter);
message.getInterceptorChain().add(ending);
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
@Override
public void handleMessage(Message message) {
if (binding.getHandlerChain().isEmpty()) {
return;
}
HandlerChainInvoker invoker = getInvoker(message);
if (invoker.getLogicalHandlers().isEmpty()) {
return;
}
LogicalMessageContextImpl lctx = new LogicalMessageContextImpl(message);
invoker.setLogicalMessageContext(lctx);
boolean requestor = isRequestor(message);
if (!invoker.invokeLogicalHandlersHandleFault(requestor, lctx)) {
if (!requestor) {
//server side, wont get here
} else {
//Client side inbound, thus no response expected, do nothing, the close will
//be handled by MEPComplete later
}
}
//If this is the inbound and end of MEP, call MEP completion
if (!isOutbound(message) && isMEPComlete(message)) {
onCompletion(message);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(SoapMessage message) {
if (binding.getHandlerChain().isEmpty()) {
return;
}
if (getInvoker(message).getProtocolHandlers().isEmpty()) {
return;
}
checkUnderstoodHeaders(message);
MessageContext context = createProtocolMessageContext(message);
HandlerChainInvoker invoker = getInvoker(message);
invoker.setProtocolMessageContext(context);
if (!invoker.invokeProtocolHandlersHandleFault(isRequestor(message), context)) {
handleAbort(message, context);
}
SOAPMessage msg = message.getContent(SOAPMessage.class);
if (msg != null) {
XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(msg);
message.setContent(XMLStreamReader.class, xmlReader);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
@Override
public void handleMessage(Message message) {
if (binding.getHandlerChain().isEmpty()) {
return;
}
HandlerChainInvoker invoker = getInvoker(message);
if (invoker.getLogicalHandlers().isEmpty()) {
return;
}
LogicalMessageContextImpl lctx = new LogicalMessageContextImpl(message);
invoker.setLogicalMessageContext(lctx);
boolean requestor = isRequestor(message);
if (!requestor) {
setupBindingOperationInfo(message.getExchange(), lctx);
}
if (!invoker.invokeLogicalHandlers(requestor, lctx)) {
if (!requestor) {
//server side
handleAbort(message, null);
} else {
//Client side inbound, thus no response expected, do nothing, the close will
//be handled by MEPComplete later
}
}
//If this is the inbound and end of MEP, call MEP completion
if (!isOutbound(message) && isMEPComlete(message)) {
onCompletion(message);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
if (binding.getHandlerChain().isEmpty()) {
return;
}
HandlerChainInvoker invoker = getInvoker(message);
if (invoker.getLogicalHandlers().isEmpty()) {
return;
}
XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
Node nd = message.getContent(Node.class);
SOAPMessage m = message.getContent(SOAPMessage.class);
Document document = null;
if (m != null) {
document = m.getSOAPPart();
} else if (nd != null) {
document = nd.getOwnerDocument();
} else {
document = DOMUtils.newDocument();
message.setContent(Node.class, document);
}
W3CDOMStreamWriter writer = new W3CDOMStreamWriter(document.createDocumentFragment());
// Replace stax writer with DomStreamWriter
message.setContent(XMLStreamWriter.class, writer);
message.put(ORIGINAL_WRITER, origWriter);
message.getInterceptorChain().add(ending);
}
@Override
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(SoapMessage message) {
if (binding.getHandlerChain().isEmpty()) {
return;
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
protected HandlerChainInvoker getInvoker(T message) {
Exchange ex = message.getExchange();
HandlerChainInvoker invoker =
ex.get(HandlerChainInvoker.class);
if (null == invoker) {
invoker = new HandlerChainInvoker(binding.getHandlerChain(),
isOutbound(message));
ex.put(HandlerChainInvoker.class, invoker);
}
boolean outbound = isOutbound(message, ex);
if (outbound) {
invoker.setOutbound();
} else {
invoker.setInbound();
}
invoker.setRequestor(isRequestor(message));
if (ex.isOneWay()
|| ((isRequestor(message) && !outbound)
|| (!isRequestor(message) && outbound))) {
invoker.setResponseExpected(false);
} else {
invoker.setResponseExpected(true);
}
return invoker;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
configureObject(jaxwsEndpoint);
@SuppressWarnings("rawtypes")
List<Handler> hc = jaxwsEndpoint.getJaxwsBinding().getHandlerChain();
代码示例来源:origin: apache/cxf
public Set<QName> getUnderstoodHeaders() {
Set<QName> understood = new HashSet<>();
for (Handler<?> h : getBinding().getHandlerChain()) {
if (h instanceof SOAPHandler) {
Set<QName> headers = CastUtils.cast(((SOAPHandler<?>) h).getHeaders());
if (headers != null) {
understood.addAll(headers);
}
}
}
return understood;
}
代码示例来源:origin: apache/cxf
private void addHandlersProgrammatically(BindingProvider bp, Handler<?>...handlers) {
@SuppressWarnings("rawtypes")
List<Handler> handlerChain = bp.getBinding().getHandlerChain();
assertNotNull(handlerChain);
for (Handler<?> h : handlers) {
handlerChain.add(h);
}
bp.getBinding().setHandlerChain(handlerChain);
}
内容来源于网络,如有侵权,请联系作者删除!