📄 rpcelement.java
字号:
} if(!JavaUtils.isConvertable(value, sigType, isEncoded)) match = false; } } // This is not the right operation, try the next one. if(!match) { children = new ArrayList(); continue; } // Success!! This is the right one... msgContext.setOperation(operation); return; } catch (SAXException e) { // If there was a problem, try the next one. savedException = e; children = new ArrayList(); continue; } catch (AxisFault e) { // Thrown by getHeadersByName... // If there was a problem, try the next one. savedException = new SAXException(e); children = new ArrayList(); continue; } } } // If we're SOAP 1.2, getting to this point means bad arguments. if (!msgContext.isClient() && soapConstants == SOAPConstants.SOAP12_CONSTANTS) { AxisFault fault = new AxisFault(Constants.FAULT_SOAP12_SENDER, "string", null, null); fault.addFaultSubCode(Constants.FAULT_SUBCODE_BADARGS); throw new SAXException(fault); } if (savedException != null) { throw savedException; } else if (!msgContext.isClient()) { QName faultCode = new QName(Constants.FAULT_SERVER_USER); if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) faultCode = Constants.FAULT_SOAP12_SENDER; AxisFault fault = new AxisFault(faultCode, null, Messages.getMessage("noSuchOperation", name), null, null, null); throw new SAXException(fault); } } if (operations != null) { rpcHandler.setOperation(operations[0]); } // Same logic as above. Don't wrap rpcHandler // if there is no operation wrapper in the message if (operations != null && operations.length > 0 && (operations[0].getStyle() == Style.DOCUMENT)) { context.pushElementHandler(rpcHandler); context.setCurElement(null); } else { context.pushElementHandler(new EnvelopeHandler(rpcHandler)); context.setCurElement(this); } publishToHandler((org.xml.sax.ContentHandler)context); } private List getParams2() { return getParams(new ArrayList()); } private List getParams(List list) { for (int i = 0; children != null && i < children.size(); i++) { Object child = children.get(i); if (child instanceof RPCParam) { list.add(child); } } return list; } /** This gets the FIRST param whose name matches. * !!! Should it return more in the case of duplicates? */ public RPCParam getParam(String name) throws SAXException { if (needDeser) { deserialize(); } List params = getParams2(); for (int i = 0; i < params.size(); i++) { RPCParam param = (RPCParam)params.get(i); if (param.getName().equals(name)) return param; } return null; } public Vector getParams() throws SAXException { if (needDeser) { deserialize(); } return (Vector)getParams(new Vector()); } public void addParam(RPCParam param) { param.setRPCCall(this); initializeChildren(); children.add(param); } protected void outputImpl(SerializationContext context) throws Exception { MessageContext msgContext = context.getMessageContext(); boolean hasOperationElement = (msgContext == null || msgContext.getOperationStyle() == Style.RPC || msgContext.getOperationStyle() == Style.WRAPPED); // When I have MIME and a no-param document WSDL, if I don't check // for no params here, the server chokes with "can't find Body". // because it will be looking for the enclosing element always // found in an RPC-style (and wrapped) request boolean noParams = getParams2().size() == 0; if (hasOperationElement || noParams) { // Set default namespace if appropriate (to avoid prefix mappings // in literal style). Do this only if there is no encodingStyle. if (encodingStyle != null && encodingStyle.equals("")) { context.registerPrefixForURI("", getNamespaceURI()); } context.startElement(new QName(getNamespaceURI(), name), attributes); } if(noParams) { if (children != null) { for (Iterator it = children.iterator(); it.hasNext();) { ((NodeImpl)it.next()).output(context); } } } else { List params = getParams2(); for (int i = 0; i < params.size(); i++) { RPCParam param = (RPCParam)params.get(i); if (!hasOperationElement && encodingStyle != null && encodingStyle.equals("")) { context.registerPrefixForURI("", param.getQName().getNamespaceURI()); } param.serialize(context); } } if (hasOperationElement || noParams) { context.endElement(); } } /** * needHeaderProcessing * @param operation OperationDesc * @param isResponse boolean indicates if request or response message * @return true if the operation description indicates parameters/results * are located in the soap header. */ private boolean needHeaderProcessing(OperationDesc operation, boolean isResponse) { // Search parameters/return to see if any indicate // that instance data is contained in the header. ArrayList paramDescs = operation.getParameters(); if (paramDescs != null) { for (int j=0; j<paramDescs.size(); j++) { ParameterDesc paramDesc = (ParameterDesc) paramDescs.get(j); if ((!isResponse && paramDesc.isInHeader()) || (isResponse && paramDesc.isOutHeader())) { return true; } } } if (isResponse && operation.getReturnParamDesc() != null && operation.getReturnParamDesc().isOutHeader()) { return true; } return false; } /** * needHeaderProcessing * @param operation OperationDesc * @param isResponse boolean indicates if request or response message * @param context DeserializationContext * @param handler RPCHandler used to deserialize parameters * are located in the soap header. */ private void processHeaders(OperationDesc operation, boolean isResponse, DeserializationContext context, RPCHandler handler) throws AxisFault, SAXException { // Inform handler that subsequent elements come from // the header try { handler.setHeaderElement(true); // Get the soap envelope SOAPElement envelope = getParentElement(); while (envelope != null && !(envelope instanceof SOAPEnvelope)) { envelope = envelope.getParentElement(); } if (envelope == null) return; // Find parameters that have instance // data in the header. ArrayList paramDescs = operation.getParameters(); if (paramDescs != null) { for (int j=0; j<paramDescs.size(); j++) { ParameterDesc paramDesc = (ParameterDesc) paramDescs.get(j); if ((!isResponse && paramDesc.isInHeader()) || (isResponse && paramDesc.isOutHeader())) { // Get the headers that match the parameter's // QName Enumeration headers = ((SOAPEnvelope) envelope). getHeadersByName( paramDesc.getQName().getNamespaceURI(), paramDesc.getQName().getLocalPart(), true); // Publish each of the found elements to the // handler. The pushElementHandler and // setCurElement calls are necessary to // have the message element recognized as a // child of the RPCElement. while(headers != null && headers.hasMoreElements()) { context.pushElementHandler(handler); context.setCurElement(null); ((MessageElement) headers.nextElement()). publishToHandler( (org.xml.sax.ContentHandler)context); } } } } // Now do the same processing for the return parameter. if (isResponse && operation.getReturnParamDesc() != null && operation.getReturnParamDesc().isOutHeader()) { ParameterDesc paramDesc = operation.getReturnParamDesc(); Enumeration headers = ((SOAPEnvelope) envelope). getHeadersByName( paramDesc.getQName().getNamespaceURI(), paramDesc.getQName().getLocalPart(), true); while(headers != null && headers.hasMoreElements()) { context.pushElementHandler(handler); context.setCurElement(null); ((MessageElement) headers.nextElement()). publishToHandler((org.xml.sax.ContentHandler)context); } } } finally { handler.setHeaderElement(false); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -