List of usage examples for javax.xml.namespace QName getNamespaceURI
public String getNamespaceURI()
Get the Namespace URI of this QName
.
From source file:org.apache.axis.wsdl.toJava.JavaStubWriter.java
/** * Write the body of the binding's stub file. * //from w ww.j av a2s . co m * @param pw * @throws IOException */ protected void writeFileBody(PrintWriter pw) throws IOException { PortType portType = binding.getPortType(); HashSet types = getTypesInPortType(portType); boolean hasMIME = Utils.hasMIME(bEntry); if ((types.size() > 0) || hasMIME) { pw.println(" private java.util.Vector cachedSerClasses = new java.util.Vector();"); pw.println(" private java.util.Vector cachedSerQNames = new java.util.Vector();"); pw.println(" private java.util.Vector cachedSerFactories = new java.util.Vector();"); pw.println(" private java.util.Vector cachedDeserFactories = new java.util.Vector();"); } pw.println(); pw.println(" static org.apache.axis.description.OperationDesc [] _operations;"); pw.println(); writeOperationMap(pw); pw.println(); pw.println(" public " + className + "() throws org.apache.axis.AxisFault {"); pw.println(" this(null);"); pw.println(" }"); pw.println(); pw.println(" public " + className + "(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {"); pw.println(" this(service);"); pw.println(" super.cachedEndpoint = endpointURL;"); pw.println(" }"); pw.println(); pw.println( " public " + className + "(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {"); pw.println(" if (service == null) {"); pw.println(" super.service = new org.apache.axis.client.Service();"); pw.println(" } else {"); pw.println(" super.service = service;"); pw.println(" }"); pw.println(" ((org.apache.axis.client.Service)super.service).setTypeMappingVersion(\"" + emitter.getTypeMappingVersion() + "\");"); List deferredBindings = new ArrayList(); // keep track of how many type mappings we write out int typeMappingCount = 0; if (types.size() > 0) { Iterator it = types.iterator(); while (it.hasNext()) { TypeEntry type = (TypeEntry) it.next(); if (!Utils.shouldEmit(type)) { continue; } // Write out serializer declarations if (typeMappingCount == 0) { writeSerializationDecls(pw, hasMIME, binding.getQName().getNamespaceURI()); } // write the type mapping for this type // writeSerializationInit(pw, type); deferredBindings.add(type); // increase the number of type mappings count typeMappingCount++; } } // Sort the TypeEntry's by their qname. Collections.sort(deferredBindings, new Comparator() { public int compare(Object a, Object b) { TypeEntry type1 = (TypeEntry) a; TypeEntry type2 = (TypeEntry) b; return type1.getQName().toString().compareToIgnoreCase(type2.getQName().toString()); } }); // We need to write out the MIME mapping, even if we don't have // any type mappings if ((typeMappingCount == 0) && hasMIME) { writeSerializationDecls(pw, hasMIME, binding.getQName().getNamespaceURI()); typeMappingCount++; } // track whether the number of bindings exceeds the threshold // that we allow per method. boolean needsMultipleBindingMethods = false; if (deferredBindings.size() < MAXIMUM_BINDINGS_PER_METHOD) { // small number of bindings, just inline them: for (Iterator it = deferredBindings.iterator(); it.hasNext();) { writeSerializationInit(pw, (TypeEntry) it.next()); } } else { needsMultipleBindingMethods = true; int methodCount = calculateBindingMethodCount(deferredBindings); // invoke each of the soon-to-be generated addBindings methods // from the constructor. for (int i = 0; i < methodCount; i++) { pw.println(" addBindings" + i + "();"); } } pw.println(" }"); pw.println(); // emit any necessary methods for assembling binding metadata. if (needsMultipleBindingMethods) { writeBindingMethods(pw, deferredBindings); pw.println(); } pw.println(" protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {"); pw.println(" try {"); pw.println(" org.apache.axis.client.Call _call = super._createCall();"); pw.println(" if (super.maintainSessionSet) {"); pw.println(" _call.setMaintainSession(super.maintainSession);"); pw.println(" }"); pw.println(" if (super.cachedUsername != null) {"); pw.println(" _call.setUsername(super.cachedUsername);"); pw.println(" }"); pw.println(" if (super.cachedPassword != null) {"); pw.println(" _call.setPassword(super.cachedPassword);"); pw.println(" }"); pw.println(" if (super.cachedEndpoint != null) {"); pw.println(" _call.setTargetEndpointAddress(super.cachedEndpoint);"); pw.println(" }"); pw.println(" if (super.cachedTimeout != null) {"); pw.println(" _call.setTimeout(super.cachedTimeout);"); pw.println(" }"); pw.println(" if (super.cachedPortName != null) {"); pw.println(" _call.setPortName(super.cachedPortName);"); pw.println(" }"); pw.println(" java.util.Enumeration keys = super.cachedProperties.keys();"); pw.println(" while (keys.hasMoreElements()) {"); pw.println(" java.lang.String key = (java.lang.String) keys.nextElement();"); pw.println(" _call.setProperty(key, super.cachedProperties.get(key));"); pw.println(" }"); if (typeMappingCount > 0) { pw.println(" // " + Messages.getMessage("typeMap00")); pw.println(" // " + Messages.getMessage("typeMap01")); pw.println(" // " + Messages.getMessage("typeMap02")); pw.println(" // " + Messages.getMessage("typeMap03")); pw.println(" // " + Messages.getMessage("typeMap04")); pw.println(" synchronized (this) {"); pw.println(" if (firstCall()) {"); // Hack alert - we need to establish the encoding style before we register type mappings due // to the fact that TypeMappings key off of encoding style pw.println(" // " + Messages.getMessage("mustSetStyle")); if (bEntry.hasLiteral()) { pw.println(" _call.setEncodingStyle(null);"); } else { Iterator iterator = bEntry.getBinding().getExtensibilityElements().iterator(); while (iterator.hasNext()) { Object obj = iterator.next(); if (obj instanceof SOAPBinding) { pw.println( " _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);"); pw.println( " _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);"); } else if (obj instanceof UnknownExtensibilityElement) { // TODO: After WSDL4J supports soap12, change this code UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj; QName name = unkElement.getElementType(); if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) && name.getLocalPart().equals("binding")) { pw.println( " _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);"); pw.println( " _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP12_ENC);"); } } } } pw.println(" for (int i = 0; i < cachedSerFactories.size(); ++i) {"); pw.println(" java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i);"); pw.println(" javax.xml.namespace.QName qName ="); pw.println(" (javax.xml.namespace.QName) cachedSerQNames.get(i);"); pw.println(" java.lang.Object x = cachedSerFactories.get(i);"); pw.println(" if (x instanceof Class) {"); pw.println(" java.lang.Class sf = (java.lang.Class)"); pw.println(" cachedSerFactories.get(i);"); pw.println(" java.lang.Class df = (java.lang.Class)"); pw.println(" cachedDeserFactories.get(i);"); pw.println(" _call.registerTypeMapping(cls, qName, sf, df, false);"); pw.println(" }"); pw.println(" else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) {"); pw.println( " org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory)"); pw.println(" cachedSerFactories.get(i);"); pw.println( " org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory)"); pw.println(" cachedDeserFactories.get(i);"); pw.println(" _call.registerTypeMapping(cls, qName, sf, df, false);"); pw.println(" }"); pw.println(" }"); pw.println(" }"); pw.println(" }"); } pw.println(" return _call;"); pw.println(" }"); pw.println(" catch (java.lang.Throwable _t) {"); pw.println(" throw new org.apache.axis.AxisFault(\"" + Messages.getMessage("badCall01") + "\", _t);"); pw.println(" }"); pw.println(" }"); pw.println(); List operations = binding.getBindingOperations(); for (int i = 0; i < operations.size(); ++i) { BindingOperation operation = (BindingOperation) operations.get(i); Parameters parameters = bEntry.getParameters(operation.getOperation()); // Get the soapAction from the <soap:operation> String soapAction = ""; String opStyle = null; Iterator operationExtensibilityIterator = operation.getExtensibilityElements().iterator(); for (; operationExtensibilityIterator.hasNext();) { Object obj = operationExtensibilityIterator.next(); if (obj instanceof SOAPOperation) { soapAction = ((SOAPOperation) obj).getSoapActionURI(); opStyle = ((SOAPOperation) obj).getStyle(); break; } else if (obj instanceof UnknownExtensibilityElement) { // TODO: After WSDL4J supports soap12, change this code UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj; QName name = unkElement.getElementType(); if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) && name.getLocalPart().equals("operation")) { if (unkElement.getElement().getAttribute("soapAction") != null) { soapAction = unkElement.getElement().getAttribute("soapAction"); } opStyle = unkElement.getElement().getAttribute("style"); } } } Operation ptOperation = operation.getOperation(); OperationType type = ptOperation.getStyle(); // These operation types are not supported. The signature // will be a string stating that fact. if ((OperationType.NOTIFICATION.equals(type)) || (OperationType.SOLICIT_RESPONSE.equals(type))) { pw.println(parameters.signature); pw.println(); } else { writeOperation(pw, operation, parameters, soapAction, opStyle, type == OperationType.ONE_WAY, i); } } }
From source file:org.apache.axis.wsdl.toJava.JavaStubWriter.java
/** * Method writeOperationMap/* ww w. j a v a 2s . co m*/ * * @param pw */ protected void writeOperationMap(PrintWriter pw) { List operations = binding.getBindingOperations(); pw.println(" static {"); pw.println( " _operations = new org.apache.axis.description.OperationDesc[" + operations.size() + "];"); for (int j = 0, k = 0; j < operations.size(); ++j) { if ((j % OPERDESC_PER_BLOCK) == 0) { k++; pw.println(" _initOperationDesc" + k + "();"); } } for (int i = 0, k = 0; i < operations.size(); ++i) { if ((i % OPERDESC_PER_BLOCK) == 0) { k++; pw.println(" }\n"); pw.println(" private static void _initOperationDesc" + k + "(){"); pw.println(" org.apache.axis.description.OperationDesc oper;"); pw.println(" org.apache.axis.description.ParameterDesc param;"); } BindingOperation operation = (BindingOperation) operations.get(i); Parameters parameters = bEntry.getParameters(operation.getOperation()); // Get the soapAction from the <soap:operation> String opStyle = null; Iterator operationExtensibilityIterator = operation.getExtensibilityElements().iterator(); for (; operationExtensibilityIterator.hasNext();) { Object obj = operationExtensibilityIterator.next(); if (obj instanceof SOAPOperation) { opStyle = ((SOAPOperation) obj).getStyle(); break; } else if (obj instanceof UnknownExtensibilityElement) { // TODO: After WSDL4J supports soap12, change this code UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj; QName name = unkElement.getElementType(); if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) && name.getLocalPart().equals("operation")) { opStyle = unkElement.getElement().getAttribute("style"); } } } Operation ptOperation = operation.getOperation(); OperationType type = ptOperation.getStyle(); // These operation types are not supported. The signature // will be a string stating that fact. if ((OperationType.NOTIFICATION.equals(type)) || (OperationType.SOLICIT_RESPONSE.equals(type))) { pw.println(parameters.signature); pw.println(); } String operName = operation.getName(); String indent = " "; pw.println(indent + "oper = new org.apache.axis.description.OperationDesc();"); pw.println(indent + "oper.setName(\"" + operName + "\");"); // 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); // Set the javaType to the name of the type String javaType = Utils.getParameterTypeName(p); if (javaType != null) { javaType += ".class, "; } else { javaType = "null, "; } // Get the text representing newing a QName for the name and type String paramNameText = Utils.getNewQNameWithLastLocalPart(p.getQName()); String paramTypeText = Utils.getNewQName(paramType); // Generate the addParameter call with the // name qname, typeQName, optional javaType, and mode boolean isInHeader = p.isInHeader(); boolean isOutHeader = p.isOutHeader(); pw.println(" param = new org.apache.axis.description.ParameterDesc(" + paramNameText + ", " + modeStrings[p.getMode()] + ", " + paramTypeText + ", " + javaType + isInHeader + ", " + isOutHeader + ");"); QName itemQName = Utils.getItemQName(p.getType()); if (itemQName != null) { pw.println(" param.setItemQName(" + Utils.getNewQName(itemQName) + ");"); } if (p.isOmittable()) pw.println(" param.setOmittable(true);"); if (p.isNillable()) pw.println(" param.setNillable(true);"); pw.println(" oper.addParameter(param);"); } // set output type Parameter returnParam = parameters.returnParam; if (returnParam != null) { // Get the QName for the return Type QName returnType = Utils.getXSIType(returnParam); // Get the javaType String javaType = Utils.getParameterTypeName(returnParam); if (javaType == null) { javaType = ""; } else { javaType += ".class"; } pw.println(" oper.setReturnType(" + Utils.getNewQName(returnType) + ");"); pw.println(" oper.setReturnClass(" + javaType + ");"); QName returnQName = returnParam.getQName(); if (returnQName != null) { pw.println(" oper.setReturnQName(" + Utils.getNewQNameWithLastLocalPart(returnQName) + ");"); } if (returnParam.isOutHeader()) { pw.println(" oper.setReturnHeader(true);"); } QName itemQName = Utils.getItemQName(returnParam.getType()); if (itemQName != null) { pw.println(" param = oper.getReturnParamDesc();"); pw.println(" param.setItemQName(" + Utils.getNewQName(itemQName) + ");"); } } else { pw.println(" oper.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);"); } boolean hasMIME = Utils.hasMIME(bEntry, operation); Style style = Style.getStyle(opStyle, bEntry.getBindingStyle()); Use use = bEntry.getInputBodyType(operation.getOperation()); if ((style == Style.DOCUMENT) && symbolTable.isWrapped()) { style = Style.WRAPPED; } if (!hasMIME) { pw.println(" oper.setStyle(" + styles.get(style) + ");"); pw.println(" oper.setUse(" + uses.get(use) + ");"); } // Register fault/exception information for this operation writeFaultInfo(pw, operation); pw.println(indent + "_operations[" + i + "] = oper;"); pw.println(""); } pw.println(" }"); }
From source file:org.apache.axis.wsdl.toJava.JavaStubWriter.java
/** * In the stub constructor, write the serializer code for the complex types. * //from ww w . j a va 2s . c o m * @param pw * @param hasMIME * @param namespace */ protected void writeSerializationDecls(PrintWriter pw, boolean hasMIME, String namespace) { pw.println(" java.lang.Class cls;"); pw.println(" javax.xml.namespace.QName qName;"); pw.println(" javax.xml.namespace.QName qName2;"); pw.println( " java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class;"); pw.println( " java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class;"); pw.println( " java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class;"); pw.println( " java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class;"); pw.println( " java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class;"); pw.println( " java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class;"); pw.println( " java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class;"); pw.println( " java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class;"); pw.println( " java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class;"); pw.println( " java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class;"); if (hasMIME) { pw.println( " java.lang.Class mimesf = org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory.class;"); pw.println( " java.lang.Class mimedf = org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory.class;"); pw.println(); QName qname = new QName(namespace, "DataHandler"); pw.println(" qName = new javax.xml.namespace.QName(\"" + qname.getNamespaceURI() + "\", \"" + qname.getLocalPart() + "\");"); pw.println(" cachedSerQNames.add(qName);"); pw.println(" cls = javax.activation.DataHandler.class;"); pw.println(" cachedSerClasses.add(cls);"); pw.println(" cachedSerFactories.add(mimesf);"); pw.println(" cachedDeserFactories.add(mimedf);"); pw.println(); } }
From source file:org.apache.axis.wsdl.toJava.JavaStubWriter.java
/** * Method writeSerializationInit// w w w. j av a 2 s. c o m * * @param pw * @param type */ protected void writeSerializationInit(PrintWriter pw, TypeEntry type) { QName qname = type.getQName(); pw.println(" qName = new javax.xml.namespace.QName(\"" + qname.getNamespaceURI() + "\", \"" + qname.getLocalPart() + "\");"); pw.println(" cachedSerQNames.add(qName);"); pw.println(" cls = " + type.getName() + ".class;"); pw.println(" cachedSerClasses.add(cls);"); if (type.getName().endsWith("[]")) { if (SchemaUtils.isListWithItemType(type.getNode())) { pw.println(" cachedSerFactories.add(simplelistsf);"); pw.println(" cachedDeserFactories.add(simplelistdf);"); } else { // We use a custom serializer if WSDL told us the component type of the array. // Both factories must be an instance, so we create a ArrayDeserializerFactory if (type.getComponentType() != null) { QName ct = type.getComponentType(); QName name = type.getItemQName(); pw.println(" qName = new javax.xml.namespace.QName(\"" + ct.getNamespaceURI() + "\", \"" + ct.getLocalPart() + "\");"); if (name != null) { pw.println(" qName2 = new javax.xml.namespace.QName(\"" + name.getNamespaceURI() + "\", \"" + name.getLocalPart() + "\");"); } else { pw.println(" qName2 = null;"); } pw.println( " cachedSerFactories.add(new org.apache.axis.encoding.ser.ArraySerializerFactory(qName, qName2));"); pw.println( " cachedDeserFactories.add(new org.apache.axis.encoding.ser.ArrayDeserializerFactory());"); } else { pw.println(" cachedSerFactories.add(arraysf);"); pw.println(" cachedDeserFactories.add(arraydf);"); } } } else if ((type.getNode() != null) && (Utils.getEnumerationBaseAndValues(type.getNode(), symbolTable) != null)) { pw.println(" cachedSerFactories.add(enumsf);"); pw.println(" cachedDeserFactories.add(enumdf);"); } else if (type.isSimpleType()) { pw.println( " cachedSerFactories.add(org.apache.axis.encoding.ser.BaseSerializerFactory.createFactory(" + "org.apache.axis.encoding.ser.SimpleSerializerFactory.class, cls, qName));"); pw.println( " cachedDeserFactories.add(org.apache.axis.encoding.ser.BaseDeserializerFactory.createFactory(" + "org.apache.axis.encoding.ser.SimpleDeserializerFactory.class, cls, qName));"); } else if (type.getBaseType() != null) { // serializers are not required for types derived from base types // java type to qname mapping is anyway established by default // note that we have to add null to the serfactories vector to // keep the order of other entries, this is not going to screw // up because if type mapping returns null for a serialization // factory, it is assumed to be not-defined and the delegate // will be checked, the end delegate is DefaultTypeMappingImpl // that'll get it right with the base type name pw.println(" cachedSerFactories.add(null);"); pw.println(" cachedDeserFactories.add(simpledf);"); } else { pw.println(" cachedSerFactories.add(beansf);"); pw.println(" cachedDeserFactories.add(beandf);"); } pw.println(); }
From source file:org.apache.axis.wsdl.toJava.JavaStubWriter.java
/** * Write the stub code for the given operation. * /*from www. j a va2 s . co m*/ * @param pw * @param operation * @param parms * @param soapAction * @param opStyle * @param oneway * @param opIndex */ protected void writeOperation(PrintWriter pw, BindingOperation operation, Parameters parms, String soapAction, String opStyle, boolean oneway, int opIndex) { writeComment(pw, operation.getDocumentationElement(), true); if (parms.signature == null) { return; } pw.println(parms.signature + " {"); pw.println(" if (super.cachedEndpoint == null) {"); pw.println(" throw new org.apache.axis.NoEndPointException();"); pw.println(" }"); pw.println(" org.apache.axis.client.Call _call = createCall();"); pw.println(" _call.setOperation(_operations[" + opIndex + "]);"); // SoapAction if (soapAction != null) { pw.println(" _call.setUseSOAPAction(true);"); pw.println(" _call.setSOAPActionURI(\"" + soapAction + "\");"); } boolean hasMIME = Utils.hasMIME(bEntry, operation); // Encoding: literal or encoded use. Use use = bEntry.getInputBodyType(operation.getOperation()); if (use == Use.LITERAL) { // Turn off encoding pw.println(" _call.setEncodingStyle(null);"); // turn off XSI types pw.println(" _call.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. pw.println(" _call.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; } Iterator iterator = bEntry.getBinding().getExtensibilityElements().iterator(); while (iterator.hasNext()) { Object obj = iterator.next(); if (obj instanceof SOAPBinding) { pw.println(" _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);"); } else if (obj instanceof UnknownExtensibilityElement) { // TODO: After WSDL4J supports soap12, change this code UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj; QName name = unkElement.getElementType(); if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) && name.getLocalPart().equals("binding")) { pw.println( " _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);"); } } } // 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 = operation.getOperation().getInput().getMessage().getParts(); Iterator i = partsMap.values().iterator(); QName q = null; while (q == null && i.hasNext()) { Part p = (Part) i.next(); q = p.getElementName(); } if (q != null) { pw.println(" _call.setOperationName(" + Utils.getNewQName(q) + ");"); } else { log.warn(Messages.getMessage("missingPartsForMessage00", operation.getOperation().getInput().getMessage().getQName().toString())); } } else { QName elementQName = Utils.getOperationQName(operation, bEntry, symbolTable); if (elementQName != null) { pw.println(" _call.setOperationName(" + Utils.getNewQName(elementQName) + ");"); } } pw.println(); // Set the headers pw.println(" setRequestHeaders(_call);"); // Set the attachments pw.println(" setAttachments(_call);"); // Set DIME flag if needed if (bEntry.isOperationDIME(operation.getOperation().getName())) { pw.println( " _call.setProperty(_call.ATTACHMENT_ENCAPSULATION_FORMAT, _call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);"); } // Invoke the operation if (oneway) { pw.print(" _call.invokeOneWay("); } else { pw.print(" try {"); pw.print(" java.lang.Object _resp = _call.invoke("); } pw.print("new java.lang.Object[] {"); writeParameters(pw, parms); pw.println("});"); pw.println(); if (!oneway) { writeResponseHandling(pw, parms); } pw.println(" }"); pw.println(); }
From source file:org.apache.axis.wsdl.toJava.Utils.java
/** * If the specified node represents a supported JAX-RPC enumeration, * a Vector is returned which contains the base type and the enumeration values. * The first element in the vector is the base type (an TypeEntry). * Subsequent elements are values (Strings). * If this is not an enumeration, null is returned. * * @param node/* w w w . j a v a 2 s.com*/ * @param symbolTable * @return */ public static Vector getEnumerationBaseAndValues(Node node, SymbolTable symbolTable) { if (node == null) { return null; } // If the node kind is an element, dive into it. QName nodeKind = Utils.getNodeQName(node); if ((nodeKind != null) && nodeKind.getLocalPart().equals("element") && Constants.isSchemaXSD(nodeKind.getNamespaceURI())) { NodeList children = node.getChildNodes(); Node simpleNode = null; for (int j = 0; (j < children.getLength()) && (simpleNode == null); j++) { QName simpleKind = Utils.getNodeQName(children.item(j)); if ((simpleKind != null) && simpleKind.getLocalPart().equals("simpleType") && Constants.isSchemaXSD(simpleKind.getNamespaceURI())) { simpleNode = children.item(j); node = simpleNode; } } } // Get the node kind, expecting a schema simpleType nodeKind = Utils.getNodeQName(node); if ((nodeKind != null) && nodeKind.getLocalPart().equals("simpleType") && Constants.isSchemaXSD(nodeKind.getNamespaceURI())) { // Under the simpleType there should be a restriction. // (There may be other #text nodes, which we will ignore). NodeList children = node.getChildNodes(); Node restrictionNode = null; for (int j = 0; (j < children.getLength()) && (restrictionNode == null); j++) { QName restrictionKind = Utils.getNodeQName(children.item(j)); if ((restrictionKind != null) && restrictionKind.getLocalPart().equals("restriction") && Constants.isSchemaXSD(restrictionKind.getNamespaceURI())) { restrictionNode = children.item(j); } } // The restriction node indicates the type being restricted // (the base attribute contains this type). // The base type must be a simple type, and not boolean TypeEntry baseEType = null; if (restrictionNode != null) { QName baseType = Utils.getTypeQName(restrictionNode, new BooleanHolder(), false); baseEType = symbolTable.getType(baseType); if (baseEType != null) { String javaName = baseEType.getName(); if (javaName.equals("boolean") || !SchemaUtils.isSimpleSchemaType(baseEType.getQName())) { baseEType = null; } } } // Process the enumeration elements underneath the restriction node if ((baseEType != null) && (restrictionNode != null)) { Vector v = new Vector(); NodeList enums = restrictionNode.getChildNodes(); for (int i = 0; i < enums.getLength(); i++) { QName enumKind = Utils.getNodeQName(enums.item(i)); if ((enumKind != null) && enumKind.getLocalPart().equals("enumeration") && Constants.isSchemaXSD(enumKind.getNamespaceURI())) { // Put the enum value in the vector. Node enumNode = enums.item(i); String value = Utils.getAttribute(enumNode, "value"); if (value != null) { v.add(value); } } } // is this really an enumeration? if (v.isEmpty()) { return null; } // The first element in the vector is the base type (an TypeEntry). v.add(0, baseEType); return v; } } return null; }
From source file:org.apache.axis.wsdl.toJava.Utils.java
/** * Return the operation QName. The namespace is determined from * the soap:body namespace, if it exists, otherwise it is "". * * @param bindingOper the operation// www. ja v a 2 s. c o m * @param bEntry the symbol table binding entry * @param symbolTable SymbolTable * @return the operation QName */ public static QName getOperationQName(BindingOperation bindingOper, BindingEntry bEntry, SymbolTable symbolTable) { Operation operation = bindingOper.getOperation(); String operationName = operation.getName(); // For the wrapped case, use the part element's name...which is // is the same as the operation name, but may have a different // namespace ? // example: // <part name="paramters" element="ns:myelem"> if ((bEntry.getBindingStyle() == Style.DOCUMENT) && symbolTable.isWrapped()) { Input input = operation.getInput(); if (input != null) { Map parts = input.getMessage().getParts(); if ((parts != null) && !parts.isEmpty()) { Iterator i = parts.values().iterator(); Part p = (Part) i.next(); return p.getElementName(); } } } String ns = null; // Get a namespace from the soap:body tag, if any // example: // <soap:body namespace="this_is_what_we_want" ..> BindingInput bindInput = bindingOper.getBindingInput(); if (bindInput != null) { Iterator it = bindInput.getExtensibilityElements().iterator(); while (it.hasNext()) { ExtensibilityElement elem = (ExtensibilityElement) it.next(); if (elem instanceof SOAPBody) { SOAPBody body = (SOAPBody) elem; ns = body.getNamespaceURI(); if (bEntry.getInputBodyType(operation) == Use.ENCODED && (ns == null || ns.length() == 0)) { log.warn(Messages.getMessage("badNamespaceForOperation00", bEntry.getName(), operation.getName())); } break; } else if (elem instanceof MIMEMultipartRelated) { Object part = null; javax.wsdl.extensions.mime.MIMEMultipartRelated mpr = (javax.wsdl.extensions.mime.MIMEMultipartRelated) elem; List l = mpr.getMIMEParts(); for (int j = 0; (l != null) && (j < l.size()) && (part == null); j++) { javax.wsdl.extensions.mime.MIMEPart mp = (javax.wsdl.extensions.mime.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) { SOAPBody body = (SOAPBody) part; ns = body.getNamespaceURI(); if (bEntry.getInputBodyType(operation) == Use.ENCODED && (ns == null || ns.length() == 0)) { log.warn(Messages.getMessage("badNamespaceForOperation00", bEntry.getName(), operation.getName())); } break; } else { part = null; } } } } else if (elem instanceof UnknownExtensibilityElement) { // TODO: After WSDL4J supports soap12, change this code UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) elem; QName name = unkElement.getElementType(); if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) && name.getLocalPart().equals("body")) { ns = unkElement.getElement().getAttribute("namespace"); } } } } // If we didn't get a namespace from the soap:body, then // use "". We should probably use the targetNamespace, // but the target namespace of what? binding? portType? // Also, we don't have enough info for to get it. if (ns == null) { ns = ""; } return new QName(ns, operationName); }
From source file:org.apache.axis.wsdl.toJava.Utils.java
/** * Return the SOAPAction (if any) of this binding operation * * @param bindingOper the operation to look at * @return the SOAPAction or null if not found *///w w w . j a v a2s. co m public static String getOperationSOAPAction(BindingOperation bindingOper) { // Find the SOAPAction. List elems = bindingOper.getExtensibilityElements(); Iterator it = elems.iterator(); boolean found = false; String action = null; while (!found && it.hasNext()) { ExtensibilityElement elem = (ExtensibilityElement) it.next(); if (elem instanceof SOAPOperation) { SOAPOperation soapOp = (SOAPOperation) elem; action = soapOp.getSoapActionURI(); found = true; } else if (elem instanceof UnknownExtensibilityElement) { // TODO: After WSDL4J supports soap12, change this code UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) elem; QName name = unkElement.getElementType(); if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP) && name.getLocalPart().equals("operation")) { action = unkElement.getElement().getAttribute("soapAction"); found = true; } } } return action; }
From source file:org.apache.axis.wsdl.toJava.Utils.java
/** * Common code for generating a QName in emitted code. Note that there's * no semicolon at the end, so we can use this in a variety of contexts. * * @param qname//from www . j av a2 s. c o m * @return */ public static String getNewQName(javax.xml.namespace.QName qname) { return "new javax.xml.namespace.QName(\"" + qname.getNamespaceURI() + "\", \"" + qname.getLocalPart() + "\")"; }
From source file:org.apache.axis.wsdl.toJava.Utils.java
public static String getNewQNameWithLastLocalPart(javax.xml.namespace.QName qname) { return "new javax.xml.namespace.QName(\"" + qname.getNamespaceURI() + "\", \"" + getLastLocalPart(qname.getLocalPart()) + "\")"; }