Java Code Examples for org.apache.cxf.service.model.OperationInfo#getProperty()
The following examples show how to use
org.apache.cxf.service.model.OperationInfo#getProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FaultBeanGenerator.java From cxf with Apache License 2.0 | 6 votes |
protected Collection<JavaClass> generateBeanClasses(final ServiceInfo serviceInfo) { Set<Class<?>> exceptionClasses = new HashSet<>(); String seiPackageName = null; for (OperationInfo op : serviceInfo.getInterface().getOperations()) { Method method = (Method) op.getProperty("operation.method"); exceptionClasses.addAll(getExceptionClasses(method)); seiPackageName = getSEIPackage(method); } Collection<JavaClass> faultBeanClasses = new HashSet<>(); String defaultPackage = seiPackageName + ".jaxws"; FaultBean bean = new FaultBean(); for (Class<?> clz : exceptionClasses) { if (!bean.faultBeanExists(clz)) { faultBeanClasses.add(bean.transform(clz, defaultPackage)); } } return faultBeanClasses; }
Example 2
Source File: DateTypeCustomGenerator.java From cxf with Apache License 2.0 | 6 votes |
protected Class<?> getDateType() { if (getServiceModel() == null) { return null; } for (OperationInfo op : getServiceModel().getInterface().getOperations()) { Method m = (Method) op.getProperty("operation.method"); for (Class<?> clz : m.getParameterTypes()) { if (clz == Date.class || clz == Calendar.class) { return clz; } } if (m.getReturnType() == Date.class || m.getReturnType() == Calendar.class) { return m.getReturnType(); } } return null; }
Example 3
Source File: AegisDatabinding.java From cxf with Apache License 2.0 | 6 votes |
private Method getMethod(Service s, OperationInfo op) { Method m = op.getProperty(Method.class.getName(), Method.class); if (m != null) { return m; } MethodDispatcher md = (MethodDispatcher)s.get(MethodDispatcher.class.getName()); // The ibm jdk requires the simple frontend dependency to be // present for the SimpleMethodDispatcher cast below even if // md is null (sun jdk does not). So, for the jaxrs frontend, // we can exclude the simple frontend from the aegis databinding // dependency as long as this null check is here. if (md == null) { return null; } SimpleMethodDispatcher smd = (SimpleMethodDispatcher)md; return smd.getPrimaryMethod(op); }
Example 4
Source File: JaxWsServiceFactoryBean.java From cxf with Apache License 2.0 | 6 votes |
@Override protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) { method = ((JaxWsServiceConfiguration)jaxWsConfiguration).getDeclaredMethod(method); o.setProperty(Method.class.getName(), method); o.setProperty(METHOD, method); initializeWrapping(o, method); // rpc out-message-part-info class mapping Operation op = (Operation)o.getProperty(WSDLServiceBuilder.WSDL_OPERATION); initializeClassInfo(o, method, op == null ? null : CastUtils.cast(op.getParameterOrdering(), String.class)); bindOperation(o, method); sendEvent(Event.INTERFACE_OPERATION_BOUND, o, method); }
Example 5
Source File: JAXBDataBase.java From cxf with Apache License 2.0 | 5 votes |
private Annotation[] getReturnMethodAnnotations(MessagePartInfo mpi) { AbstractMessageContainer mi = mpi.getMessageInfo(); if (mi == null || !isOutputMessage(mi)) { return null; } OperationInfo oi = mi.getOperation(); return oi != null ? (Annotation[])oi.getProperty("method.return.annotations") : null; }
Example 6
Source File: JaxWsSoapBindingConfiguration.java From cxf with Apache License 2.0 | 5 votes |
public String getStyle(OperationInfo op) { Method m = op.getProperty("operation.method", Method.class); if (m != null) { return serviceFactory.isRPC(m) ? "rpc" : "document"; } return getStyle(); }
Example 7
Source File: JaxWsProxyFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
private boolean needWrapperClassInterceptor(ServiceInfo serviceInfo) { if (serviceInfo == null) { return false; } for (OperationInfo opInfo : serviceInfo.getInterface().getOperations()) { if (opInfo.isUnwrappedCapable() && opInfo.getProperty(ReflectionServiceFactoryBean.WRAPPERGEN_NEEDED) != null) { return true; } } return false; }
Example 8
Source File: SoapBindingConfiguration.java From cxf with Apache License 2.0 | 5 votes |
public String getSoapAction(OperationInfo op) { String action = (String)op.getProperty("action"); if (action == null) { return defaultSoapAction; } return action; }
Example 9
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) { // rpc out-message-part-info class mapping Operation op = (Operation)o.getProperty(WSDLServiceBuilder.WSDL_OPERATION); if (initializeClassInfo(o, method, op == null ? null : CastUtils.cast(op.getParameterOrdering(), String.class))) { bindOperation(o, method); o.setProperty(ReflectionServiceFactoryBean.METHOD, method); sendEvent(Event.INTERFACE_OPERATION_BOUND, o, method); } else { LOG.log(Level.WARNING, "NO_METHOD_FOR_OP", o.getName()); } }
Example 10
Source File: ServiceWSDLBuilder.java From cxf with Apache License 2.0 | 4 votes |
protected void buildPortTypeOperation(PortType portType, Collection<OperationInfo> operationInfos, final Definition def) { for (OperationInfo operationInfo : operationInfos) { Operation operation = null; try { operation = operationInfo.getProperty( WSDLServiceBuilder.WSDL_OPERATION, Operation.class); } catch (ClassCastException e) { // do nothing } if (operation == null) { operation = def.createOperation(); addDocumentation(operation, operationInfo.getDocumentation()); operation.setUndefined(false); operation.setName(operationInfo.getName().getLocalPart()); addNamespace(operationInfo.getName().getNamespaceURI(), def); if (operationInfo.isOneWay()) { operation.setStyle(OperationType.ONE_WAY); } addExtensibilityElements(def, operation, getWSDL11Extensors(operationInfo)); Input input = def.createInput(); addDocumentation(input, operationInfo.getInput().getDocumentation()); input.setName(operationInfo.getInputName()); Message message = def.createMessage(); buildMessage(message, operationInfo.getInput(), def); this.addExtensibilityAttributes(def, input, getInputExtensionAttributes(operationInfo)); this.addExtensibilityElements(def, input, getWSDL11Extensors(operationInfo.getInput())); input.setMessage(message); operation.setInput(input); operation.setParameterOrdering(operationInfo.getParameterOrdering()); if (operationInfo.getOutput() != null) { Output output = def.createOutput(); addDocumentation(output, operationInfo.getOutput().getDocumentation()); output.setName(operationInfo.getOutputName()); message = def.createMessage(); buildMessage(message, operationInfo.getOutput(), def); this.addExtensibilityAttributes(def, output, getOutputExtensionAttributes(operationInfo)); this.addExtensibilityElements(def, output, getWSDL11Extensors(operationInfo.getOutput())); output.setMessage(message); operation.setOutput(output); } //loop to add fault Collection<FaultInfo> faults = operationInfo.getFaults(); Fault fault = null; for (FaultInfo faultInfo : faults) { fault = def.createFault(); addDocumentation(fault, faultInfo.getDocumentation()); fault.setName(faultInfo.getFaultName().getLocalPart()); message = def.createMessage(); buildMessage(message, faultInfo, def); this.addExtensibilityAttributes(def, fault, faultInfo.getExtensionAttributes()); this.addExtensibilityElements(def, fault, getWSDL11Extensors(faultInfo)); fault.setMessage(message); operation.addFault(fault); } } portType.addOperation(operation); } }
Example 11
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
protected void buildServiceFromClass() { Object o = getBus().getProperty("requireExplicitContractLocation"); if (o != null && ("true".equals(o) || Boolean.TRUE.equals(o))) { throw new ServiceConstructionException(new Message("NO_WSDL_PROVIDED", LOG, getServiceClass().getName())); } if (LOG.isLoggable(Level.INFO)) { LOG.info("Creating Service " + getServiceQName() + " from class " + getServiceClass().getName()); } populateFromClass = true; if (Proxy.isProxyClass(this.getServiceClass())) { LOG.log(Level.WARNING, "USING_PROXY_FOR_SERVICE", getServiceClass()); } sendEvent(Event.CREATE_FROM_CLASS, getServiceClass()); ServiceInfo serviceInfo = new ServiceInfo(); SchemaCollection col = serviceInfo.getXmlSchemaCollection(); col.getXmlSchemaCollection().setSchemaResolver(new CatalogXmlSchemaURIResolver(this.getBus())); col.getExtReg().registerSerializer(MimeAttribute.class, new MimeSerializer()); ServiceImpl service = new ServiceImpl(serviceInfo); setService(service); setServiceProperties(); serviceInfo.setName(getServiceQName()); serviceInfo.setTargetNamespace(serviceInfo.getName().getNamespaceURI()); sendEvent(Event.SERVICE_SET, getService()); createInterface(serviceInfo); Set<?> wrapperClasses = this.getExtraClass(); for (ServiceInfo si : getService().getServiceInfos()) { if (wrapperClasses != null && !wrapperClasses.isEmpty()) { si.setProperty(EXTRA_CLASS, wrapperClasses); } } initializeDataBindings(); boolean isWrapped = isWrapped() || hasWrappedMethods(serviceInfo.getInterface()); if (isWrapped) { initializeWrappedSchema(serviceInfo); } for (OperationInfo opInfo : serviceInfo.getInterface().getOperations()) { Method m = (Method)opInfo.getProperty(METHOD); if (!isWrapped(m) && !isRPC(m) && opInfo.getInput() != null) { createBareMessage(serviceInfo, opInfo, false); } if (!isWrapped(m) && !isRPC(m) && opInfo.getOutput() != null) { createBareMessage(serviceInfo, opInfo, true); } if (opInfo.hasFaults()) { // check to make sure the faults are elements for (FaultInfo fault : opInfo.getFaults()) { QName qn = (QName)fault.getProperty("elementName"); MessagePartInfo part = fault.getFirstMessagePart(); if (!part.isElement()) { part.setElement(true); part.setElementQName(qn); checkForElement(serviceInfo, part); } } } } if (LOG.isLoggable(Level.FINE) || isValidate()) { ServiceModelSchemaValidator validator = new ServiceModelSchemaValidator(serviceInfo); validator.walk(); String validationComplaints = validator.getComplaints(); if (!"".equals(validationComplaints)) { if (isValidate()) { LOG.warning(validationComplaints); } else { LOG.fine(validationComplaints); } } } }
Example 12
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
protected void createBareMessage(ServiceInfo serviceInfo, OperationInfo opInfo, boolean isOut) { MessageInfo message = isOut ? opInfo.getOutput() : opInfo.getInput(); final List<MessagePartInfo> messageParts = message.getMessageParts(); if (messageParts.isEmpty()) { return; } Method method = (Method)opInfo.getProperty(METHOD); int paraNumber = 0; for (MessagePartInfo mpi : messageParts) { SchemaInfo schemaInfo = null; XmlSchema schema = null; QName qname = (QName)mpi.getProperty(ELEMENT_NAME); if (messageParts.size() == 1 && qname == null) { qname = !isOut ? getInParameterName(opInfo, method, -1) : getOutParameterName(opInfo, method, -1); if (qname.getLocalPart().startsWith("arg") || qname.getLocalPart().startsWith("return")) { qname = isOut ? new QName(qname.getNamespaceURI(), method.getName() + "Response") : new QName(qname .getNamespaceURI(), method.getName()); } } else if (isOut && messageParts.size() > 1 && qname == null) { while (!isOutParam(method, paraNumber)) { paraNumber++; } qname = getOutParameterName(opInfo, method, paraNumber); } else if (qname == null) { qname = getInParameterName(opInfo, method, paraNumber); } for (SchemaInfo s : serviceInfo.getSchemas()) { if (s.getNamespaceURI().equals(qname.getNamespaceURI())) { schemaInfo = s; break; } } if (schemaInfo == null) { schemaInfo = getOrCreateSchema(serviceInfo, qname.getNamespaceURI(), true); schema = schemaInfo.getSchema(); } else { schema = schemaInfo.getSchema(); if (schema != null && schema.getElementByName(qname) != null) { mpi.setElement(true); mpi.setElementQName(qname); mpi.setXmlSchema(schema.getElementByName(qname)); paraNumber++; continue; } } schemaInfo.setElement(null); //cached element is now invalid XmlSchemaElement el = new XmlSchemaElement(schema, true); el.setName(qname.getLocalPart()); el.setNillable(true); if (mpi.isElement()) { XmlSchemaElement oldEl = (XmlSchemaElement)mpi.getXmlSchema(); if (null != oldEl && !oldEl.getQName().equals(qname)) { el.setSchemaTypeName(oldEl.getSchemaTypeName()); el.setSchemaType(oldEl.getSchemaType()); if (oldEl.getSchemaTypeName() != null) { addImport(schema, oldEl.getSchemaTypeName().getNamespaceURI()); } } mpi.setElement(true); mpi.setXmlSchema(el); mpi.setElementQName(qname); mpi.setConcreteName(qname); continue; } if (null == mpi.getTypeQName() && mpi.getXmlSchema() == null) { throw new ServiceConstructionException(new Message("UNMAPPABLE_PORT_TYPE", LOG, method.getDeclaringClass().getName(), method.getName(), mpi.getName())); } if (mpi.getTypeQName() != null) { el.setSchemaTypeName(mpi.getTypeQName()); } else { el.setSchemaType((XmlSchemaType)mpi.getXmlSchema()); } mpi.setXmlSchema(el); mpi.setConcreteName(qname); if (mpi.getTypeQName() != null) { addImport(schema, mpi.getTypeQName().getNamespaceURI()); } mpi.setElement(true); mpi.setElementQName(qname); paraNumber++; } }
Example 13
Source File: DocLiteralInInterceptor.java From cxf with Apache License 2.0 | 4 votes |
private void validatePart(MessagePartInfo p, QName elName, Message m) { if (p == null) { throw new Fault(new org.apache.cxf.common.i18n.Message("NO_PART_FOUND", LOG, elName), Fault.FAULT_CODE_CLIENT); } boolean synth = false; if (p.getMessageInfo() != null && p.getMessageInfo().getOperation() != null) { OperationInfo op = p.getMessageInfo().getOperation(); Boolean b = (Boolean)op.getProperty("operation.is.synthetic"); if (b != null) { synth = b; } } if (MessageUtils.getContextualBoolean(m, "soap.no.validate.parts", false)) { // something like a Provider service or similar that is forcing a // doc/lit/bare on an endpoint that may not really be doc/lit/bare. // we need to just let these through per spec so the endpoint // can process it synth = true; } if (synth) { return; } if (p.isElement()) { if (p.getConcreteName() != null && !elName.equals(p.getConcreteName()) && !synth) { throw new Fault("UNEXPECTED_ELEMENT", LOG, null, elName, p.getConcreteName()); } } else { if (!(elName.equals(p.getName()) || elName.equals(p.getConcreteName())) && !synth) { throw new Fault("UNEXPECTED_ELEMENT", LOG, null, elName, p.getConcreteName()); } } }