📄 axismessagedispatcher.java
字号:
} protected Object refineMethod(MuleEvent event, Call call, Object method) { if (method instanceof String) { // Set a custome method namespace if one is set. This will be used forthe // parameters too String methodNamespace = (String)event.getMessage().getProperty(SoapConstants.METHOD_NAMESPACE_PROPERTY); if (methodNamespace != null) { call.setOperationName(new QName(methodNamespace, method.toString())); } else { call.setOperationName(new QName(method.toString())); } } else if (method instanceof QName) { call.setOperationName((QName)method); method = ((QName)method).getLocalPart(); } else { call.setOperationName(((SoapMethod)method).getName()); } return method; } protected void parseUse(MuleEvent event, Call call) { // Set use: Endcoded/Literal String use = event.getMessage().getStringProperty(AxisConnector.USE, null); if (use != null) { Use u = Use.getUse(use); if (u == null) { throw new IllegalArgumentException( CoreMessages.valueIsInvalidFor(use, AxisConnector.USE).toString()); } else { call.setOperationUse(u); } } } protected void parseStyle(MuleEvent event, Call call) { // Note that Axis has specific rules to how these two variables are // combined. This is handled for us // Set style: RPC/wrapped/Doc/Message String style = event.getMessage().getStringProperty(AxisConnector.STYLE, null); if (style != null) { Style s = Style.getStyle(style); if (s == null) { throw new IllegalArgumentException( CoreMessages.valueIsInvalidFor(style, AxisConnector.STYLE).toString()); } else { call.setOperationStyle(s); } } } protected Object getInitialMethod(MuleEvent event) throws DispatchException { Object method = event.getMessage().getProperty(MuleProperties.MULE_METHOD_PROPERTY); if (method == null) { method = event.getEndpoint().getEndpointURI().getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY); } if (method == null) { throw new DispatchException( SoapMessages.cannotInvokeCallWithoutOperation(), event.getMessage(), event.getEndpoint()); } else if (method instanceof SoapMethod) { synchronized (this) { if (callParameters == null) { callParameters = new HashMap(); } callParameters.put(((SoapMethod)method).getName().getLocalPart(), method); } } return method; } private Object[] getArgs(MuleEvent event) throws TransformerException { Object payload = event.transformMessage(); Object[] args; if (payload instanceof Object[]) { args = (Object[])payload; } else { args = new Object[]{payload}; } if (event.getMessage().getAttachmentNames() != null && event.getMessage().getAttachmentNames().size() > 0) { ArrayList attachments = new ArrayList(); Iterator i = event.getMessage().getAttachmentNames().iterator(); while (i.hasNext()) { attachments.add(event.getMessage().getAttachment((String)i.next())); } ArrayList temp = new ArrayList(Arrays.asList(args)); temp.add(attachments.toArray(new DataHandler[0])); args = temp.toArray(); } return args; } protected void setMessageContextProperties(MuleMessage message, MessageContext ctx) { String temp = ctx.getStrProp(MuleProperties.MULE_CORRELATION_ID_PROPERTY); if (StringUtils.isNotBlank(temp)) { message.setCorrelationId(temp); } temp = ctx.getStrProp(MuleProperties.MULE_CORRELATION_GROUP_SIZE_PROPERTY); if (StringUtils.isNotBlank(temp)) { message.setCorrelationGroupSize(Integer.parseInt(temp)); } temp = ctx.getStrProp(MuleProperties.MULE_CORRELATION_SEQUENCE_PROPERTY); if (StringUtils.isNotBlank(temp)) { message.setCorrelationSequence(Integer.parseInt(temp)); } temp = ctx.getStrProp(MuleProperties.MULE_REPLY_TO_PROPERTY); if (StringUtils.isNotBlank(temp)) { message.setReplyTo(temp); } } protected void setMessageContextAttachments(MuleMessage message, MessageContext ctx) throws Exception { int x = 0; for (Iterator iterator = ctx.getMessage().getAttachments(); iterator.hasNext(); x++) { message.addAttachment(String.valueOf(x), ((AttachmentPart)iterator.next()).getActivationDataHandler()); } } protected static MuleMessage createMessage(Object result, Call call) { if (result == null) { result = NullPayload.getInstance(); } Map props = new HashMap(); Iterator iter = call.getMessageContext().getPropertyNames(); Object key; while (iter.hasNext()) { key = iter.next(); props.put(key, call.getMessageContext().getProperty(key.toString())); } props.put("soap.message", call.getMessageContext().getMessage()); call.clearHeaders(); call.clearOperation(); return new DefaultMuleMessage(result, props); } public String parseSoapAction(String soapAction, QName method, MuleEvent event) { EndpointURI endpointURI = event.getEndpoint().getEndpointURI(); Map properties = new HashMap(); MuleMessage msg = event.getMessage(); for (Iterator iterator = msg.getPropertyNames().iterator(); iterator.hasNext();) { String propertyKey = (String)iterator.next(); properties.put(propertyKey, msg.getProperty(propertyKey)); } properties.put(MuleProperties.MULE_METHOD_PROPERTY, method.getLocalPart()); properties.put("methodNamespace", method.getNamespaceURI()); properties.put("address", endpointURI.getAddress()); properties.put("scheme", endpointURI.getScheme()); properties.put("host", endpointURI.getHost()); properties.put("port", String.valueOf(endpointURI.getPort())); properties.put("path", endpointURI.getPath()); properties.put("hostInfo", endpointURI.getScheme() + "://" + endpointURI.getHost() + (endpointURI.getPort() > -1 ? ":" + String.valueOf(endpointURI.getPort()) : "")); if (event.getService() != null) { properties.put("serviceName", event.getService().getName()); } TemplateParser tp = TemplateParser.createMuleStyleParser(); soapAction = tp.parse(properties, soapAction); if (logger.isDebugEnabled()) { logger.debug("SoapAction for this call is: " + soapAction); } return soapAction; } private void setCallParams(Call call, MuleEvent event, QName method) throws ClassNotFoundException { synchronized (this) { if (callParameters == null) { loadCallParams(event, method.getNamespaceURI()); } } SoapMethod soapMethod = (SoapMethod)event.getMessage() .removeProperty(MuleProperties.MULE_SOAP_METHOD); if (soapMethod == null) { soapMethod = (SoapMethod)callParameters.get(method.getLocalPart()); } if (soapMethod != null) { for (Iterator iterator = soapMethod.getNamedParameters().iterator(); iterator.hasNext();) { NamedParameter parameter = (NamedParameter)iterator.next(); call.addParameter(parameter.getName(), parameter.getType(), parameter.getMode()); } if (soapMethod.getReturnType() != null) { call.setReturnType(soapMethod.getReturnType()); } else if (soapMethod.getReturnClass() != null) { call.setReturnClass(soapMethod.getReturnClass()); } call.setOperationName(soapMethod.getName()); } } private void loadCallParams(MuleEvent event, String namespace) throws ClassNotFoundException { Map methodCalls = (Map)event.getMessage().getProperty(AxisConnector.SOAP_METHODS); if (methodCalls == null) { return; } Map.Entry entry; SoapMethod soapMethod; callParameters = new HashMap(); for (Iterator iterator = methodCalls.entrySet().iterator(); iterator.hasNext();) { entry = (Map.Entry)iterator.next(); if (StringUtils.isEmpty(namespace)) { if (entry.getValue() instanceof List) { soapMethod = new SoapMethod(entry.getKey().toString(), (List)entry.getValue()); } else { soapMethod = new SoapMethod(entry.getKey().toString(), entry.getValue().toString()); } } else { if (entry.getValue() instanceof List) { soapMethod = new SoapMethod(new QName(namespace, entry.getKey().toString()), (List)entry.getValue()); } else { soapMethod = new SoapMethod(new QName(namespace, entry.getKey().toString()), entry.getValue().toString()); } } callParameters.put(soapMethod.getName().getLocalPart(), soapMethod); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -