List of usage examples for javax.xml.namespace QName toString
public String toString()
From source file:org.apache.abdera2.factory.AbstractExtensionFactory.java
/** * Associate a QName with an implementation class. This version of the * method ignores the QName annotation and uses the provided qname */// www . j ava 2 s . c o m protected AbstractExtensionFactory addImpl(QName qname, Class<? extends ElementWrapper> impl) { checkNotNull(qname); checkNotNull(impl); log.debug(String.format("Adding implementation for [%s] : %s", qname.toString(), impl)); impls.put(qname, checkNotNull(constructor(impl), "Missing Element Wrapper Constructor")); return this; }
From source file:org.apache.abdera2.factory.AbstractExtensionFactory.java
private static void addImpls(Object obj, Map<QName, Constructor<? extends ElementWrapper>> map) { if (obj == null) return;/*w w w . ja v a2s . c o m*/ Class<?> _class = obj instanceof Class ? (Class<?>) obj : obj.getClass(); if (_class.isAnnotationPresent(Impls.class)) { log.debug("@Impls annotation found... processing"); Impls impls = _class.getAnnotation(Impls.class); Impl[] imps = impls.value(); for (Impl impl : imps) { log.debug(String.format("Processing >> %s", impl.value().getName())); QName qname = AnnoUtil.qNameFromAnno(impl.qname()); Class<? extends ElementWrapper> _impl = impl.value(); if (qname == null) { if (_impl.isAnnotationPresent(org.apache.abdera2.common.anno.QName.class)) { org.apache.abdera2.common.anno.QName qn = _impl .getAnnotation(org.apache.abdera2.common.anno.QName.class); qname = AnnoUtil.qNameFromAnno(qn); } } if (qname != null) { log.debug(String.format(" Discovered QName: %s", qname.toString())); Constructor<? extends ElementWrapper> con = constructor(_impl); if (con != null) { map.put(qname, con); } else log.debug( " An appropriate ElementWrapper constructor could not be found! Ignoring implementation class"); } else log.debug(" A QName could not be found. Ignoring implementation class"); } } }
From source file:org.apache.airavata.workflow.model.wf.Workflow.java
/** * Binds WSNodes to components//from w w w . j a va2 s.co m * * @throws ComponentException * @throws GraphException */ public void bindComponents() throws ComponentException, GraphException { // This map is to avoid creating multiple instances for the a component Map<WSComponentKey, WSComponent> components = new HashMap<WSComponentKey, WSComponent>(); for (WSNode node : GraphUtil.getWSNodes(this.graph)) { String id = node.getWSDLID(); logger.debug("id: " + id); WsdlDefinitions wsdl = this.wsdlMap.get(id); if (wsdl == null) { // XXX This happens while loading a workflow that is created by // the version 2.2.6_2 or below from GPEL. // Need to look for wsdl manually. // id should be look like // {http://www.extreme.indiana.edu/math/}Adder for (WsdlDefinitions w : this.wsdlMap.values()) { QName name = WSDLUtil.getWSDLQName(w); if (name.toString().equals(id)) { wsdl = w; break; } } } if (wsdl == null) { continue; } try { QName portType = node.getPortTypeQName(); if (portType == null) { // XXX This happens while parsing xwf created by the version // 2.2.6_1 or below. portType = WSDLUtil.getFirstPortTypeQName(wsdl); } String operation = node.getOperationName(); if (operation == null) { // XXX This happens while parsing xwf created by the version // 2.2.6_1 or below. operation = WSDLUtil.getFirstOperationName(wsdl, portType); } WSComponentKey key = new WSComponentKey(id, portType, operation); WSComponent component; if (components.containsKey(key)) { component = components.get(key); } else { component = WSComponentFactory.createComponent(wsdl, portType, operation); components.put(key, component); } node.setComponent(component); } catch (UtilsException e) { logger.error(e.getMessage(), e); } } this.graph.fixParameterNodes(); GraphUtil.propagateTypes(this.graph); }
From source file:org.apache.airavata.workflow.model.wf.Workflow.java
private void generateODEScripts(URI dscUrl, String odeEprEndingWithPort) throws GraphException, ComponentException { this.getGraph().setID(this.getName()); BPELScript script = null;/*from w ww.j a v a2 s . c om*/ script = new BPELScript(this); ODEWSDLTransformer wsdlTransformer = new ODEWSDLTransformer(); script.create(BPELScriptType.BPEL2); this.odeProcess = script.getGpelProcess(); this.odeProcess.setTargetNamespace(WorkflowConstants.LEAD_NS); WsdlDefinitions abstractWorkflowWsdl = script.getWorkflowWSDL().getWsdlDefinitions(); this.odeWorkflowWSDL = abstractWorkflowWsdl; try { this.odeInvokableWSDL = WSDLUtil.stringToWSDL(abstractWorkflowWsdl.xmlString()); wsdlTransformer.makeWorkflowWSDLConcrete(this.odeInvokableWSDL, this.getName(), dscUrl); wsdlTransformer.setOdeLocation(odeEprEndingWithPort, this.getName(), this.odeInvokableWSDL); this.odeWsdlMap = new HashMap<String, WsdlDefinitions>(); Collection<XmlElement> itr = script.getWSDLs(); for (XmlElement xmlElement : itr) { WsdlDefinitions wsdl = WSDLUtil.stringToWSDL(XmlConstants.BUILDER.serializeToString(xmlElement)); String id = xmlElement.attributeValue(NS_XWF, ID_ATTRIBUTE); if (id == null || id.length() == 0) { // xwf up to 2.2.6_2 doesn't have ID. id = WSDLUtil.getWSDLQName(wsdl).toString(); if (null == id || "".equals(id) || (id.startsWith("{") && id.endsWith("}"))) { QName wsdlQname = new QName(NS_XWF.getName(), WSDLUtil.getFirstOperationName(wsdl, WSDLUtil.getFirstPortTypeQName(wsdl))); id = wsdlQname.toString(); wsdl.xml().setAttributeValue("name", wsdlQname.getLocalPart()); } } WSDLCleaner.cleanWSDL(wsdl); this.odeWsdlMap.put(id, wsdl); } } catch (Exception e) { logger.error(e.getMessage(), e); } new ODEBPELTransformer().generateODEBPEL(this.odeProcess, this.getName(), this.odeWorkflowWSDL, this.odeWsdlMap); wsdlTransformer.trasnformToODEWsdls(this.getName(), dscUrl, this.odeWorkflowWSDL, this.odeWsdlMap); String wsdlString = XMLUtil.xmlElementToString(this.odeWorkflowWSDL.xml()); this.tridentWSDL = new WsdlDefinitions(XMLUtil.stringToXmlElement(wsdlString)); new TridentTransformer().process(this.tridentWSDL); }
From source file:org.apache.axis.client.Call.java
/** * Prefill as much info from the WSDL as it can. * Right now it's SOAPAction, operation qname, parameter types * and return type of the Web Service./*from w w w . j a va2 s .c o m*/ * * This methods considers that port name and target endpoint address have * already been set. This is useful when you want to use the same Call * instance for several calls on the same Port * * Note: Not part of JAX-RPC specification. * * @param opName Operation(method) that's going to be invoked * @throws JAXRPCException */ public void setOperation(String opName) { if (service == null) { throw new JAXRPCException(Messages.getMessage("noService04")); } // remove all settings concerning an operation // leave portName and targetEndPoint as they are this.setOperationName(opName); this.setEncodingStyle(null); this.setReturnType(null); this.removeAllParameters(); javax.wsdl.Service wsdlService = service.getWSDLService(); // Nothing to do is the WSDL is not already set. if (wsdlService == null) { return; } Port port = wsdlService.getPort(portName.getLocalPart()); if (port == null) { throw new JAXRPCException(Messages.getMessage("noPort00", "" + portName)); } Binding binding = port.getBinding(); PortType portType = binding.getPortType(); if (portType == null) { throw new JAXRPCException(Messages.getMessage("noPortType00", "" + portName)); } this.setPortTypeName(portType.getQName()); List operations = portType.getOperations(); if (operations == null) { throw new JAXRPCException(Messages.getMessage("noOperation01", opName)); } Operation op = null; for (int i = 0; i < operations.size(); i++, op = null) { op = (Operation) operations.get(i); if (opName.equals(op.getName())) { break; } } if (op == null) { throw new JAXRPCException(Messages.getMessage("noOperation01", opName)); } // Get the SOAPAction //////////////////////////////////////////////////////////////////// List list = port.getExtensibilityElements(); String opStyle = null; BindingOperation bop = binding.getBindingOperation(opName, null, null); if (bop == null) { throw new JAXRPCException(Messages.getMessage("noOperation02", opName)); } list = bop.getExtensibilityElements(); for (int i = 0; list != null && i < list.size(); i++) { Object obj = list.get(i); if (obj instanceof SOAPOperation) { SOAPOperation sop = (SOAPOperation) obj; opStyle = ((SOAPOperation) obj).getStyle(); String action = sop.getSoapActionURI(); if (action != null) { setUseSOAPAction(true); setSOAPActionURI(action); } else { setUseSOAPAction(false); setSOAPActionURI(null); } break; } } // Get the body's namespace URI and encoding style //////////////////////////////////////////////////////////////////// BindingInput bIn = bop.getBindingInput(); if (bIn != null) { list = bIn.getExtensibilityElements(); for (int i = 0; list != null && i < list.size(); i++) { Object obj = list.get(i); if (obj instanceof MIMEMultipartRelated) { MIMEMultipartRelated mpr = (MIMEMultipartRelated) obj; Object part = null; List l = mpr.getMIMEParts(); for (int j = 0; l != null && j < l.size() && part == null; j++) { MIMEPart mp = (MIMEPart) l.get(j); List ll = mp.getExtensibilityElements(); for (int k = 0; ll != null && k < ll.size() && part == null; k++) { part = ll.get(k); if (!(part instanceof SOAPBody)) { part = null; } } } if (null != part) { obj = part; } } if (obj instanceof SOAPBody) { SOAPBody sBody = (SOAPBody) obj; list = sBody.getEncodingStyles(); if (list != null && list.size() > 0) { this.setEncodingStyle((String) list.get(0)); } String ns = sBody.getNamespaceURI(); if (ns != null && !ns.equals("")) { setOperationName(new QName(ns, opName)); } break; } } } Service service = this.getService(); SymbolTable symbolTable = service.getWSDLParser().getSymbolTable(); BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); Parameters parameters = bEntry.getParameters(bop.getOperation()); // loop over paramters and set up in/out params for (int j = 0; j < parameters.list.size(); ++j) { Parameter p = (Parameter) parameters.list.get(j); // Get the QName representing the parameter type QName paramType = Utils.getXSIType(p); // checks whether p is an IN or OUT header // and adds it as a header parameter else // add it to the body ParameterMode mode = modes[p.getMode()]; if (p.isInHeader() || p.isOutHeader()) { this.addParameterAsHeader(p.getQName(), paramType, mode, mode); } else { this.addParameter(p.getQName(), paramType, mode); } } Map faultMap = bEntry.getFaults(); // Get the list of faults for this operation ArrayList faults = (ArrayList) faultMap.get(bop); // check for no faults if (faults == null) { return; } // For each fault, register its information for (Iterator faultIt = faults.iterator(); faultIt.hasNext();) { FaultInfo info = (FaultInfo) faultIt.next(); QName qname = info.getQName(); info.getMessage(); // if no parts in fault, skip it! if (qname == null) { continue; } QName xmlType = info.getXMLType(); Class clazz = getTypeMapping().getClassForQName(xmlType); if (clazz != null) { addFault(qname, clazz, xmlType, true); } else { //we cannot map from the info to a java class //In Axis1.1 and before this was silently swallowed. Now we log it log.debug(Messages.getMessage("clientNoTypemapping", xmlType.toString())); } } // set output type if (parameters.returnParam != null) { // Get the QName for the return Type QName returnType = Utils.getXSIType(parameters.returnParam); QName returnQName = parameters.returnParam.getQName(); // Get the javaType String javaType = null; if (parameters.returnParam.getMIMEInfo() != null) { javaType = "javax.activation.DataHandler"; } else { javaType = parameters.returnParam.getType().getName(); } if (javaType == null) { javaType = ""; } else { javaType = javaType + ".class"; } this.setReturnType(returnType); try { Class clazz = ClassUtils.forName(javaType); this.setReturnClass(clazz); } catch (ClassNotFoundException swallowedException) { //log that this lookup failed, log.debug(Messages.getMessage("clientNoReturnClass", javaType)); } this.setReturnQName(returnQName); } else { this.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID); } boolean hasMIME = Utils.hasMIME(bEntry, bop); Use use = bEntry.getInputBodyType(bop.getOperation()); setOperationUse(use); if (use == Use.LITERAL) { // Turn off encoding setEncodingStyle(null); // turn off XSI types setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); } if (hasMIME || use == Use.LITERAL) { // If it is literal, turn off multirefs. // // If there are any MIME types, turn off multirefs. // I don't know enough about the guts to know why // attachments don't work with multirefs, but they don't. setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); } Style style = Style.getStyle(opStyle, bEntry.getBindingStyle()); if (style == Style.DOCUMENT && symbolTable.isWrapped()) { style = Style.WRAPPED; } setOperationStyle(style); // Operation name if (style == Style.WRAPPED) { // We need to make sure the operation name, which is what we // wrap the elements in, matches the Qname of the parameter // element. Map partsMap = bop.getOperation().getInput().getMessage().getParts(); Part p = (Part) partsMap.values().iterator().next(); QName q = p.getElementName(); setOperationName(q); } else { QName elementQName = Utils.getOperationQName(bop, bEntry, symbolTable); if (elementQName != null) { setOperationName(elementQName); } } // Indicate that the parameters and return no longer // need to be specified with addParameter calls. parmAndRetReq = false; return; }
From source file:org.apache.axis.client.Call.java
/** Invoke an RPC service with a pre-constructed RPCElement. * * Note: Not part of JAX-RPC specification. * * @param body an RPCElement containing all the information about * this call.//from www . j av a 2s .co m * @return a deserialized Java Object containing the return value * @exception AxisFault */ public Object invoke(RPCElement body) throws AxisFault { if (log.isDebugEnabled()) { log.debug("Enter: Call::invoke(RPCElement)"); } /** * Since JAX-RPC requires us to specify a return type if we've set * parameter types, check for this case right now and toss a fault * if things don't look right. */ if (!invokeOneWay && operation != null && operation.getNumParams() > 0 && getReturnType() == null) { // TCK: // Issue an error if the return type was not set, but continue processing. //throw new AxisFault(Messages.getMessage("mustSpecifyReturnType")); log.error(Messages.getMessage("mustSpecifyReturnType")); } SOAPEnvelope reqEnv = new SOAPEnvelope(msgContext.getSOAPConstants(), msgContext.getSchemaVersion()); SOAPEnvelope resEnv = null; Message reqMsg = new Message(reqEnv); Message resMsg = null; Vector resArgs = null; Object result = null; // Clear the output params outParams = new HashMap(); outParamsList = new ArrayList(); // Set both the envelope and the RPCElement encoding styles try { body.setEncodingStyle(getEncodingStyle()); setRequestMessage(reqMsg); reqEnv.addBodyElement(body); reqEnv.setMessageType(Message.REQUEST); invoke(); } catch (Exception e) { entLog.debug(Messages.getMessage("toAxisFault00"), e); throw AxisFault.makeFault(e); } resMsg = msgContext.getResponseMessage(); if (resMsg == null) { if (msgContext.isPropertyTrue(FAULT_ON_NO_RESPONSE, false)) { throw new AxisFault(Messages.getMessage("nullResponse00")); } else { return null; } } resEnv = resMsg.getSOAPEnvelope(); SOAPBodyElement bodyEl = resEnv.getFirstBody(); if (bodyEl == null) { return null; } if (bodyEl instanceof RPCElement) { try { resArgs = ((RPCElement) bodyEl).getParams(); } catch (Exception e) { log.error(Messages.getMessage("exception00"), e); throw AxisFault.makeFault(e); } if (resArgs != null && resArgs.size() > 0) { // If there is no return, then we start at index 0 to create the outParams Map. // If there IS a return, then we start with 1. int outParamStart = 0; // If we have resArgs and the returnType is specified, then the first // resArgs is the return. If we have resArgs and neither returnType // nor paramXMLTypes are specified, then we assume that the caller is // following the non-JAX-RPC AXIS shortcut of not having to specify // the return, in which case we again assume the first resArgs is // the return. // NOTE 1: the non-JAX-RPC AXIS shortcut allows a potential error // to escape notice. If the caller IS NOT following the non-JAX-RPC // shortcut but instead intentionally leaves returnType and params // null (ie., a method that takes no parameters and returns nothing) // then, if we DO receive something it should be an error, but this // code passes it through. The ideal solution here is to require // this caller to set the returnType to void, but there's no void // type in XML. // NOTE 2: we should probably verify that the resArgs element // types match the expected returnType and paramXMLTypes, but I'm not // sure how to do that since the resArgs value is a Java Object // and the returnType and paramXMLTypes are QNames. // GD 03/15/02 : We're now checking for invalid metadata // config at the top of this method, so don't need to do it // here. Check for void return, though. boolean findReturnParam = false; QName returnParamQName = null; if (operation != null) { returnParamQName = operation.getReturnQName(); } if (!XMLType.AXIS_VOID.equals(getReturnType())) { if (returnParamQName == null) { // Assume the first param is the return RPCParam param = (RPCParam) resArgs.get(0); result = param.getObjectValue(); outParamStart = 1; } else { // If the QName of the return value was given to us, look // through the result arguments to find the right name findReturnParam = true; } } // The following loop looks at the resargs and // converts the value to the appropriate return/out parameter // value. If the return value is found, is value is // placed in result. The remaining resargs are // placed in the outParams list (note that if a resArg // is found that does not match a operation parameter qname, // it is still placed in the outParms list). for (int i = outParamStart; i < resArgs.size(); i++) { RPCParam param = (RPCParam) resArgs.get(i); Class javaType = getJavaTypeForQName(param.getQName()); Object value = param.getObjectValue(); // Convert type if needed if (javaType != null && value != null && !javaType.isAssignableFrom(value.getClass())) { value = JavaUtils.convert(value, javaType); } // Check if this parameter is our return // otherwise just add it to our outputs if (findReturnParam && returnParamQName.equals(param.getQName())) { // found it! result = value; findReturnParam = false; } else { outParams.put(param.getQName(), value); outParamsList.add(value); } } // added by scheu: // If the return param is still not found, that means // the returned value did not have the expected qname. // The soap specification indicates that this should be // accepted (and we also fail interop tests if we are strict here). // Look through the outParms and find one that // does not match one of the operation parameters. if (findReturnParam) { Iterator it = outParams.keySet().iterator(); while (findReturnParam && it.hasNext()) { QName qname = (QName) it.next(); ParameterDesc paramDesc = operation.getOutputParamByQName(qname); if (paramDesc == null) { // Doesn't match a paramter, so use this for the return findReturnParam = false; result = outParams.remove(qname); } } } // If we were looking for a particular QName for the return and // still didn't find it, throw an exception if (findReturnParam) { String returnParamName = returnParamQName.toString(); throw new AxisFault(Messages.getMessage("noReturnParam", returnParamName)); } } } else { // This is a SOAPBodyElement, try to treat it like a return value try { result = bodyEl.getValueAsType(getReturnType()); } catch (Exception e) { // just return the SOAPElement result = bodyEl; } } if (log.isDebugEnabled()) { log.debug("Exit: Call::invoke(RPCElement)"); } // Convert type if needed if (operation != null && operation.getReturnClass() != null) { result = JavaUtils.convert(result, operation.getReturnClass()); } return (result); }
From source file:org.apache.axis.configuration.DirProvider.java
/** * retrieve an instance of the named service * @param qname XXX// w ww. j av a 2 s . com * @return XXX * @throws ConfigurationException XXX */ public SOAPService getService(QName qname) throws ConfigurationException { SOAPService service = this.deployment.getService(qname); if (service == null) { throw new ConfigurationException(Messages.getMessage("noService10", qname.toString())); } return service; }
From source file:org.apache.axis.configuration.FileProvider.java
/** * retrieve an instance of the named service * @param qname XXX//from ww w. j ava 2 s . c o m * @return XXX * @throws ConfigurationException XXX */ public SOAPService getService(QName qname) throws ConfigurationException { SOAPService service = deployment.getService(qname); if (service == null) { throw new ConfigurationException(Messages.getMessage("noService10", qname.toString())); } return service; }
From source file:org.apache.axis.deployment.wsdd.WSDDProvider.java
/** * * @param registry XXX//from www . j av a 2 s . c om * @return XXX * @throws Exception XXX */ public static Handler getInstance(QName providerType, WSDDService service, EngineConfiguration registry) throws Exception { if (providerType == null) throw new WSDDException(Messages.getMessage("nullProvider00")); WSDDProvider provider = (WSDDProvider) providers.get(providerType); if (provider == null) { throw new WSDDException(Messages.getMessage("noMatchingProvider00", providerType.toString())); } return provider.newProviderInstance(service, registry); }
From source file:org.apache.axis.encoding.DeserializationContext.java
/** * Get a Deserializer which can turn a given xml type into a given * Java type/*from w w w. j a v a2 s . c om*/ */ public final Deserializer getDeserializer(Class cls, QName xmlType) { if (xmlType == null) return null; DeserializerFactory dserF = null; Deserializer dser = null; try { dserF = (DeserializerFactory) getTypeMapping().getDeserializer(cls, xmlType); } catch (JAXRPCException e) { log.error(Messages.getMessage("noFactory00", xmlType.toString())); } if (dserF != null) { try { dser = (Deserializer) dserF.getDeserializerAs(Constants.AXIS_SAX); } catch (JAXRPCException e) { log.error(Messages.getMessage("noDeser00", xmlType.toString())); } } return dser; }