Methods Summary |
---|
private java.lang.String | fixNull(java.lang.String s)
return s == null ? "" : s;
|
public static Binding | getBinding(Definition def, javax.xml.namespace.QName serviceName, java.lang.String endpointName)
String location = null;
Service svc = def.getService(serviceName);
if (svc == null) {
return null;
}
Port port = svc.getPort(QName.valueOf(endpointName).getLocalPart());
if (port == null) {
return null;
} else {
return port.getBinding();
}
|
private BindingOperation | getBindingOperation(javax.wsdl.Operation interfaceOperation, javax.wsdl.Binding binding)
String inputMsgName = interfaceOperation.getInput() != null
? interfaceOperation.getInput().getName()
: null;
String outputMsgName = interfaceOperation.getOutput() != null
? interfaceOperation.getOutput().getName()
: null;
BindingOperation bindingOperation = binding.getBindingOperation(
interfaceOperation.getName(),
inputMsgName,
outputMsgName
);
if(bindingOperation == null) {
bindingOperation = binding.getBindingOperation(
interfaceOperation.getName(), null, null);
}
return bindingOperation;
|
public java.lang.String | getBindingStyle(java.lang.String operationName)
for (OperationMetaData om : opmds) {
if(operationName.equals(om.getOperationName())) {
return om.getBindingStyle();
}
}
return null;
|
public Definition | getDefinition()
return def;
|
public Message | getFaultMessage(java.lang.String operationName, java.lang.String faultDetailElementName, java.lang.String faultDetailNsUri)
for (OperationMetaData om : opmds) {
if(operationName.equals(om.getOperationName())) {
Map<String,Object> m = om.getFaults();
for(String s : m.keySet()) {
Message msg = ((Fault)m.get(s)).getMessage();
List<Part> orderedParts = msg.getOrderedParts(null);
for(Part p : orderedParts) {
if(match(p.getElementName(),
faultDetailElementName, faultDetailNsUri)) {
return msg;
}
if(match(p.getTypeName(),
faultDetailElementName, faultDetailNsUri)) {
return msg;
}
if(isSimpleType(p) && faultDetailElementName == null) {
return msg;
}
}
}
}
}
return null;
|
public Message | getInputMessage(java.lang.String operationName)
for (OperationMetaData om : opmds) {
if(operationName.equals(om.getOperationName())) {
return om.getInputMessage();
}
}
return null;
|
public int[] | getInputPartBindings(java.lang.String operationName)
for (OperationMetaData om : opmds) {
if(operationName.equals(om.getOperationName())) {
return om.getInputPartBindings();
}
}
return null;
|
private java.util.Set | getInputPartNames(Message msg)
Set set = new HashSet();
if (logger.isLoggable(Level.FINE)) {
logger.fine("Getting input parameters for: "+ msg);
}
if (msg != null) {
Iterator bodyIterator = null;
Map msgParts = msg.getParts();
if (logger.isLoggable(Level.FINE)) {
logger.fine("Message Parts are: "+ msgParts);
}
if (msgParts != null) {
bodyIterator = msgParts.keySet().iterator();
}
// construct a set of expected names
while (bodyIterator != null && bodyIterator.hasNext()) {
String bodyPart = (String) bodyIterator.next();
Part part = msg.getPart(bodyPart);
if (part == null) {
throw new IllegalStateException("WSDL error");
}
QName typeQName = part.getTypeName();
QName elemQName = part.getElementName();
if (typeQName != null) {
// it uses type, so the root node name is the part name
set.add(part.getName());
if (logger.isLoggable(Level.FINE)) {
logger.fine("Added partName: "+ part.getName());
}
} else if (elemQName != null) {
//it uses element, so the root node name is the element name
if (logger.isLoggable(Level.FINE)) {
logger.fine("Added root node: "+ elemQName.getLocalPart());
logger.fine("Part name is : " + part.getName());
}
set.add(elemQName.getLocalPart());
}
}
}
return set;
|
public java.lang.String | getOperationInputName(java.lang.String operationName)
for (OperationMetaData om : opmds) {
if(operationName.equals(om.getOperationName())) {
return om.getOperationInputName();
}
}
return null;
|
public java.lang.String | getOperationName()
return this.operationName;
|
public java.lang.String | getOperationName(javax.xml.soap.SOAPMessage soapMsg)
if (this.operationName != null) {
return this.operationName;
}
List nodeNames = new ArrayList();
try {
javax.xml.soap.SOAPBody soapBody = soapMsg.getSOAPBody();
NodeList nl = soapBody.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node n = nl.item(i);
if (Node.ELEMENT_NODE == n.getNodeType()) {
String nodeName = n.getLocalName();
if (nodeName != null) {
return nodeName;
//nodeNames.add(nodeName);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
for (OperationMetaData om : opmds) {
if (logger.isLoggable(Level.FINEST)) {
logger.finest("Matching for" + om.getOperationName());
}
Set inputs = om.getInputParameters();
if (logger.isLoggable(Level.FINEST)) {
logger.finest("Inputs" + inputs);
logger.finest("Nodes" + nodeNames);
}
if (inputs.containsAll(nodeNames)) {
return om.getOperationName();
}
}
return null;
|
public java.lang.String | getOperationOutputName(java.lang.String operationName)
for (OperationMetaData om : opmds) {
if(operationName.equals(om.getOperationName())) {
return om.getOperationOutputName();
}
}
return null;
|
public static javax.wsdl.Operation[] | getOperations(javax.wsdl.Binding binding)
if (binding != null) {
PortType pt = binding.getPortType();
if (pt != null) {
List l = pt.getOperations();
if (l != null && l.size() > 0) {
return (javax.wsdl.Operation[])
l.toArray(new javax.wsdl.Operation[0]);
}
}
}
return null;
|
public Message | getOutputMessage(java.lang.String operationName)
for (OperationMetaData om : opmds) {
if(operationName.equals(om.getOperationName())) {
return om.getOutputMessage();
}
}
return null;
|
public int[] | getOutputPartBindings(java.lang.String operationName)
for (OperationMetaData om : opmds) {
if(operationName.equals(om.getOperationName())) {
return om.getOutputPartBindings();
}
}
return null;
|
private int[] | getPartBindings(java.util.List extensibleElems, Message message)
List<String> orderedParts = new ArrayList<String>();
for(Part p : (List<Part>)message.getOrderedParts(null)) {
orderedParts.add(p.getName());
}
int partBindings[] = new int[orderedParts.size()]; // all default to SOAPConstants.SOAP_BODY_BINDING
for(ExtensibilityElement extElem : extensibleElems) {
if(extElem instanceof MIMEMultipartRelated) {
MIMEMultipartRelated mpr = (MIMEMultipartRelated) extElem;
for(MIMEPart mp : (List<MIMEPart>) mpr.getMIMEParts()) {
for(ExtensibilityElement mpe : (List<ExtensibilityElement>)mp.getExtensibilityElements()) {
setPartBinding(partBindings, orderedParts, mpe);
}
}
} else {
setPartBinding(partBindings, orderedParts, extElem);
}
}
//Debug
if(logger.isLoggable(Level.FINE)) {
for(int i=0; i<partBindings.length; i++) {
logger.log(Level.FINE, "PartName = " + orderedParts.get(i) + ", PartBinding : " + partBindings[i]);
}
}
return partBindings;
|
private java.lang.String | getStyleFor(javax.wsdl.Binding binding)
String sty = null;
java.util.List extList = binding.getExtensibilityElements();
if (extList != null) {
for (int i = 0; i < extList.size(); i++) {
if ( extList.get(i) instanceof SOAPBinding) {
SOAPBinding sb = (SOAPBinding) extList.get(i);
sty = sb.getStyle();
break;
}
}
}
return sty;
|
private java.lang.String | getStyleFor(javax.wsdl.BindingOperation bo)
String style = null;
java.util.List extList = bo.getExtensibilityElements();
if (extList != null) {
for (int i = 0; i < extList.size(); i++) {
if ( extList.get(i) instanceof SOAPOperation) {
SOAPOperation sa = (SOAPOperation) extList.get(i);
style = sa.getStyle();
break;
}
}
}
return style;
|
private java.lang.String | getStyleFor(javax.wsdl.Operation interfaceOperation, javax.wsdl.Binding binding)
String style = null;
BindingOperation bindingOperation = getBindingOperation(interfaceOperation, binding);
if(bindingOperation != null) {
style = getStyleFor(bindingOperation);
if(style == null) {
style = getStyleFor(binding);
}
}
return style;
|
private boolean | isSimpleType(Part part)
QName parttype = part.getTypeName();
if (parttype != null) {
String s = parttype.getNamespaceURI();
if ( s != null && s.trim().equals("http://www.w3.org/2001/XMLSchema")) {
return true;
}
}
return false;
|
private boolean | match(javax.xml.namespace.QName qName, java.lang.String localName, java.lang.String nsUri)Checks whether the localName & namespaceUri of the qName
matches with the given localName & nsUri.
if(qName == null) {
return false;
}
String qLocalName = fixNull(qName.getLocalPart());
String qNsUri = fixNull(qName.getNamespaceURI());
localName = fixNull(localName);
nsUri = fixNull(nsUri);
if(qLocalName.equals(localName) && qNsUri.equals(nsUri)) {
return true;
}
return false;
|
private Definition | readWSDLDefinition(java.net.URL wsdlLocation)
try {
WSDLFactory mFactory = WSDLFactory.newInstance();
javax.wsdl.xml.WSDLReader mReader = mFactory.newWSDLReader();
return mReader.readWSDL(wsdlLocation.toURI().toString());
} catch(Exception ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex);
return null;
}
|
public void | resolve()Partially resolve the operation name.
1. If there is only one operation, use that as the operation name.
2. If there is more than one operation name, save the input parameter
for matching with the soap message.
3. Since we want to work with any kind of binding, we need to only
consider the abstract WSDL.
if (logger.isLoggable(Level.FINE)) {
logger.fine("Resolving the WSDL for : " + serviceName + " : " + epName);
}
Binding binding = getBinding(def, serviceName, epName);
javax.wsdl.Operation[] ops = getOperations(binding);
if (ops.length < 1) {
throw new RuntimeException("WSDL operation not resolved");
}
if (ops.length == 1) {
this.operationName = ops[0].getName();
}
opmds = new OperationMetaData[ops.length];
int i = 0 ;
for (javax.wsdl.Operation op : ops) {
Message input = null;
OperationMetaData md = new OperationMetaData();
BindingOperation bindingOp = getBindingOperation(op, binding);
if (op.getInput() != null) {
input = op.getInput().getMessage();
md.setInputMessage(input);
md.setOperationInputName(op.getInput().getName());
md.setInputPartBindings(getPartBindings(
bindingOp.getBindingInput().getExtensibilityElements(),
input));
}
Set s = getInputPartNames(input);
md.setOperationName(op.getName());
md.setInputParameters(s);
if(op.getOutput() != null) {
md.setOperationOutputName(op.getOutput().getName());
md.setOutputMessage(op.getOutput().getMessage());
md.setOutputPartBindings(getPartBindings(
bindingOp.getBindingOutput().getExtensibilityElements(),
op.getOutput().getMessage()));
}
md.setBindingStyle(getStyleFor(op, binding));
md.setFaults(op.getFaults());
opmds[i++] = md;
}
|
private void | setPartBinding(int[] partBindings, java.util.List orderedParts, javax.wsdl.extensions.ExtensibilityElement extElem)
if(extElem instanceof SOAPBody) {
SOAPBody body = (SOAPBody) extElem;
List<String> parts = body.getParts();
if(parts != null) {
for(String part : parts) {
int index = orderedParts.indexOf(part);
if(index != -1) {
partBindings[index] = SOAPConstants.SOAP_BODY_BINDING;
}
}
}
} else if(extElem instanceof SOAPHeader) {
SOAPHeader header = (SOAPHeader)extElem;
String part = header.getPart();
if(part != null) {
int index = orderedParts.indexOf(part);
if(index != -1) {
partBindings[index] = SOAPConstants.SOAP_HEADER_BINDING;
}
}
} else if(extElem instanceof MIMEContent) {
MIMEContent mimeContent = (MIMEContent)extElem;
String part = mimeContent.getPart();
if(part != null) {
int index = orderedParts.indexOf(part);
if(index != -1) {
partBindings[index] = SOAPConstants.SOAP_ATTACHMENT_BINDING;
}
}
}
|