axisservice.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,682 行 · 第 1/5 页
JAVA
1,682 行
* @return name of the port type
* @deprecated use AxisService#getEndpointName() instead.
*/
public String getPortTypeName() {
return endpointName;
}
/**
* @param portTypeName
* @deprecated use AxisService#setEndpointName() instead
*/
public void setPortTypeName(String portTypeName) {
this.endpointName = portTypeName;
}
public String getBindingName() {
return bindingName;
}
public void setBindingName(String bindingName) {
this.bindingName = bindingName;
}
/**
* get the SOAPVersion
*/
public String getSoapNsUri() {
return soapNsUri;
}
public void setSoapNsUri(String soapNsUri) {
this.soapNsUri = soapNsUri;
}
/**
* get the endpointName
*/
public String getEndpointName() {
return endpointName;
}
public void setEndpointName(String endpoint) {
this.endpointName = endpoint;
}
/**
* Constructor AxisService.
*/
public AxisService(String name) {
this();
this.name = name;
}
public void addMessageReceiver(String mepURI, MessageReceiver messageReceiver) {
if (WSDL2Constants.MEP_URI_IN_ONLY.equals(mepURI) ||
WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_ONLY.equals(mepURI) ||
WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_ONLY.equals(mepURI)) {
messageReceivers
.put(WSDL2Constants.MEP_URI_IN_ONLY, messageReceiver);
messageReceivers
.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_ONLY, messageReceiver);
messageReceivers
.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_ONLY, messageReceiver);
} else if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(mepURI) ||
WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_ONLY.equals(mepURI) ||
WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_ONLY.equals(mepURI)) {
messageReceivers
.put(WSDL2Constants.MEP_URI_OUT_ONLY, messageReceiver);
messageReceivers
.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_ONLY, messageReceiver);
messageReceivers
.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_ONLY, messageReceiver);
} else if (WSDL2Constants.MEP_URI_IN_OUT.equals(mepURI) ||
WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OUT.equals(mepURI) ||
WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OUT.equals(mepURI)) {
messageReceivers
.put(WSDL2Constants.MEP_URI_IN_OUT, messageReceiver);
messageReceivers
.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OUT, messageReceiver);
messageReceivers
.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OUT, messageReceiver);
} else if (WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI) ||
WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI) ||
WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI)) {
messageReceivers.put(WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT,
messageReceiver);
messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OPTIONAL_OUT,
messageReceiver);
messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OPTIONAL_OUT,
messageReceiver);
} else if (WSDL2Constants.MEP_URI_OUT_IN.equals(mepURI) ||
WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_IN.equals(mepURI) ||
WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_IN.equals(mepURI)) {
messageReceivers
.put(WSDL2Constants.MEP_URI_OUT_IN, messageReceiver);
messageReceivers
.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_IN, messageReceiver);
messageReceivers
.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_IN, messageReceiver);
} else if (WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI) ||
WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI) ||
WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI)) {
messageReceivers.put(WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN,
messageReceiver);
messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_OPTIONAL_IN,
messageReceiver);
messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_OPTIONAL_IN,
messageReceiver);
} else if (WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI) ||
WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI) ||
WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI)) {
messageReceivers.put(WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY,
messageReceiver);
messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_OUT_ONLY,
messageReceiver);
messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_OUT_ONLY,
messageReceiver);
} else if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI) ||
WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI) ||
WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI)) {
messageReceivers.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
messageReceiver);
messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_IN_ONLY,
messageReceiver);
messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_IN_ONLY,
messageReceiver);
} else {
messageReceivers.put(mepURI, messageReceiver);
}
}
public MessageReceiver getMessageReceiver(String mepURL) {
return (MessageReceiver) messageReceivers.get(mepURL);
}
/**
* Adds module configuration , if there is moduleConfig tag in service.
*
* @param moduleConfiguration
*/
public void addModuleConfig(ModuleConfiguration moduleConfiguration) {
moduleConfigmap.put(moduleConfiguration.getModuleName(), moduleConfiguration);
}
/**
* Add any control operations defined by a Module to this service.
*
* @param module the AxisModule which has just been engaged
* @throws AxisFault if a problem occurs
*/
void addModuleOperations(AxisModule module) throws AxisFault {
HashMap map = module.getOperations();
Collection col = map.values();
PhaseResolver phaseResolver = new PhaseResolver(getAxisConfiguration());
for (Iterator iterator = col.iterator(); iterator.hasNext();) {
AxisOperation axisOperation = copyOperation((AxisOperation) iterator.next());
if (this.getOperation(axisOperation.getName()) == null) {
ArrayList wsamappings = axisOperation.getWSAMappingList();
if (wsamappings != null) {
for (int j = 0, size = wsamappings.size(); j < size; j++) {
String mapping = (String) wsamappings.get(j);
mapActionToOperation(mapping, axisOperation);
}
}
// If we've set the "expose" parameter for this operation, it's normal (non-
// control) and therefore it will appear in generated WSDL. If we haven't,
// it's a control operation and will be ignored at WSDL-gen time.
if (axisOperation.isParameterTrue(DeploymentConstants.TAG_EXPOSE)) {
axisOperation.setControlOperation(false);
} else {
axisOperation.setControlOperation(true);
}
phaseResolver.engageModuleToOperation(axisOperation, module);
this.addOperation(axisOperation);
}
}
}
public void addModuleref(String moduleref) {
moduleRefs.add(moduleref);
}
/*
* (non-Javadoc)
*
* @see org.apache.axis2.description.AxisService#addOperation(org.apache.axis2.description.AxisOperation)
*/
/**
* Method addOperation.
*
* @param axisOperation
*/
public void addOperation(AxisOperation axisOperation) {
axisOperation.setParent(this);
Iterator modules = getEngagedModules().iterator();
while (modules.hasNext()) {
AxisModule module = (AxisModule) modules.next();
try {
axisOperation.engageModule(module);
} catch (AxisFault axisFault) {
log.info(Messages.getMessage("modulealredyengagetoservice", module.getName()));
}
}
if (axisOperation.getMessageReceiver() == null) {
axisOperation.setMessageReceiver(
loadDefaultMessageReceiver(axisOperation.getMessageExchangePattern(), this));
}
if (axisOperation.getInputAction() == null) {
axisOperation.setSoapAction("urn:" + axisOperation.getName().getLocalPart());
}
if (axisOperation.getOutputAction() == null) {
axisOperation.setOutputAction("urn:" + axisOperation.getName().getLocalPart() +
Java2WSDLConstants.RESPONSE);
}
addChild(axisOperation);
String operationName = axisOperation.getName().getLocalPart();
/*
Some times name of the operation can be different from the name of the first child of the SOAPBody.
This will put the correct mapping associating that name with the operation. This will be useful especially for
the SOAPBodyBasedDispatcher
*/
Iterator axisMessageIter = axisOperation.getChildren();
while (axisMessageIter.hasNext()) {
AxisMessage axisMessage = (AxisMessage) axisMessageIter.next();
String messageName = axisMessage.getName();
if (messageName != null && !messageName.equals(operationName)) {
mapActionToOperation(messageName, axisOperation);
}
}
mapActionToOperation(operationName, axisOperation);
String action = axisOperation.getInputAction();
if (action.length() > 0) {
mapActionToOperation(action, axisOperation);
}
ArrayList wsamappings = axisOperation.getWSAMappingList();
if (wsamappings != null) {
for (int j = 0, size = wsamappings.size(); j < size; j++) {
String mapping = (String) wsamappings.get(j);
mapActionToOperation(mapping, axisOperation);
}
}
if (axisOperation.getMessageReceiver() == null) {
axisOperation.setMessageReceiver(
loadDefaultMessageReceiver(
axisOperation.getMessageExchangePattern(), this));
}
}
private MessageReceiver loadDefaultMessageReceiver(String mepURL, AxisService service) {
MessageReceiver messageReceiver;
if (mepURL == null) {
mepURL = WSDL2Constants.MEP_URI_IN_OUT;
}
if (service != null) {
messageReceiver = service.getMessageReceiver(mepURL);
if (messageReceiver != null) {
return messageReceiver;
}
}
if (getAxisConfiguration() != null) {
return getAxisConfiguration().getMessageReceiver(mepURL);
}
return null;
}
/**
* Gets a copy from module operation.
*
* @param axisOperation
* @return Returns AxisOperation.
* @throws AxisFault
*/
private AxisOperation copyOperation(AxisOperation axisOperation) throws AxisFault {
AxisOperation operation =
AxisOperationFactory
.getOperationDescription(axisOperation.getMessageExchangePattern());
operation.setMessageReceiver(axisOperation.getMessageReceiver());
operation.setName(axisOperation.getName());
Iterator parameters = axisOperation.getParameters().iterator();
while (parameters.hasNext()) {
Parameter parameter = (Parameter) parameters.next();
operation.addParameter(parameter);
}
PolicyInclude policyInclude = new PolicyInclude(operation);
PolicyInclude axisOperationPolicyInclude = axisOperation.getPolicyInclude();
if (axisOperationPolicyInclude != null) {
Policy policy = axisOperationPolicyInclude.getPolicy();
if (policy != null) {
policyInclude.setPolicy(axisOperationPolicyInclude.getPolicy());
}
}
operation.setPolicyInclude(policyInclude);
operation.setWsamappingList(axisOperation.getWSAMappingList());
operation.setRemainingPhasesInFlow(axisOperation.getRemainingPhasesInFlow());
operation.setPhasesInFaultFlow(axisOperation.getPhasesInFaultFlow());
operation.setPhasesOutFaultFlow(axisOperation.getPhasesOutFaultFlow());
operation.setPhasesOutFlow(axisOperation.getPhasesOutFlow());
operation.setOutputAction(axisOperation.getOutputAction());
String[] faultActionNames = axisOperation.getFaultActionNames();
for (int i = 0; i < faultActionNames.length; i++) {
operation.addFaultAction(faultActionNames[i],
axisOperation.getFaultAction(faultActionNames[i]));
}
return operation;
}
/*
* (non-Javadoc)
*
* @see org.apache.axis2.description.AxisService#addToengagedModules(javax.xml.namespace.QName)
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?