public MessageModeOutInterceptor(SAAJOutInterceptor saajOut, QName bname) { super(Phase.PREPARE_SEND); this.saajOut = saajOut; this.bindingName = bname; internal = new MessageModeOutInterceptorInternal(); } public MessageModeOutInterceptor(Class<?> t, QName bname) {
MessageModeOutInterceptorInternal() { super(Phase.PRE_PROTOCOL); addBefore(SAAJOutInterceptor.class.getName()); }
in.add(new WrapperClassInInterceptor()); in.add(new HolderInInterceptor()); in.add(new SwAInInterceptor()); getOutInterceptors().add(new SwAOutInterceptor()); if (isProvider && mode == Mode.MESSAGE) { in.add(new SAAJInInterceptor()); in.add(new MessageModeInInterceptor(clazz, getBinding().getBindingInfo().getName())); out.add(new WrapperClassOutInterceptor()); out.add(new HolderOutInterceptor()); out.add(new MessageModeOutInterceptor(saajOut, getBinding().getBindingInfo().getName())); } else if (isProvider) { out.add(new MessageModeOutInterceptor(clazz, getBinding().getBindingInfo().getName()));
List<Interceptor<? extends Message>> in = super.getInInterceptors(); List<Interceptor<? extends Message>> out = super.getOutInterceptors(); in.add(new WrapperClassInInterceptor()); in.add(new HolderInInterceptor()); out.add(new WrapperClassOutInterceptor()); out.add(new HolderOutInterceptor());
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) {
client.getOutInterceptors().add(saajOut); client.getOutInterceptors(). add(new MessageModeOutInterceptor(saajOut, client.getEndpoint() .getBinding().getBindingInfo().getName())); client.getInInterceptors().add(new SAAJInInterceptor()); client.getInInterceptors() .add(new MessageModeInInterceptor(clazz, client.getEndpoint() .getBinding().getBindingInfo().getName()));
MultiPartDataSource(Message message, DataSource root) { atts = message.getAttachments().iterator(); String s = (String)message.get(Message.CONTENT_TYPE); boundary = findBoundary(s); start = findStart(s); if (!s.contains(boundary)) { s += "; boundary=\"" + boundary + "\""; } contentType = s; rootPart = root; try { writer = new OutputStreamWriter(bout, "ASCII"); writer.append("Content-Type: ").append(contentType).append("\r\n\r\n"); writer.flush(); current = bout.createInputStream(); } catch (Exception e) { //nothing } }
public void handleMessage(Message message) throws Fault { BindingOperationInfo bop = message.getExchange().getBindingOperationInfo(); if (bop == null || !bindingName.equals(bop.getBinding().getName())) { return; } Object o = message.getContent(soapMsgClass); if (o != null) { doFromSoapMessage(message, o); } else if (DataSource.class.isAssignableFrom(type)) { doDataSource(message); } }
private void validatePossibleFault(Message message, BindingOperationInfo bop, Node ds) { Element el = DOMUtils.getFirstElement(ds); if (!"Fault".equals(el.getLocalName())) { return; } message.put(Message.RESPONSE_CODE, 500); el = DOMUtils.getFirstElement(el); while (el != null && !"detail".equals(el.getLocalName())) { el = DOMUtils.getNextElement(el); } if (el != null) { Schema schema = EndpointReferenceUtils.getSchema(message.getExchange().getService() .getServiceInfos().get(0), message.getExchange().getBus()); try { validateFaultDetail(el, schema, bop); } catch (Exception e) { throw new Fault(e); } //We validated what we can from a fault standpoint message.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE); } } private void validateFaultDetail(Element detail, Schema schema, BindingOperationInfo bop) throws Exception {
public HolderOutInterceptor() { super(Phase.PRE_LOGICAL); addBefore(WrapperClassOutInterceptor.class.getName()); }
private WebFault getWebFaultAnnotation(Class<?> t) { WebFault fault = t.getAnnotation(WebFault.class); if (fault == null && t.getSuperclass() != null && Throwable.class.isAssignableFrom(t.getSuperclass())) { fault = getWebFaultAnnotation(t.getSuperclass()); } return fault; }
protected boolean hasSwaRef(JAXBDataBinding db) { JAXBContext context = db.getContext(); return callSWARefMethod(context); }
@Override public InputStream getInputStream() throws IOException { LoadingByteArrayOutputStream bout = new LoadingByteArrayOutputStream(); writeTo(bout); return bout.createInputStream(); } @Override
@Override protected void initializeFaultInterceptors() { getService().getOutFaultInterceptors().add(new WebFaultOutInterceptor()); }
private void doDataSource(final Message message) { MessageContentsList list = (MessageContentsList)message.getContent(List.class); //reconstitute all the parts into a Mime data source if (message.getAttachments() != null && !message.getAttachments().isEmpty() && list != null && !list.isEmpty() && list.get(0) instanceof DataSource) { list.set(0, new MultiPartDataSource(message, (DataSource)list.get(0))); } }
private synchronized WrapperHelper getWrapperHelper(Message message, MessageInfo messageInfo, MessageInfo wrappedMessageInfo, Class<?> wrapClass, MessagePartInfo messagePartInfo) { WrapperHelper helper = messagePartInfo.getProperty("WRAPPER_CLASS", WrapperHelper.class); if (helper == null) { Service service = ServiceModelUtil.getService(message.getExchange()); DataBinding dataBinding = service.getDataBinding(); if (dataBinding instanceof WrapperCapableDatabinding) { helper = createWrapperHelper((WrapperCapableDatabinding)dataBinding, messageInfo, wrappedMessageInfo, wrapClass); messagePartInfo.setProperty("WRAPPER_CLASS", helper); } } return helper; }
ensureSize(partNames, p.getIndex()); ensureSize(elTypeNames, p.getIndex()); ensureSize(partClasses, p.getIndex());
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); } }