📄 symboltable.java
字号:
symbolTablePut(new UndefinedType(qName)); } else { symbolTablePut(new UndefinedElement(qName)); } } } } // createTypeFromRef /** * Populate the symbol table with all of the MessageEntry's from the Definition. * * @param def * @throws IOException */ private void populateMessages(Definition def) throws IOException { Iterator i = def.getMessages().values().iterator(); while (i.hasNext()) { Message message = (Message) i.next(); MessageEntry mEntry = new MessageEntry(message); symbolTablePut(mEntry); } } // populateMessages /** * ensures that a message in a <code><input></code>, <code><output></code>, * or <code><fault></fault> element in an <code><operation></code> * element is valid. In particular, ensures that * <ol> * <li>an attribute <code>message</code> is present (according to the * XML Schema for WSDL 1.1 <code>message</code> is <strong>required</strong> * <p/> * <li>the value of attribute <code>message</code> (a QName) refers to * an already defined message * </ol> * <p/> * <strong>Note</strong>: this method should throw a <code>javax.wsdl.WSDLException</code> rather than * a <code>java.io.IOException</code> * * @param message the message object * @throws IOException thrown, if the message is not valid */ protected void ensureOperationMessageValid(Message message) throws IOException { // make sure the message is not null (i.e. there is an // attribute 'message ') // if (message == null) { throw new IOException( "<input>,<output>, or <fault> in <operation ..> without attribute 'message' found. Attribute 'message' is required."); } // make sure the value of the attribute refers to an // already defined message // if (message.isUndefined()) { throw new IOException( "<input ..>, <output ..> or <fault ..> in <portType> with undefined message found. message name is '" + message.getQName().toString() + "'"); } } /** * ensures that an an element <code><operation></code> within * an element <code><portType><code> is valid. Throws an exception * if the operation is not valid. * <p/> * <strong>Note</strong>: this method should throw a <code>javax.wsdl.WSDLException</code> * rather than a <code>java.io.IOException</code> * * @param operation the operation element * @throws IOException thrown, if the element is not valid. * @throws IllegalArgumentException thrown, if operation is null */ protected void ensureOperationValid(Operation operation) throws IOException { if (operation == null) { throw new IllegalArgumentException( "parameter 'operation' must not be null"); } Input input = operation.getInput(); Message message; if (input != null) { message = input.getMessage(); if (message == null) { throw new IOException( "No 'message' attribute in <input> for operation '" + operation.getName() + "'"); } ensureOperationMessageValid(message); } Output output = operation.getOutput(); if (output != null) { message = output.getMessage(); if (message == null) { throw new IOException( "No 'message' attribute in <output> for operation '" + operation.getName() + "'"); } ensureOperationMessageValid(output.getMessage()); } Map faults = operation.getFaults(); if (faults != null) { Iterator it = faults.values().iterator(); while (it.hasNext()) { Fault fault = (Fault)it.next(); message = fault.getMessage(); if (message == null) { throw new IOException( "No 'message' attribute in <fault> named '" + fault.getName() + "' for operation '" + operation.getName() + "'"); } ensureOperationMessageValid(message); } } } /** * ensures that an an element <code><portType></code> * is valid. Throws an exception if the portType is not valid. * <p/> * <strong>Note</strong>: this method should throw a <code>javax.wsdl.WSDLException</code> * rather than a <code>java.io.IOException</code> * * @param portType the portType element * @throws IOException thrown, if the element is not valid. * @throws IllegalArgumentException thrown, if operation is null */ protected void ensureOperationsOfPortTypeValid(PortType portType) throws IOException { if (portType == null) { throw new IllegalArgumentException( "parameter 'portType' must not be null"); } List operations = portType.getOperations(); // no operations defined ? -> valid according to the WSDL 1.1 schema // if ((operations == null) || (operations.size() == 0)) { return; } // check operations defined in this portType // Iterator it = operations.iterator(); while (it.hasNext()) { Operation operation = (Operation) it.next(); ensureOperationValid(operation); } } /** * Populate the symbol table with all of the PortTypeEntry's from the Definition. * * @param def * @throws IOException */ private void populatePortTypes(Definition def) throws IOException { Iterator i = def.getPortTypes().values().iterator(); while (i.hasNext()) { PortType portType = (PortType) i.next(); // If the portType is undefined, then we're parsing a Definition // that didn't contain a portType, merely a binding that referred // to a non-existent port type. Don't bother with it. if (!portType.isUndefined()) { ensureOperationsOfPortTypeValid(portType); PortTypeEntry ptEntry = new PortTypeEntry(portType); symbolTablePut(ptEntry); } } } // populatePortTypes /** * Create the parameters and store them in the bindingEntry. * * @throws IOException */ private void populateParameters() throws IOException { Iterator it = symbolTable.values().iterator(); while (it.hasNext()) { Vector v = (Vector) it.next(); for (int i = 0; i < v.size(); ++i) { if (v.get(i) instanceof BindingEntry) { BindingEntry bEntry = (BindingEntry) v.get(i); // Skip non-soap bindings if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) { continue; } Binding binding = bEntry.getBinding(); Collection bindOperations = bEntry.getOperations(); PortType portType = binding.getPortType(); HashMap parameters = new HashMap(); Iterator operations = portType.getOperations().iterator(); // get parameters while (operations.hasNext()) { Operation operation = (Operation) operations.next(); // See if the PortType operation has a corresponding // Binding operation and report an error if it doesn't. if (!bindOperations.contains(operation)) { throw new IOException( Messages.getMessage( "emitFailNoMatchingBindOperation01", operation.getName(), portType.getQName().getLocalPart())); } String namespace = portType.getQName().getNamespaceURI(); Parameters parms = getOperationParameters(operation, namespace, bEntry); parameters.put(operation, parms); } bEntry.setParameters(parameters); } } } } // populateParameters /** * For the given operation, this method returns the parameter info conveniently collated. * There is a bit of processing that is needed to write the interface, stub, and skeleton. * Rather than do that processing 3 times, it is done once, here, and stored in the * Parameters object. * * @param operation * @param namespace * @param bindingEntry * @return * @throws IOException */ public Parameters getOperationParameters( Operation operation, String namespace, BindingEntry bindingEntry) throws IOException { Parameters parameters = new Parameters(); // The input and output Vectors of Parameters Vector inputs = new Vector(); Vector outputs = new Vector(); List parameterOrder = operation.getParameterOrdering(); // Handle parameterOrder="", which is techinically illegal if ((parameterOrder != null) && parameterOrder.isEmpty()) { parameterOrder = null; } Input input = operation.getInput(); Output output = operation.getOutput(); parameters.mep = operation.getStyle(); // All input parts MUST be in the parameterOrder list. It is an error otherwise. if (parameterOrder != null && !wrapped) { if (input != null) { Message inputMsg = input.getMessage(); Map allInputs = inputMsg.getParts(); Collection orderedInputs = inputMsg.getOrderedParts(parameterOrder); if (allInputs.size() != orderedInputs.size()) { throw new IOException( Messages.getMessage("emitFail00", operation.getName())); } } } boolean literalInput = false; boolean literalOutput = false; if (bindingEntry != null) { literalInput = (bindingEntry.getInputBodyType(operation) == Use.LITERAL); literalOutput = (bindingEntry.getOutputBodyType(operation) == Use.LITERAL); } // Collect all the input parameters if ((input != null) && (input.getMessage() != null)) { getParametersFromParts(inputs, input.getMessage().getOrderedParts(null), literalInput, operation.getName(), bindingEntry); } // Collect all the output parameters if ((output != null) && (output.getMessage() != null)) { getParametersFromParts(outputs, output.getMessage().getOrderedParts(null), literalOutput, operation.getName(), bindingEntry); } if (parameterOrder != null && !wrapped) { // Construct a list of the parameters in the parameterOrder list, determining the // mode of each parameter and preserving the parameterOrder list. for (int i = 0; i < parameterOrder.size(); ++i) { String name = (String) parameterOrder.get(i); // index in the inputs Vector of the given name, -1 if it doesn't exist. int index = getPartIndex(name, inputs); // index in the outputs Vector of the given name, -1 if it doesn't exist. int outdex = getPartIndex(name, outputs); if (index >= 0) { // The mode of this parameter is either in or inout addInishParm(inputs, outputs, index, outdex, parameters, true); } else if (outdex >= 0) { addOutParm(outputs, outdex, parameters, true); } else { System.err.println(Messages.getMessage("noPart00", name)); } } } // Some special case logic for JAX-RPC, but also to make things // nicer for the user. // If we have a single input and output with the same name // instead of: void echo(StringHolder inout) // Do this: string echo(string in) if (wrapped && (inputs.size() == 1) && (outputs.size() == 1) && Utils.getLastLocalPart(((Parameter) inputs.get(0)).getName()).equals( Utils.getLastLocalPart(((Parameter) outputs.get(0)).getName())) ) { // add the input and make s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -