📄 wsdlutils.java
字号:
CollectionsX.filter(operations, bindingOperation.getExtensibilityElements(), SOAPOperation.class); if (operations.size() == 0) { // exception if no bindings found throw new IllegalArgumentException(msgs.msgNoBindingForOperation(bindingOperation.getName())); } else if (operations.size() > 1) { // exception if multiple bindings found throw new IllegalArgumentException(msgs.msgMultipleBindingsForOperation(bindingOperation.getName())); } else { // retrieve the single element ExtensibilityElement result = (ExtensibilityElement) operations.iterator().next(); return result; } } /** * @return true if the extensibility elements of the given {@link javax.wsdl.BindingInput} contains an instance of {@link javax.wsdl.extensions.http.HTTPUrlEncoded} */ public static boolean useUrlEncoded(BindingInput bindingInput) { Collection<HTTPUrlEncoded> coll = CollectionsX.filter(bindingInput.getExtensibilityElements(), HTTPUrlEncoded.class); return !coll.isEmpty(); } /** * @return true if the extensibility elements of the given {@link javax.wsdl.BindingInput} contains an instance of {@link javax.wsdl.extensions.http.HTTPUrlReplacement} */ public static boolean useUrlReplacement(BindingInput bindingInput) { Collection<HTTPUrlReplacement> coll = CollectionsX.filter(bindingInput.getExtensibilityElements(), HTTPUrlReplacement.class); return !coll.isEmpty(); } /** * @return true if the extensibility elements of the given {@link javax.wsdl.BindingInput} contains an instance of {@link javax.wsdl.extensions.mime.MIMEMultipartRelated} */ public static boolean useMimeMultipartRelated(BindingInput bindingInput) { Collection<MIMEMultipartRelated> coll = CollectionsX.filter(bindingInput.getExtensibilityElements(), MIMEMultipartRelated.class); return !coll.isEmpty(); } /** * @return the {@linkplain javax.wsdl.extensions.mime.MIMEContent#getType() type} of the instance of {@link javax.wsdl.extensions.mime.MIMEContent} * contained in the extensibility element list. Or null if none. * @throws IllegalArgumentException if more than 1 MIMEContent is found. */ public static MIMEContent getMimeContent(List extensibilityElements) { Collection<MIMEContent> coll = CollectionsX.filter(extensibilityElements, MIMEContent.class); if (coll.size() == 0) { return null; } else if (coll.size() > 1) { // exception if multiple contents found throw new IllegalArgumentException(msgs.msgMultipleMimeContent()); } else { // retrieve the single element return coll.iterator().next(); } } /** * Extract the instance of {@link javax.wsdl.extensions.http.HTTPAddress] or {@link javax.wsdl.extensions.soap.SOAPAddress} * from the list of extensibility elements of the given {@link javax.wsdl.Port}. * * @param port * @return an instance of {@link javax.wsdl.extensions.http.HTTPAddress} or {@link javax.wsdl.extensions.soap.SOAPAddress} * @throws IllegalArgumentException if not exactly 1 element is found. */ public static ExtensibilityElement getAddressExtension(Port port) { Collection operations = new ArrayList(); CollectionsX.filter(operations, port.getExtensibilityElements(), HTTPAddress.class); CollectionsX.filter(operations, port.getExtensibilityElements(), SOAPAddress.class); if (operations.size() == 0) { // exception if no bindings found throw new IllegalArgumentException(msgs.msgNoAddressForPort(port.getName())); } else if (operations.size() > 1) { // exception if multiple bindings found throw new IllegalArgumentException(msgs.msgMultipleAddressesForPort(port.getName())); } else { // retrieve the single element ExtensibilityElement result = (ExtensibilityElement) operations.iterator().next(); return result; } } /** * ODE extends the wsdl spec by allowing definition of the HTTP verb at the operation level. * <br/> If you do so, an {@link UnknownExtensibilityElement} will be added to the list of extensibility elements of the {@link javax.wsdl.BindingOperation}. * <br/> This method looks up for such an element and return the value of the verb attribute if the underlying {@link org.w3c.dom.Element} is {@literal <binding xmlns="http://schemas.xmlsoap.org/wsdl/http/"/>} * or null. * * @param bindingOperation */ public static String getOperationVerb(BindingOperation bindingOperation) { final Collection<UnknownExtensibilityElement> unknownExtElements = CollectionsX.filter(bindingOperation.getExtensibilityElements(), UnknownExtensibilityElement.class); for (UnknownExtensibilityElement extensibilityElement : unknownExtElements) { final Element e = extensibilityElement.getElement(); if (Namespaces.ODE_HTTP_EXTENSION_NS.equalsIgnoreCase(e.getNamespaceURI()) && "binding".equals(extensibilityElement.getElement().getLocalName()) && e.hasAttribute("verb")) { return e.getAttribute("verb"); } } return null; } /** * @param fault * @return true if the given fault is bound with the {@link org.apache.ode.utils.Namespaces.ODE_HTTP_EXTENSION_NS}:fault element. */ public static boolean isOdeFault(BindingFault fault) { final Collection<UnknownExtensibilityElement> unknownExtElements = CollectionsX.filter(fault.getExtensibilityElements(), UnknownExtensibilityElement.class); for (UnknownExtensibilityElement extensibilityElement : unknownExtElements) { final Element e = extensibilityElement.getElement(); if (Namespaces.ODE_HTTP_EXTENSION_NS.equalsIgnoreCase(e.getNamespaceURI()) && "fault".equals(extensibilityElement.getElement().getLocalName())) { // name attribute is optional, but if any it must match the fault name if (e.hasAttribute("name")) { return fault.getName().equals(e.getAttribute("name")); } else { return true; } } } return false; } public static Collection<UnknownExtensibilityElement> getHttpHeaders(List extensibilityElements) { final Collection<UnknownExtensibilityElement> unknownExtElements = CollectionsX.filter(extensibilityElements, UnknownExtensibilityElement.class); for (UnknownExtensibilityElement extensibilityElement : unknownExtElements) { final Element e = extensibilityElement.getElement(); // keep only the header elements if (!Namespaces.ODE_HTTP_EXTENSION_NS.equalsIgnoreCase(e.getNamespaceURI()) || !"header".equals(extensibilityElement.getElement().getLocalName())) { unknownExtElements.remove(extensibilityElement); } } return unknownExtElements; } /** * Return the {@link javax.wsdl.Fault} that has the given element as message part. * * @param operation the operation * @param elName the qname to look for * @return the first fault for which the element of message part matches the given qname */ @SuppressWarnings("unchecked") public static Fault inferFault(Operation operation, QName elName) { for (Fault f : (Collection<Fault>) operation.getFaults().values()) { if (f.getMessage() == null) continue; Collection<Part> parts = f.getMessage().getParts().values(); if (parts.isEmpty()) continue; Part p = parts.iterator().next(); if (p.getElementName() == null) continue; if (p.getElementName().equals(elName)) return f; } return null; } /** * ODE extends the wsdl spec by allowing definition of the HTTP verb at the operation level. * <br/>The current implementation implementations allows you to have a {@literal <binding xmlns="http://schemas.xmlsoap.org/wsdl/http/"/>} element * at the port level <strong>and</strong> at the operation level. In such a case the operation's verb overrides the port's verb. * <br/> This method applies the later rule. * <br/> If defined the operation's verb is returned, else the port's verb. * * @param binding * @param bindingOperation * @return If defined the operation's verb is returned, else the port's verb. * @see #getOperationVerb(javax.wsdl.BindingOperation) */ public static String resolveVerb(Binding binding, BindingOperation bindingOperation) { final HTTPBinding httpBinding = (HTTPBinding) WsdlUtils.getBindingExtension(binding); String portVerb = httpBinding != null ? httpBinding.getVerb() : null; String operationVerb = WsdlUtils.getOperationVerb(bindingOperation); return operationVerb != null ? operationVerb : portVerb; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -