List of usage examples for javax.xml.namespace QName getNamespaceURI
public String getNamespaceURI()
Get the Namespace URI of this QName
.
From source file:com.example.soaplegacy.WsdlValidator.java
@SuppressWarnings("unchecked") private void validateSoapFault(BindingOperation bindingOperation, XmlObject msgXml, List<XmlError> errors) throws Exception { Map faults = bindingOperation.getBindingFaults(); Iterator<BindingFault> i = faults.values().iterator(); // create internal error list List<?> list = new ArrayList<Object>(); XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setErrorListener(list);//from w w w.j a v a 2s . c o m xmlOptions.setValidateTreatLaxAsSkip(); msgXml.validate(xmlOptions); for (Object o : list) { if (o instanceof XmlError) errors.add((XmlError) o); else errors.add(XmlError.forMessage(o.toString())); } while (i.hasNext()) { BindingFault bindingFault = i.next(); String faultName = bindingFault.getName(); Part[] faultParts = WsdlUtils.getFaultParts(bindingOperation, faultName); if (faultParts.length == 0) { log.warn("Missing fault parts in wsdl for fault [" + faultName + "] in bindingOperation [" + bindingOperation.getName() + "]"); continue; } if (faultParts.length != 1) { log.info("Too many fault parts in wsdl for fault [" + faultName + "] in bindingOperation [" + bindingOperation.getName() + "]"); continue; } Part part = faultParts[0]; QName elementName = part.getElementName(); if (elementName != null) { XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='" + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';" + "declare namespace ns='" + elementName.getNamespaceURI() + "';" + "//env:Fault/flt:detail/ns:" + elementName.getLocalPart()); if (paths.length == 1) { SchemaGlobalElement elm = wsdlContext.getSchemaTypeLoader().findElement(elementName); if (elm != null) { validateMessageBody(errors, elm.getType(), paths[0]); } else errors.add(XmlError.forMessage("Missing fault part element [" + elementName + "] for fault [" + part.getName() + "] in associated schema")); return; } } // this is not allowed by Basic Profile.. remove? else if (part.getTypeName() != null) { QName typeName = part.getTypeName(); XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='" + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';" + "declare namespace ns='" + typeName.getNamespaceURI() + "';" + "//env:Fault/flt:detail/ns:" + part.getName()); if (paths.length == 1) { SchemaType type = wsdlContext.getSchemaTypeLoader().findType(typeName); if (type != null) { validateMessageBody(errors, type, paths[0]); } else errors.add(XmlError.forMessage("Missing fault part type [" + typeName + "] for fault [" + part.getName() + "] in associated schema")); return; } } } // if we get here, no matching fault was found.. this is not an error but // should be warned.. XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='" + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';//env:Fault/flt:detail"); if (paths.length == 0) log.warn("Missing matching Fault in wsdl for bindingOperation [" + bindingOperation.getName() + "]"); else { String xmlText = paths[0].xmlText(new XmlOptions().setSaveOuter()); log.warn("Missing matching Fault in wsdl for Fault Detail element [" + XmlUtils.removeUnneccessaryNamespaces(xmlText) + "] in bindingOperation [" + bindingOperation.getName() + "]"); } }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public ComplexTypeDefinition findComplexTypeDefinition(QName typeName) { if (StringUtils.isEmpty(typeName.getNamespaceURI())) { return resolveGlobalTypeDefinitionWithoutNamespace(typeName.getLocalPart()); }/*from www .j av a 2 s .c o m*/ PrismSchema schema = findSchemaByNamespace(typeName.getNamespaceURI()); if (schema == null) { return null; } return schema.findComplexTypeDefinition(typeName); }
From source file:com.ettrema.httpclient.Host.java
/** * TODO: should optimise so it only generates once per set of fields * /*from w w w .j a v a 2s. c o m*/ * @param fields * @return */ private String buildPropFindXml(List<QName> fields) { try { if (fields == null) { fields = defaultFields; } Element elPropfind = new Element("propfind", RespUtils.NS_DAV); Document doc = new Document(elPropfind); Element elProp = new Element("prop", RespUtils.NS_DAV); elPropfind.addContent(elProp); for (QName qn : fields) { Element elName = new Element(qn.getLocalPart(), qn.getPrefix(), qn.getNamespaceURI()); elProp.addContent(elName); } XMLOutputter outputter = new XMLOutputter(); ByteArrayOutputStream out = new ByteArrayOutputStream(); outputter.output(doc, out); return out.toString("UTF-8"); } catch (IOException ex) { throw new RuntimeException(ex); } }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public ItemDefinition findItemDefinitionByType(QName typeName) { if (StringUtils.isEmpty(typeName.getNamespaceURI())) { ComplexTypeDefinition ctd = resolveGlobalTypeDefinitionWithoutNamespace(typeName.getLocalPart()); typeName = ctd.getTypeName();/*from w ww . jav a 2 s . co m*/ } PrismSchema schema = findSchemaByNamespace(typeName.getNamespaceURI()); if (schema == null) { return null; } return schema.findItemDefinitionByType(typeName, ItemDefinition.class); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public ItemDefinition findItemDefinitionByElementName(QName elementName) { if (StringUtils.isEmpty(elementName.getNamespaceURI())) { return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), ItemDefinition.class); }//ww w .j a v a2 s. c o m PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI()); if (schema == null) { return null; } return schema.findItemDefinition(elementName, ItemDefinition.class); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public <T extends Objectable> PrismObjectDefinition<T> findObjectDefinitionByElementName(QName elementName) { if (StringUtils.isEmpty(elementName.getNamespaceURI())) { return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), PrismObjectDefinition.class); }/*from ww w . ja va2 s . com*/ PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI()); if (schema == null) { return null; } return schema.findObjectDefinitionByElementName(elementName); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public PrismPropertyDefinition findPropertyDefinitionByElementName(QName elementName) { if (StringUtils.isEmpty(elementName.getNamespaceURI())) { return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), PrismPropertyDefinition.class); }//from ww w.j av a2 s . c o m PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI()); if (schema == null) { return null; } return schema.findPropertyDefinitionByElementName(elementName); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public PrismReferenceDefinition findReferenceDefinitionByElementName(QName elementName) { if (StringUtils.isEmpty(elementName.getNamespaceURI())) { return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), PrismReferenceDefinition.class); }/*from w w w . j a va 2 s. c om*/ PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI()); if (schema == null) { return null; } return schema.findReferenceDefinitionByElementName(elementName); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public <C extends Containerable> PrismContainerDefinition<C> findContainerDefinitionByElementName( QName elementName) { if (StringUtils.isEmpty(elementName.getNamespaceURI())) { return resolveGlobalItemDefinitionWithoutNamespace(elementName.getLocalPart(), PrismContainerDefinition.class); }//from w ww .ja va2 s .c o m PrismSchema schema = findSchemaByNamespace(elementName.getNamespaceURI()); if (schema == null) { return null; } return schema.findContainerDefinitionByElementName(elementName); }
From source file:com.evolveum.midpoint.prism.schema.SchemaRegistry.java
public <T> Class<T> determineCompileTimeClass(QName typeName) { if (StringUtils.isEmpty(typeName.getNamespaceURI())) { ComplexTypeDefinition ctd = resolveGlobalTypeDefinitionWithoutNamespace(typeName.getLocalPart()); return (Class) ctd.getCompileTimeClass(); }/* ww w .ja v a2s . c o m*/ SchemaDescription desc = findSchemaDescriptionByNamespace(typeName.getNamespaceURI()); if (desc == null) { return null; } Package pkg = desc.getCompileTimeClassesPackage(); if (pkg == null) { return null; } Class<T> compileTimeClass = JAXBUtil.findClassForType(typeName, pkg); return compileTimeClass; }