wsdl11toaxisservicebuilder.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,531 行 · 第 1/5 页
JAVA
1,531 行
binding = getBinding(bindingQName, innerDefinition, list);
if (binding != null) {
break;
}
}
}
if (binding != null) {
break;
}
}
return binding;
}
/**
* Finds a SOAP port given the port map
*/
private Port findPort(Map ports) {
Port port;
for (Iterator portsIterator = ports.values().iterator(); portsIterator.hasNext();) {
port = (Port) portsIterator.next();
List extensibilityElements = port.getExtensibilityElements();
for (int i = 0; i < extensibilityElements.size(); i++) {
Object extElement = extensibilityElements.get(i);
if (extElement instanceof SOAP12Address) {
// SOAP 1.2 address found - return that port and we are done
return port;
}
}
}
for (Iterator portsIterator = ports.values().iterator(); portsIterator
.hasNext();) {
port = (Port) portsIterator.next();
List extensibilityElements = port.getExtensibilityElements();
for (int i = 0; i < extensibilityElements.size(); i++) {
Object extElement = extensibilityElements.get(i);
if (extElement instanceof SOAPAddress) {
// SOAP 1.1 address found - return that port and we are done
return port;
}
}
}
for (Iterator portsIterator = ports.values().iterator(); portsIterator
.hasNext();) {
port = (Port) portsIterator.next();
List extensibilityElements = port.getExtensibilityElements();
for (int i = 0; i < extensibilityElements.size(); i++) {
Object extElement = extensibilityElements.get(i);
if (extElement instanceof HTTPAddress) {
// SOAP 1.1 address found - return that port and we are done
return port;
}
}
}
// None found - just return null.
return null;
}
private Operation findOperation(PortType portType,
BindingOperation wsdl4jBindingOperation) {
Operation op = wsdl4jBindingOperation.getOperation();
String input = null;
if (op != null && op.getInput() != null) {
input = op.getInput().getName();
if (":none".equals(input)) {
input = null;
}
}
String output = null;
if (op != null && op.getOutput() != null) {
output = op.getOutput().getName();
if (":none".equals(output)) {
output = null;
}
}
Operation op2 = portType.getOperation(op.getName(), input, output);
return ((op2 == null) ? op : op2);
}
/**
* Find the fault message relevant to a given name from the fault message
* list
*
* @param name
* @param faultMessages
*/
private AxisMessage findFaultMessage(String name, ArrayList faultMessages) {
AxisMessage tempMessage;
for (int i = 0; i < faultMessages.size(); i++) {
tempMessage = (AxisMessage) faultMessages.get(i);
if (name.equals(tempMessage.getName())) {
return tempMessage;
}
}
return null;
}
/**
* Add the QName for the binding input
*
* @param inMessage
* @param wsdl4jOperation
* @param bindingInput
* @param isWrapped - basically whether the operation is soap/rpc or not
*/
private void addQNameReference(AxisMessage inMessage,
Operation wsdl4jOperation, BindingInput bindingInput,
boolean isWrapped) {
List extensibilityElements = bindingInput.getExtensibilityElements();
Message wsdl4jMessage = wsdl4jOperation.getInput().getMessage();
addQNameReference(inMessage,
wsdl4jOperation,
isWrapped,
extensibilityElements,
wsdl4jMessage,
wsdl4jOperation.getName());
}
/**
* Add the QName for the binding output
*
* @param outMessage
* @param wsdl4jOperation
* @param isWrapped
*/
private void addQNameReference(AxisMessage outMessage,
Operation wsdl4jOperation, BindingOutput bindingOutput,
boolean isWrapped) {
if (bindingOutput != null) {
List extensibilityElements = bindingOutput.getExtensibilityElements();
if (wsdl4jOperation.getOutput() == null) {
return;
}
Message wsdl4jMessage = wsdl4jOperation.getOutput().getMessage();
addQNameReference(outMessage,
wsdl4jOperation,
isWrapped,
extensibilityElements,
wsdl4jMessage,
wsdl4jOperation.getName() + WRAPPED_OUTPUTNAME_SUFFIX);
}
}
private void addQNameReference(AxisMessage message,
Operation wsdl4jOperation,
boolean isWrapped,
List extensibilityElements,
Message wsdl4jMessage,
String rpcOperationName) {
if (isWrapped) {
// we have already validated and process the qname references
// so set it here
// The schema for this should be already made ! Find the
// QName from
// the list and add it - the name for this is just the
message.setElementQName((QName) resolvedRpcWrappedElementMap
.get(rpcOperationName));
message.getAxisOperation().getAxisService().addMessageElementQNameToOperationMapping(
(QName) resolvedRpcWrappedElementMap.get(rpcOperationName),
message.getAxisOperation());
} else {
// now we are sure this is an document literal type element
List bindingPartsList = getPartsListFromSoapBody(extensibilityElements);
if (bindingPartsList == null) {
// i.e user has not given any part list so we go to message and pick the firest part if
// available
if ((wsdl4jMessage.getParts() != null) && (wsdl4jMessage.getParts().size() > 0)) {
if (wsdl4jMessage.getParts().size() == 1) {
Part part = (Part) wsdl4jMessage.getParts().values().iterator().next();
QName elementName = part.getElementName();
if (elementName != null) {
message.setElementQName(elementName);
message.setMessagePartName(part.getName());
AxisOperation operation = message.getAxisOperation();
AxisService service = operation.getAxisService();
service.addMessageElementQNameToOperationMapping(elementName,
operation);
} else {
throw new WSDLProcessingException(
"No element type is defined for message " +
wsdl4jMessage.getQName().getLocalPart());
}
} else {
// user has specified more than one parts with out specifing a part in
// soap body
throw new WSDLProcessingException("More than one part for message " +
wsdl4jMessage.getQName().getLocalPart());
}
} else {
// this is allowed in the spec in this case element qname is null and nothing is send
// in the soap body
message.setElementQName(null);
}
} else {
if (bindingPartsList.size() == 0) {
// we donot have to set the element qname
message.setElementQName(null);
} else if (bindingPartsList.size() == 1) {
Part part = wsdl4jMessage.getPart((String) bindingPartsList.get(0));
if (part != null) {
QName elementName = part.getElementName();
if (elementName != null) {
message.setElementQName(elementName);
message.setMessagePartName(part.getName());
AxisOperation operation = message.getAxisOperation();
AxisService service = operation.getAxisService();
service.addMessageElementQNameToOperationMapping(elementName,
operation);
} else {
throw new WSDLProcessingException(
"No element type is defined for message" +
wsdl4jMessage.getQName().getLocalPart());
}
} else {
throw new WSDLProcessingException("Missing part named "
+ bindingPartsList.get(0) + " ");
}
} else {
// i.e more than one part specified in this case we have
// to send an exception
throw new WSDLProcessingException(
"More than one element part is not allwed in document literal " +
" type binding operation " + wsdl4jOperation.getName());
}
}
}
}
/**
* Add the QName for the binding output
*/
private void addQNameReference(AxisMessage faultMessage,
Message wsdl4jMessage) throws AxisFault {
// for a fault this is trivial - All faults are related directly to a
// message by the name and are supposed to have a single part. So it is
// a matter of copying the right QName from the message part
// get the part
Map parts = wsdl4jMessage.getParts();
if (parts == null || parts.size() == 0) {
String message = "There are no parts"
+ " for fault message : "
+ wsdl4jMessage.getQName();
log.error(message);
throw new WSDLProcessingException(message);
}
Part wsdl4jMessagePart = (Part) parts.values()
.toArray()[0];
if (wsdl4jMessagePart == null) {
throw new WSDLProcessingException();
}
QName name = wsdl4jMessagePart.getElementName();
if (name == null) {
String message = "Part '"
+ wsdl4jMessagePart.getName()
+ "' of fault message '"
+ wsdl4jMessage.getQName()
+ "' must be defined with 'element=QName' and not 'type=QName'";
log.error(message);
throw new AxisFault(message);
}
faultMessage.setMessagePartName(wsdl4jMessagePart.getName());
faultMessage.setElementQName(name);
}
/**
* A util method that returns the SOAP style included in the binding
* operation
*
* @param bindingOp
*/
private String getSOAPStyle(BindingOperation bindingOp) {
List extensibilityElements = bindingOp.getExtensibilityElements();
for (int i = 0; i < extensibilityElements.size(); i++) {
Object extElement = extensibilityElements.get(i);
if (extElement instanceof SOAPOperation) {
return ((SOAPOperation) extElement).getStyle();
} else if (extElement instanceof SOAP12Operation) {
return ((SOAP12Operation) extElement).getStyle();
}
}
return null;
}
/**
* Copy the component from the operation
*
* @param wsdl4jOperation
* @param dif
* @throws AxisFault
*/
private AxisOperation populateOperations(Operation wsdl4jOperation,
PortType wsdl4jPortType, Definition dif)
throws AxisFault {
QName opName = new QName(dif.getTargetNamespace(), wsdl4jOperation.getName());
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?