wsdl11toaxisservicebuilder.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,531 行 · 第 1/5 页
JAVA
1,531 行
// Copy Name Attribute
AxisOperation axisOperation = axisService.getOperation(opName);
if (axisOperation == null) {
String MEP = getMEP(wsdl4jOperation);
axisOperation = AxisOperationFactory.getOperationDescription(MEP);
axisOperation.setName(opName);
// setting the PolicyInclude property of the AxisOperation
PolicyInclude policyInclude = new PolicyInclude(axisOperation);
axisOperation.setPolicyInclude(policyInclude);
}
copyExtensibleElements(wsdl4jOperation.getExtensibilityElements(), dif,
axisOperation, PORT_TYPE_OPERATION);
Input wsdl4jInputMessage = wsdl4jOperation.getInput();
if (isServerSide) {
if (null != wsdl4jInputMessage) {
AxisMessage inMessage = axisOperation
.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
Message message = wsdl4jInputMessage.getMessage();
if (null != message) {
inMessage.setName(message.getQName().getLocalPart());
copyExtensibleElements(message.getExtensibilityElements(),
dif, inMessage, PORT_TYPE_OPERATION_INPUT);
}
// Check if the action is already set as we don't want to
// override it
// with the Default Action Pattern
ArrayList inputActions = axisOperation.getWSAMappingList();
String action = null;
if (inputActions == null || inputActions.size() == 0) {
action = WSDL11ActionHelper
.getActionFromInputElement(dif, wsdl4jPortType,
wsdl4jOperation, wsdl4jInputMessage);
}
if (action != null) {
if (inputActions == null) {
inputActions = new ArrayList();
axisOperation.setWsamappingList(inputActions);
}
inputActions.add(action);
axisService.mapActionToOperation(action, axisOperation);
}
}
// Create an output message and add
Output wsdl4jOutputMessage = wsdl4jOperation.getOutput();
if (null != wsdl4jOutputMessage) {
AxisMessage outMessage = axisOperation
.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
Message message = wsdl4jOutputMessage.getMessage();
if (null != message) {
outMessage.setName(message.getQName().getLocalPart());
copyExtensibleElements(message.getExtensibilityElements(),
dif, outMessage, PORT_TYPE_OPERATION_OUTPUT);
// wsdl:portType -> wsdl:operation -> wsdl:output
}
// Check if the action is already set as we don't want to
// override it
// with the Default Action Pattern
String action = axisOperation.getOutputAction();
if (action == null) {
action = WSDL11ActionHelper.getActionFromOutputElement(dif,
wsdl4jPortType,
wsdl4jOperation,
wsdl4jOutputMessage);
}
if (action != null) {
axisOperation.setOutputAction(action);
}
}
} else {
// for the client side we have to do something that is a bit
// weird. The in message is actually taken from the output
// and the output is taken from the in
if (null != wsdl4jInputMessage) {
AxisMessage inMessage = axisOperation
.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
Message message = wsdl4jInputMessage.getMessage();
if (null != message) {
inMessage.setName(message.getQName().getLocalPart());
copyExtensibleElements(message.getExtensibilityElements(),
dif, inMessage, PORT_TYPE_OPERATION_OUTPUT);
}
// Check if the action is already set as we don't want to
// override it
// with the Default Action Pattern
String action = axisOperation.getOutputAction();
if (action == null) {
action = WSDL11ActionHelper
.getActionFromInputElement(dif, wsdl4jPortType,
wsdl4jOperation, wsdl4jInputMessage);
}
if (action != null) {
axisOperation.setOutputAction(action);
}
}
// Create an output message and add
Output wsdl4jOutputMessage = wsdl4jOperation.getOutput();
if (null != wsdl4jOutputMessage) {
AxisMessage outMessage = axisOperation
.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
Message message = wsdl4jOutputMessage.getMessage();
if (null != message) {
outMessage.setName(message.getQName().getLocalPart());
copyExtensibleElements(message.getExtensibilityElements(),
dif, outMessage, PORT_TYPE_OPERATION_INPUT);
// wsdl:portType -> wsdl:operation -> wsdl:output
}
// Check if the action is already set as we don't want to
// override it
// with the Default Action Pattern
ArrayList inputActions = axisOperation.getWSAMappingList();
String action = null;
if (inputActions == null || inputActions.size() == 0) {
action = WSDL11ActionHelper.getActionFromOutputElement(dif,
wsdl4jPortType,
wsdl4jOperation,
wsdl4jOutputMessage);
}
if (action != null) {
if (inputActions == null) {
inputActions = new ArrayList();
axisOperation.setWsamappingList(inputActions);
}
inputActions.add(action);
}
}
}
Map faults = wsdl4jOperation.getFaults();
Iterator faultKeyIterator = faults.keySet().iterator();
while (faultKeyIterator.hasNext()) {
Fault fault = (Fault) faults.get(faultKeyIterator.next());
AxisMessage axisFaultMessage = new AxisMessage();
Message faultMessage = fault.getMessage();
if (null != faultMessage) {
axisFaultMessage
.setName(faultMessage.getQName().getLocalPart());
copyExtensibleElements(faultMessage.getExtensibilityElements(),
dif, axisFaultMessage, PORT_TYPE_OPERATION_FAULT);
}
// Check if the action is already set as we don't want to override
// it
// with the Default Action Pattern
String action = axisOperation.getFaultAction(fault.getName());
if (action == null) {
action = WSDL11ActionHelper.getActionFromFaultElement(dif,
wsdl4jPortType,
wsdl4jOperation, fault);
}
if (action != null) {
axisOperation.addFaultAction(fault.getName(), action);
}
axisOperation.setFaultMessages(axisFaultMessage);
}
return axisOperation;
}
/**
* Generates a list of wrapper schemas
*
* @param wsdl4jBinding
*/
private Element[] generateWrapperSchema(Map schemaMap,
Binding wsdl4jBinding,
PortType portType) {
List schemaElementList = new ArrayList();
// target namespace for this should be the namespace URI for
// the porttype
String porttypeNamespaceURI = portType.getQName().getNamespaceURI();
// //////////////////////////////////////////////////////////////////////
// if there are any bindings present then we have to process them. we
// have to generate a schema per wsdl4jBinding (that is the safest
// option).
// if not we just resolve to
// the good old port type
// list, in which case we'll generate a schema per porttype
// //////////////////////////////////////////////////////////////////////
// findwrappable operations return either the rpc soap operations or
// Http binding operations
List wrappableBindingOperationsList = findWrappableBindingOperations(wsdl4jBinding);
// this method returns all the new schemas created when processing the rpc messages
Map newSchemaMap = createSchemaForPorttype(porttypeNamespaceURI,
wrappableBindingOperationsList,
schemaMap);
schemaElementList.addAll(newSchemaMap.values());
return (Element[]) schemaElementList
.toArray(new Element[schemaElementList.size()]);
}
/**
* Create a schema by looking at the port type
*
* @param namespaceURI - namespace of the porttype uri we use this only if a user has not specified
* a namespace in soap:body
* @return null if there is no element
*/
private Map createSchemaForPorttype(String namespaceURI,
List operationListToProcess,
Map existingSchemaMap) {
// this map is used to keep the newly added schemas
Map newSchemaMap = new HashMap();
// first of all look at the operations list
// we can return immediately if we get the operations list
// as empty
if (operationListToProcess.isEmpty()) {
return newSchemaMap;
}
// loop through the messages. We'll populate thins map with the relevant
// messages
// from the operations
Map messageQnameToMessageMap = new HashMap();
Map operationToInputMessageMap = new HashMap();
Map operationToOutputMessageMap = new HashMap();
// this contains the required namespace imports. the key in this
// map would be the namaspace URI
Map namespaceImportsMap = null;
// list namespace prefix map. This map will include uri -> prefix
Map namespacePrefixMap = null;
// //////////////////////////////////////////////////////////////////////////////////////////////////
// First thing is to populate the message map with the messages to
// process.
// //////////////////////////////////////////////////////////////////////////////////////////////////
// we really need to do this for a single porttype!
BindingOperation op;
for (int k = 0; k < operationListToProcess.size(); k++) {
op = (BindingOperation) operationListToProcess.get(k);
Input input = op.getOperation().getInput();
Message message;
if (input != null) {
message = input.getMessage();
messageQnameToMessageMap.put(message.getQName(), message);
operationToInputMessageMap.put(op, message);
}
Output output = op.getOperation().getOutput();
if (output != null) {
message = output.getMessage();
messageQnameToMessageMap.put(message.getQName(), message);
operationToOutputMessageMap.put(op, message);
}
// we do not want to process fault messages since they can only be used as document type
// see basic profile 4.4.2
}
// find the xsd prefix
String xsdPrefix = findSchemaPrefix();
// DOM document that will be the ultimate creator
Document document = getDOMDocumentBuilder().newDocument();
Element elementDeclaration;
//loop through the input op map and generate the elements
BindingOperation operation;
for (Iterator operationsIter = operationToInputMessageMap.keySet().iterator();
operationsIter.hasNext();) {
operation = (BindingOperation) operationsIter.next();
elementDeclaration = document.createElementNS(
XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
+ XML_SCHEMA_ELEMENT_LOCAL_NAME);
elementDeclaration.setAttribute(XSD_NAME, operation.getName());
//when creating the inner complex type we have to find the parts list from the binding input
BindingInput bindingInput = operation.getBindingInput();
Message message = (Message) operationToInputMessageMap.get(operation);
if (bindingInput != null) {
Collection partsCollection = null;
if (BINDING_TYPE_SOAP.equals(this.bindingType)) {
// first see the body parts list
List bodyPartsList =
getPartsListFromSoapBody(bindingInput.getExtensibilityElements());
if (bodyPartsList != null) {
partsCollection = message.getOrderedParts(body
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?