List of usage examples for javax.xml.namespace QName equals
public final boolean equals(Object objectToTest)
Test this QName
for equality with another Object
.
If the Object
to be tested is not a QName
or is null
, then this method returns false
.
Two QName
s are considered equal if and only if both the Namespace URI and local part are equal.
From source file:org.apache.axis2.context.externalize.ActivateUtils.java
/** * Find the AxisOperation object that matches the criteria * //from w w w.j a va 2s .c om * @param axisConfig The AxisConfiguration object * @param opClassName the class name string for the target object * (could be a derived class) * @param opQName the name associated with the operation * @return the AxisOperation object that matches the given criteria */ public static AxisOperation findOperation(AxisConfiguration axisConfig, String opClassName, QName opQName) { HashMap services = axisConfig.getServices(); Iterator its = services.values().iterator(); while (its.hasNext()) { AxisService service = (AxisService) its.next(); Iterator ito = service.getOperations(); while (ito.hasNext()) { AxisOperation operation = (AxisOperation) ito.next(); String tmpOpName = operation.getClass().getName(); QName tmpOpQName = operation.getName(); if ((tmpOpName.equals(opClassName)) && (tmpOpQName.equals(opQName))) { // trace point if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findOperation(axisCfg): returning [" + opClassName + "] [" + opQName.toString() + "]"); } return operation; } } } // trace point if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findOperation(axisCfg): [" + opClassName + "] [" + opQName.toString() + "] returning [null]"); } return null; }
From source file:org.apache.axis2.context.externalize.ActivateUtils.java
/** * Find the AxisOperation object that matches the criteria * /*w w w . ja v a 2s . c o m*/ * @param service The AxisService object * @param opClassName The class name string for the target object * (could be a derived class) * @param opQName the name associated with the operation * @return the AxisOperation object that matches the given criteria */ public static AxisOperation findOperation(AxisService service, String opClassName, QName opQName) { if (service == null) { return null; } Iterator ito = service.getOperations(); // Previous versions of Axis2 didn't use a namespace on the operation name, so they wouldn't // have externalized a namespace. If that's the case, only compare the localPart of the // operation name String namespace = opQName.getNamespaceURI(); boolean ignoreNamespace = false; if (namespace == null || "".equals(namespace)) { ignoreNamespace = true; } while (ito.hasNext()) { AxisOperation operation = (AxisOperation) ito.next(); String tmpOpName = operation.getClass().getName(); QName tmpOpQName = operation.getName(); if ((tmpOpName.equals(opClassName)) && ((ignoreNamespace && (tmpOpQName.getLocalPart().equals(opQName.getLocalPart())) || (tmpOpQName.equals(opQName))))) { if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findOperation(service): ignoreNamespace [" + ignoreNamespace + "] returning [" + opClassName + "] [" + opQName.toString() + "]"); } return operation; } } // trace point if (log.isTraceEnabled()) { log.trace("ObjectStateUtils:findOperation(service): ignoreNamespace [" + ignoreNamespace + " classname [" + opClassName + "] QName [" + opQName.toString() + "] returning [null]"); } return null; }
From source file:org.apache.axis2.deployment.util.Utils.java
public static AxisBindingOperation getBindingOperation(AxisBinding binding, AxisOperation operation) { QName opName = operation.getName(); for (Iterator bindingOps = binding.getChildren(); bindingOps.hasNext();) { AxisBindingOperation bindingOp = (AxisBindingOperation) bindingOps.next(); if (opName.equals(bindingOp.getName())) { return bindingOp; }/* w w w. j a v a 2s . c o m*/ } return null; }
From source file:org.apache.axis2.description.WSDL11ToAxisServiceBuilder.java
/** * @param binding/*w w w.j a va2 s .co m*/ * @param wsdl4jService must have atlease one port * @throws AxisFault */ private void populateEndpoints(Binding binding, Definition bindingWSDL, Service wsdl4jService, PortType portType, Definition portTypeWSDL) throws AxisFault { Map wsdl4jPorts = wsdl4jService.getPorts(); QName bindingName = binding.getQName(); Port port; AxisEndpoint axisEndpoint = null; processedBindings = new HashMap(); // process the port type for this binding // although we support multiports they must be belongs to same port type and should have the // same soap style populatePortType(portType, portTypeWSDL); Binding currentBinding; Definition currentBindingWSDL = null; for (Iterator iterator = wsdl4jPorts.values().iterator(); iterator.hasNext();) { port = (Port) iterator.next(); // if the user has picked a port then we have to process only that port if ((this.portName == null) || (this.portName.equals(port.getName()))) { // we process the port only if it has the same port type as the selected binding currentBindingWSDL = getParentDefinition(wsdl4jDefinition, port.getBinding().getQName(), COMPONENT_BINDING, new HashSet()); currentBinding = currentBindingWSDL.getBinding(port.getBinding().getQName()); if (currentBinding.getPortType().getQName().equals(binding.getPortType().getQName())) { axisEndpoint = new AxisEndpoint(); axisEndpoint.setName(port.getName()); if (axisService.getEndpointName() == null && bindingName.equals(port.getBinding().getQName())) { populateEndpoint(axisEndpoint, port, currentBinding, bindingWSDL, portType, portTypeWSDL, true); axisService.setEndpointName(axisEndpoint.getName()); axisService.setBindingName(axisEndpoint.getBinding().getName().getLocalPart()); } else { populateEndpoint(axisEndpoint, port, currentBinding, bindingWSDL, portType, portTypeWSDL, false); } axisEndpoint.setParent(axisService); axisService.addEndpoint(port.getName(), axisEndpoint); } } } }
From source file:org.apache.axis2.jaxws.common.config.AddressingWSDLExtensionValidator.java
/** * Performs validation of input extensionSets from RespectBindingConfigurator. * @param extensionSet - Set of found required=true extensions from WSDL, read WSDLValidatorElement object definition. * @param wsdlDefinition - a WSDL definition instance. * @param endpointDesc - EndpointDescription that describes JAX-WS Endpoint definition. */// w w w. java2 s. c om public void validate(Set<WSDLValidatorElement> extensionSet, Definition wsdlDefinition, EndpointDescription endpointDesc) { if (debug) { log.debug("Looking for WSDL extension elements to validate"); } if (extensionSet.isEmpty()) { if (debug) { log.debug("No WSDL extension elements found to validate"); } return; } if (debug) { log.debug("Processing WSDL extension elements"); } Iterator<WSDLValidatorElement> extensionIterator = extensionSet.iterator(); WSDLValidatorElement elementToValidate; while (extensionIterator.hasNext()) { elementToValidate = extensionIterator.next(); if (elementToValidate.getState() == WSDLValidatorElement.State.NOT_RECOGNIZED) { ExtensibilityElement ee = elementToValidate.getExtensionElement(); QName name = (ee != null) ? ee.getElementType() : null; if ((name != null) && (name .equals(new QName("http://www.w3.org/2006/05/addressing/wsdl", "UsingAddressing")))) { if (debug) { log.debug( "Found WSDL extension element {http://www.w3.org/2006/05/addressing/wsdl,UsingAddressing} -- validating"); } EndpointDescriptionJava edj = (EndpointDescriptionJava) endpointDesc; Annotation anno = edj.getAnnoFeature(AddressingFeature.ID); if (getFeatureFromAnnotation(anno) == null) { if (debug) { log.debug( "Enabling addressing annotation was not found, so this extension element is not supported"); } elementToValidate.setState(WSDLValidatorElement.State.NOT_SUPPORTED); } else { if (debug) { log.debug( "The matching addressing annotation was found, so this extension element is supported"); } elementToValidate.setState(WSDLValidatorElement.State.SUPPORTED); } } } } }
From source file:org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.java
/** * @see org.apache.axis2.jaxws.description.DescriptionFactory#updateEndpoint(ServiceDescription, * Class, EndpointReference, String, DescriptionFactory.UpdateType, DescriptionBuilderComposite, Object) */// w w w.j av a 2s . co m public static EndpointDescription updateEndpoint(ServiceDescription serviceDescription, Class sei, EndpointReference epr, String addressingNamespace, DescriptionFactory.UpdateType updateType, DescriptionBuilderComposite composite, Object sparseCompositeKey, String bindingId, String endpointAddress) { QName portQName = null; try { ServiceName serviceName = EndpointReferenceHelper.getServiceNameMetadata(epr, addressingNamespace); QName serviceQName = serviceDescription.getServiceQName(); //We need to throw an exception if the service name in the EPR metadata does not //match the service name associated with the JAX-WS service instance. if (serviceName.getName() != null && !serviceQName.equals(serviceName.getName())) { throw ExceptionFactory.makeWebServiceException(Messages.getMessage("serviceNameMismatch", serviceName.getName().toString(), serviceQName.toString())); } //If a port name is available from the EPR metadata then use that, otherwise //leave it to the runtime to find a suitable port, based on WSDL/annotations. if (serviceName.getEndpointName() != null) { portQName = new QName(serviceQName.getNamespaceURI(), serviceName.getEndpointName()); } } catch (Exception e) { throw ExceptionFactory .makeWebServiceException(Messages.getMessage("updateEndpointError", e.getMessage())); } return updateEndpoint(serviceDescription, sei, portQName, updateType, composite, sparseCompositeKey, bindingId, endpointAddress); }
From source file:org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.java
public List<Port> getWSDLPortsUsingPortType(QName portTypeQN) { ArrayList<Port> portList = new ArrayList<Port>(); if (!DescriptionUtils.isEmpty(portTypeQN)) { Map wsdlPortMap = getWSDLPorts(); if (wsdlPortMap != null && !wsdlPortMap.isEmpty()) { for (Object mapElement : wsdlPortMap.values()) { Port wsdlPort = (Port) mapElement; PortType wsdlPortType = wsdlPort.getBinding().getPortType(); QName wsdlPortTypeQN = wsdlPortType.getQName(); if (portTypeQN.equals(wsdlPortTypeQN)) { portList.add(wsdlPort); }// w w w . j a va 2 s . c o m } } } return portList; }
From source file:org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMinimalMethodMarshaller.java
/** * Unmarshal the return object from the message * * @param packages/* ww w . j av a 2 s . co m*/ * @param message * @param javaTypeClass * @param javaComponentTypeClass * @param isHeader * @param headerNS (only needed if isHeader) * @param headerLocalPart (only needed if isHeader) * @param hasOutputBodyParams (true if the method has out or inout params other * than the return value) * @param ioutputBodyArgIndes (first index of output body argument or -1) * * @return Element * @throws WebService * @throws XMLStreamException */ static Element getReturnElementForDocLitWrappedMinimal(TreeSet<String> packages, Message message, Class javaTypeClass, Class javaComponentTypeClass, boolean isList, boolean isHeader, String headerNS, String headerLocalPart, boolean hasOutputBodyParams, int outputBodyArgIndex) throws WebServiceException, XMLStreamException { // The return object is the first block in the body JAXBBlockContext context = new JAXBBlockContext(packages); // In most cases the entire java object is unmarshalled. // But in some cases, the java object is a series of // elements. boolean unmarshalComponents = false; if (isList || javaComponentTypeClass == null) { context.setProcessType(javaTypeClass); context.setIsxmlList(isList); } else { context.setProcessType(javaComponentTypeClass); unmarshalComponents = true; } Element returnElement = null; if (isHeader) { // In header Block block = message.getHeaderBlock(headerNS, headerLocalPart, context, factory); // Get the business object. We want to return the object that represents the type. returnElement = new Element(block.getBusinessObject(true), block.getQName()); } else { // In Body // Determine how many return elements are present int numBodyBlocks = message.getNumBodyBlocks(); if (outputBodyArgIndex >= 0) { numBodyBlocks = outputBodyArgIndex; } if (!unmarshalComponents) { if (numBodyBlocks == 1) { if (log.isDebugEnabled()) { log.debug("Case A: Not unmarshalling components, and only 1 block"); } // Normal case: Only one body block // We can use the get body block method // that streams the whole block content. Block block = message.getBodyBlock(context, factory); //We look for body block only when the return type associated with operation is not void. //If a null body block is returned in response on a operation that is not void, its a user error. returnElement = new Element(block.getBusinessObject(true), block.getQName()); } else if (numBodyBlocks > 1) { if (log.isDebugEnabled()) { log.debug("Case B: Not unmarshalling components, and multiple blocks"); } // There is only one return element Block block = message.getBodyBlock(0, context, factory); returnElement = new Element(block.getBusinessObject(true), block.getQName()); } } else { if (numBodyBlocks > 0) { if (log.isDebugEnabled()) { log.debug("Case C: unmarshalling components. Number of blocks=" + numBodyBlocks); } // Assume that all the qnames matching the first QName are for the return List<QName> qNames = message.getBodyBlockQNames(); int firstIndex = 0; int lastIndex = 0; QName returnQName = qNames.get(0); if (log.isDebugEnabled()) { log.debug(" returnQName =" + returnQName); } do { lastIndex++; } while (lastIndex < qNames.size() && returnQName.equals(qNames.get(lastIndex))); // Multiple Elements for QName int numElements = lastIndex - firstIndex; if (log.isDebugEnabled()) { log.debug(" number of return blocks=" + numElements); } Object container = makeContainer(javaTypeClass, javaComponentTypeClass, numElements); for (int blockI = firstIndex; blockI < lastIndex; blockI++) { Block block = message.getBodyBlock(blockI, context, factory); Object value = block.getBusinessObject(true); if (value instanceof JAXBElement) { value = ((JAXBElement) value).getValue(); } if (log.isDebugEnabled()) { log.debug(" get return Business object (" + JavaUtils.getObjectIdentity(value) + ") for block " + blockI); } addComponent(container, value, blockI); } returnElement = new Element(container, returnQName); } else { if (log.isDebugEnabled()) { log.debug("Case D: unmarshalling components, but there are no blocks"); } Object container = makeContainer(javaTypeClass, javaComponentTypeClass, 0); QName qName = new QName("", "return"); returnElement = new Element(container, qName); } } //We look for body block only when the return type associated with operation is not void. //If a null body block is returned in response on a operation that has non void return type, its a user error. if (returnElement == null) { if (log.isDebugEnabled()) { log.debug( "Empty Body Block Found in response Message for wsdl Operation defintion that expects an Output"); log.debug("Return type associated with SEI operation is not void, Body Block cannot be null"); } throw ExceptionFactory.makeWebServiceException(Messages.getMessage("MethodMarshallerUtilErr1")); } } if (log.isDebugEnabled()) { log.debug("getReturnElementForDocLitWrappedMinimal " + JavaUtils.getObjectIdentity(returnElement)); } return returnElement; }
From source file:org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.java
/** * Unmarshal the service/system exception from a Message. This is used by all of the * marshallers// www . j a v a 2s. c o m * * @param operationDesc * @param marshalDesc * @param message * @return Throwable * @throws WebServiceException * @throws ClassNotFoundException * @throws IllegalAccessException * @throws InstantiationException * @throws XMLStreamException * @throws InvocationTargetException * @throws NoSuchMethodException */ static Throwable demarshalFaultResponse(OperationDescription operationDesc, MarshalServiceRuntimeDescription marshalDesc, Message message) throws WebServiceException, ClassNotFoundException, IllegalAccessException, InstantiationException, XMLStreamException, InvocationTargetException, NoSuchMethodException { Throwable exception = null; // Get the fault from the message and get the detail blocks (probably one) XMLFault xmlfault = message.getXMLFault(); Block[] detailBlocks = xmlfault.getDetailBlocks(); // If there is only one block, get the element name of that block. QName elementQName = null; if (detailBlocks != null && detailBlocks.length >= 1) { elementQName = detailBlocks[0].getQName(); if (log.isDebugEnabled()) { if (detailBlocks.length > 1) { log.debug("The detail element has multiple child elements. " + "Only the first child is examined to determine if this is a service exception. " + "If this first detail child is mapped to a service exception, " + "the information in other detail children may be ignored. " + "The most common scenario is that the second child is a " + "{http://jax-ws.dev.java.net/}exception element, which is used " + "by some vendors for debugging. "); } } } if (log.isDebugEnabled()) { log.debug("element QName which will be used to find a service exception = " + elementQName); log.debug("XMLFault Dump = " + xmlfault.dump("")); log.debug("OperationDesc Dump =" + operationDesc); } // Use the element name to find the matching FaultDescriptor FaultDescription faultDesc = null; if (elementQName != null) { for (int i = 0; i < operationDesc.getFaultDescriptions().length && faultDesc == null; i++) { FaultDescription fd = operationDesc.getFaultDescriptions()[i]; FaultBeanDesc faultBeanDesc = marshalDesc.getFaultBeanDesc(fd); if (faultBeanDesc != null) { QName tryQName = new QName(faultBeanDesc.getFaultBeanNamespace(), faultBeanDesc.getFaultBeanLocalName()); if (log.isErrorEnabled()) { log.debug(" FaultDescription qname is (" + tryQName + ") and detail element qname is (" + elementQName + ")"); } if (elementQName.equals(tryQName)) { faultDesc = fd; } } } } if (faultDesc == null && elementQName != null) { // If not found, retry the search using just the local name for (int i = 0; i < operationDesc.getFaultDescriptions().length && faultDesc == null; i++) { FaultDescription fd = operationDesc.getFaultDescriptions()[i]; FaultBeanDesc faultBeanDesc = marshalDesc.getFaultBeanDesc(fd); if (faultBeanDesc != null) { String tryName = faultBeanDesc.getFaultBeanLocalName(); if (elementQName.getLocalPart().equals(tryName)) { faultDesc = fd; } } } } if (faultDesc == null) { // This is a system exception if the method does not throw a checked exception or if // the detail block is missing or contains multiple items. exception = createSystemException(xmlfault, message); } else { if (log.isErrorEnabled()) { log.debug("Ready to demarshal service exception. The detail entry name is " + elementQName); } FaultBeanDesc faultBeanDesc = marshalDesc.getFaultBeanDesc(faultDesc); boolean isLegacy = (faultDesc.getFaultInfo() == null || faultDesc.getFaultInfo().length() == 0); // Get the JAXB object from the block JAXBBlockContext blockContext = new JAXBBlockContext(marshalDesc.getPackages()); // Note that faultBean may not be a bean, it could be a primitive Class faultBeanFormalClass; try { faultBeanFormalClass = loadClass(faultBeanDesc.getFaultBeanClassName()); } catch (ClassNotFoundException e) { faultBeanFormalClass = loadClass(faultBeanDesc.getFaultBeanClassName(), operationDesc.getEndpointInterfaceDescription().getEndpointDescription().getAxisService() .getClassLoader()); } // Use "by java type" marshalling if necessary if (blockContext.getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE.BY_CONTEXT_PATH && isNotJAXBRootElement(faultBeanFormalClass, marshalDesc)) { blockContext.setProcessType(faultBeanFormalClass); } // Get the jaxb block and business object Block jaxbBlock = factory.createFrom(detailBlocks[0], blockContext); Object faultBeanObject = jaxbBlock.getBusinessObject(true); // At this point, faultBeanObject is an object that can be rendered as an // element. We want the object that represents the type. if (faultBeanObject instanceof JAXBElement) { faultBeanObject = ((JAXBElement) faultBeanObject).getValue(); } if (log.isErrorEnabled()) { log.debug("Unmarshalled the detail element into a JAXB object"); } // Construct the JAX-WS generated exception that holds the faultBeanObject Class exceptionClass; try { exceptionClass = loadClass(faultDesc.getExceptionClassName()); } catch (ClassNotFoundException e) { exceptionClass = loadClass(faultDesc.getExceptionClassName(), operationDesc.getEndpointInterfaceDescription().getEndpointDescription().getAxisService() .getClassLoader()); } if (log.isErrorEnabled()) { log.debug("Found FaultDescription. The exception name is " + exceptionClass.getName()); } exception = createServiceException(xmlfault.getReason().getText(), exceptionClass, faultBeanObject, faultBeanFormalClass, marshalDesc, isLegacy); } return exception; }
From source file:org.apache.axis2.saaj.SOAPFactoryTest.java
@Validated @Test/*w w w. j a v a 2s .com*/ public void testCreateFault() { try { SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); //SOAPFactory factory = SOAPFactory.newInstance(); SOAPFault sf = factory.createFault("This is the fault reason.", SOAPConstants.SOAP_RECEIVER_FAULT); assertNotNull(sf); assertTrue(sf instanceof SOAPFault); QName fc = sf.getFaultCodeAsQName(); //Expect FaultCode="+SOAPConstants.SOAP_RECEIVER_FAULT Iterator i = sf.getFaultReasonTexts(); if (i == null) { log.info("Call to getFaultReasonTexts() returned null iterator"); } String reason = ""; while (i.hasNext()) { reason += (String) i.next(); } assertNotNull(reason); assertTrue(reason.indexOf("This is the fault reason.") > -1); assertTrue(fc.equals(SOAPConstants.SOAP_RECEIVER_FAULT)); } catch (SOAPException e) { fail("Caught unexpected SOAPException"); } }