public SOAPMessageContextImpl(Message m) { super(m, Scope.HANDLER); roles.add(getWrappedSoapMessage().getVersion().getNextRole()); }
private Collection<Attachment> setupAttachmentOutput(SoapMessage message) { // We have attachments, so add the interceptor message.getInterceptorChain().add(attachOut); // We should probably come up with another property for this message.put(AttachmentOutInterceptor.WRITE_ATTACHMENTS, Boolean.TRUE); Collection<Attachment> atts = message.getAttachments(); if (atts == null) { atts = new ArrayList<>(); message.setAttachments(atts); } return atts; } }
private void checkUnderstoodHeaders(SoapMessage soapMessage) { Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(soapMessage); if (soapMessage.getHeaders().isEmpty() && paramHeaders.isEmpty()) { //the TCK expects the getHeaders method to always be //called. If there aren't any headers in the message, //THe MustUnderstandInterceptor quickly returns without //trying to calculate the understood headers. Thus, //we need to call it here. getUnderstoodHeaders(); } }
private void validateFault(SoapMessage message, SOAPFault fault, BindingOperationInfo bop) { if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) { Schema schema = EndpointReferenceUtils.getSchema(message.getExchange().getService() .getServiceInfos().get(0), message.getExchange().getBus()); Detail d = fault.getDetail(); try { validateFaultDetail(d, schema, bop); } catch (Exception e) { throw new SoapFault(e.getMessage(), e, message.getVersion().getReceiver()); } //We validated what we can from a fault standpoint message.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE); } }
org.apache.cxf.binding.soap.SoapMessage cxfSoapMessage = (org.apache.cxf.binding.soap.SoapMessage)message; String cxfNamespace = cxfSoapMessage.getVersion().getNamespace(); SOAPHeader soapHeader = soapMessage.getSOAPHeader(); String namespace = soapHeader == null ? null : soapHeader.getNamespaceURI(); if (namespace != null && cxfNamespace != null && !namespace.equals(cxfNamespace) && Soap12.SOAP_NAMESPACE.equals(namespace)) { cxfSoapMessage.setVersion(Soap12.getInstance()); cxfSoapMessage.put(Message.CONTENT_TYPE, cxfSoapMessage.getVersion().getContentType());
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); } }
public SOAPMessage getMessage() { SOAPMessage message = null; if (getWrappedMessage().getContent(Object.class) instanceof SOAPMessage) { message = (SOAPMessage)getWrappedMessage().getContent(Object.class); } else { message = getWrappedMessage().getContent(SOAPMessage.class); } //Only happens to non-Dispatch/Provider case. if (null == message) { Boolean outboundProperty = (Boolean)get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty == null || !outboundProperty) { //No SOAPMessage exists yet, so lets create one SAAJ_IN.handleMessage(getWrappedSoapMessage()); message = getWrappedSoapMessage().getContent(SOAPMessage.class); } } return message; }
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); } }
@Override public void handleMessage(SoapMessage message) throws Fault { HttpServletResponse response = (HttpServletResponse) message.getExchange() .getInMessage().get(AbstractHTTPDestination.HTTP_RESPONSE); response.setStatus(200); // message.put(SoapMessage.RESPONSE_CODE, 200); } }
protected void updateHeader(Exchange exchange, MessageContext ctx) { if (ctx.containsKey(Header.HEADER_LIST) && ctx.get(Header.HEADER_LIST) instanceof List<?>) { List<?> list = (List<?>) ctx.get(Header.HEADER_LIST); if (list != null && !list.isEmpty()) { SoapMessage sm = (SoapMessage) createResponseMessage(exchange); if (sm != null) { Iterator<?> iter = list.iterator(); while (iter.hasNext()) { Header header = (Header) iter.next(); if (header.getDirection() != Header.Direction.DIRECTION_IN && !header.getName().getNamespaceURI(). equals("http://docs.oasis-open.org/wss/2004/01/" + "oasis-200401-wss-wssecurity-secext-1.0.xsd") && !header.getName().getNamespaceURI(). equals("http://docs.oasis-open.org/" + "wss/oasis-wss-wssecurity-secext-1.1.xsd")) { //don't copy over security header, out interceptor chain will take care of it. sm.getHeaders().add(header); } } } } } }
public void handleMessage(SoapMessage message) throws Fault { Exchange ex = message.getExchange(); BindingOperationInfo bop = ex.getBindingOperationInfo(); if (bop == null) { return; } if (bop.isUnwrapped()) { bop = bop.getWrappedOperation(); } boolean client = isRequestor(message); BindingMessageInfo bmi = client ? bop.getInput() : bop.getOutput(); if (bmi == null) { return; } SoapBodyInfo sbi = bmi.getExtensor(SoapBodyInfo.class); if (sbi == null || sbi.getAttachments() == null || sbi.getAttachments().isEmpty()) { Service s = ex.getService(); DataBinding db = s.getDataBinding(); if (db instanceof JAXBDataBinding && hasSwaRef((JAXBDataBinding) db)) { setupAttachmentOutput(message); } return; } processAttachments(message, sbi); } protected void processAttachments(SoapMessage message, SoapBodyInfo sbi) {
public void setRoles(Set<String> set) { if (set != null && (set.contains(Soap11.getInstance().getNoneRole()) || set.contains(Soap12.getInstance().getNoneRole()))) { throw new WebServiceException(BUNDLE.getString("NONE_ROLE_ERR")); } this.roles = set; addRequiredRoles(); }
private static boolean chainAlreadyContainsSAAJ(SoapMessage message) { ListIterator<Interceptor<? extends Message>> listIterator = message.getInterceptorChain().getIterator(); while (listIterator.hasNext()) { if (listIterator.next() instanceof SAAJOutInterceptor) { return true; } } return false; } }
private void addRequiredRoles() { if (this.roles == null) { this.roles = new HashSet<>(); } if (this.soapBinding instanceof SoapBindingInfo) { SoapBindingInfo bindingInfo = (SoapBindingInfo) this.soapBinding; if (bindingInfo.getSoapVersion() instanceof Soap11) { this.roles.add(bindingInfo.getSoapVersion().getNextRole()); } else if (bindingInfo.getSoapVersion() instanceof Soap12) { this.roles.add(bindingInfo.getSoapVersion().getNextRole()); this.roles.add(bindingInfo.getSoapVersion().getUltimateReceiverRole()); } } }
@Override public String getStyle() { SOAPBinding sb = getServiceClass().getAnnotation(SOAPBinding.class); if (sb != null) { if (sb.style().equals(Style.DOCUMENT)) { return "document"; } else if (sb.style().equals(Style.RPC)) { return "rpc"; } } return super.getStyle(); }
@Override public String getUse() { SOAPBinding sb = getServiceClass().getAnnotation(SOAPBinding.class); if (sb != null) { if (sb.use().equals(Use.LITERAL)) { return "literal"; } else if (sb.use().equals(Use.ENCODED)) { return "encoded"; } } return super.getUse(); } }
private void checkUnderstoodHeaders(SoapMessage soapMessage) { Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(soapMessage); if (soapMessage.getHeaders().isEmpty() && paramHeaders.isEmpty()) { //the TCK expects the getHeaders method to always be //called. If there aren't any headers in the message, //THe MustUnderstandInterceptor quickly returns without //trying to calculate the understood headers. Thus, //we need to call it here. getUnderstoodHeaders(); } }
@Override protected Fault createFault(Throwable ex, Method m, List<Object> params, boolean checked) { //map the JAX-WS faults SOAPFaultException sfe = findSoapFaultException(ex); if (sfe != null) { SoapFault fault = new SoapFault(sfe.getFault().getFaultString(), ex, sfe.getFault().getFaultCodeAsQName()); fault.setRole(sfe.getFault().getFaultActor()); if (sfe.getFault().hasDetail()) { fault.setDetail(sfe.getFault().getDetail()); } return fault; } return super.createFault(ex, m, params, checked); }
private void checkUnderstoodHeaders(SoapMessage soapMessage) { Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(soapMessage); if (soapMessage.getHeaders().isEmpty() && paramHeaders.isEmpty()) { //the TCK expects the getHeaders method to always be //called. If there aren't any headers in the message, //THe MustUnderstandInterceptor quickly returns without //trying to calculate the understood headers. Thus, //we need to call it here. getUnderstoodHeaders(); } }