public void handleMessage(Message message) throws Fault { BindingOperationInfo bop = message.getExchange().getBindingOperationInfo(); if (bop != null && !bindingName.equals(bop.getBinding().getName())) { return; } else if (DataSource.class.isAssignableFrom(type)) { MessageContentsList list = (MessageContentsList)message.getContent(List.class); DataSource ds = (DataSource)list.get(0); String ct = ds.getContentType(); if (ct.toLowerCase().contains("multipart/related")) { Message msg = new MessageImpl(); msg.setExchange(message.getExchange()); msg.put(Message.CONTENT_TYPE, ct); try { message.setContent(XMLStreamWriter.class, writer); } else if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message) && Source.class.isAssignableFrom(type)) {
public static QName makeQualifiedNameFromClass(Class<?> clazz) { String namespace = makeNamespaceFromClassName(clazz.getName(), "http"); String localPart = makeServiceNameFromClassName(clazz); return new QName(namespace, localPart); }
/** * A convenience method to check for schema validation config in the message context, and then in the service model. * Does not modify the Message context (other than what is done in the getContextualProperty itself) * * @param message */ public static SchemaValidationType getSchemaValidationType(Message message) { SchemaValidationType validationType = getOverrideSchemaValidationType(message); if (validationType == null) { validationType = getSchemaValidationTypeFromModel(message); } if (validationType == null) { Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED); if (obj != null) { validationType = getSchemaValidationType(obj); } } if (validationType == null) { validationType = SchemaValidationType.NONE; } return validationType; }
/** * A convenience method to check for schema validation config in the message context, and then in the service model. * Does not modify the Message context (other than what is done in the getContextualProperty itself) * * @param message * @param type */ public static SchemaValidationType getSchemaValidationType(Message message) { SchemaValidationType validationType = getOverrideSchemaValidationType(message); if (validationType == null) { validationType = getSchemaValidationTypeFromModel(message); } if (validationType == null) { validationType = SchemaValidationType.NONE; } return validationType; }
public void handleMessage(Message message) throws Fault { Exchange ex = message.getExchange(); BindingOperationInfo bop = ex.getBindingOperationInfo(); MessageInfo messageInfo = message.get(MessageInfo.class); if (messageInfo == null || bop == null || !bop.isUnwrapped()) { return; if (Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) { wrappedMsgInfo = newbop.getInput().getMessageInfo(); } else { if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message) && helper instanceof AbstractWrapperHelper) { ((AbstractWrapperHelper)helper).setValidate(true); ex.put(BindingOperationInfo.class, newbop);
public void handleMessage(Message message) throws Fault { Fault f = (Fault)message.getContent(Exception.class); if (f == null) { return; SoapVersion soapVersion = (SoapVersion)message.get(SoapVersion.class.getName()); if (soapVersion != null && soapVersion.getVersion() != 1.1) { if (f instanceof SoapFault) { message.setContent(Exception.class, f); throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_INVOKE", BUNDLE), e); Service service = message.getExchange().getService(); = service.getDataBinding().createWriter(XMLStreamWriter.class); if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) { Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message.getExchange().getBus()); writer.setSchema(schema); OperationInfo op = message.getExchange().getBindingOperationInfo().getOperationInfo(); QName faultName = getFaultName(fault, cause.getClass(), op); MessagePartInfo part = getFaultMessagePart(faultName, op);
private static SchemaValidationType getOverrideSchemaValidationType(Message message) { Object obj = message.get(Message.SCHEMA_VALIDATION_ENABLED); if (obj == null && message.getExchange() != null) { obj = message.getExchange().get(Message.SCHEMA_VALIDATION_ENABLED); } if (obj != null) { // this method will transform the legacy enabled as well return getSchemaValidationType(obj); } return null; }
private static SchemaValidationType getSchemaValidationTypeFromModel(Message message) { Exchange exchange = message.getExchange(); if (exchange != null) { BindingOperationInfo boi = exchange.getBindingOperationInfo(); Endpoint endpoint = exchange.getEndpoint(); if (boi != null && endpoint != null) { SchemaValidationType validationType = null; OperationInfo opInfo = boi.getOperationInfo(); EndpointInfo ep = endpoint.getEndpointInfo(); if (validationType == null && opInfo != null) { validationType = getSchemaValidationTypeFromModel(message, opInfo); if (validationType == null && ep != null) { validationType = getSchemaValidationTypeFromModel(message, ep); } } return validationType; } } // else return null; }
private void setSchemaInMessage(Message message, XMLStreamReader reader) throws XMLStreamException { if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) { try { WoodstoxValidationImpl mgr = new WoodstoxValidationImpl(); if (mgr.canValidate()) { mgr.setupValidation(reader, message.getExchange().getEndpoint(), message.getExchange().getService().getServiceInfos().get(0)); } } catch (Throwable t) { //likely no MSV or similar LOG.log(Level.FINE, "Problem initializing MSV validation", t); } } } }
protected void setOperationSchemaValidation(Message message) { SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message); message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType); }
public void handleMessage(Message message) throws Fault { // This assumes that this interceptor is only use in IN / IN Fault chains. if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message) && message.getAttachments() != null) { Collection<AttachmentDataSource> dss = new ArrayList<>(); for (Attachment at : message.getAttachments()) { if (at.getDataHandler().getDataSource() instanceof AttachmentDataSource) { AttachmentDataSource ds = (AttachmentDataSource)at.getDataHandler().getDataSource(); try { ds.hold(message); } catch (IOException e) { throw new Fault(e); } dss.add(ds); } } if (!dss.isEmpty()) { message.put(SAVED_DATASOURCES, dss); message.getInterceptorChain().add(EndingInterceptor.INSTANCE); } } }
private void setDataWriterValidation(Service service, Message message, DataWriter<?> writer) { if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) { Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message.getExchange().getBus()); writer.setSchema(schema); } }
BindingOperationInfo bop = exchange.getBindingOperationInfo(); if (null == bop) { return; MessagePartInfo mpi = header.getPart(); try { if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) { Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message .getExchange().getBus()); validateHeader(message, mpi, schema);
private static SchemaValidationType getOverrideSchemaValidationType(Message message) { Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED); if (obj != null) { // this method will transform the legacy enabled as well return getSchemaValidationType(obj); } else { return null; } }
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); } }
DataReader<Node> dataReader = dataBinding.createReader(Node.class); dataReader.setAttachments(message.getAttachments()); dataReader.setProperty(DataReader.ENDPOINT, message.getExchange().getEndpoint()); dataReader.setProperty(Message.class.getName(), message); obj = dataReader.read(hel); if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message)) { message.getInterceptorChain().add(new CheckClosingTagsInterceptor());
protected boolean shouldValidate(Message message) { return ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, message); }
@Override public QName getFaultName(InterfaceInfo service, OperationInfo o, Class<?> exClass, Class<?> beanClass) { String name = ServiceUtils.makeServiceNameFromClassName(beanClass); return new QName(service.getName().getNamespaceURI(), name); }
@Override public String getServiceNamespace() { String ret = super.getServiceNamespace(); if (ret == null && getServiceFactory() != null && getServiceFactory().getServiceClass() != null) { ret = ServiceUtils.makeNamespaceFromClassName(getServiceFactory().getServiceClass().getName(), "http"); } return ret; }
addWordToPackageBuffer(sb, words[i], i == words.length - 1); addWordToPackageBuffer(sb, st2.nextToken(), false);