Search in sources :

Example 1 with WebResult

use of com.webcohesion.enunciate.modules.jaxws.model.WebResult in project enunciate by stoicflame.

the class ResponseDocumentQNameMethod method exec.

/**
 * Gets the client-side package for the type, type declaration, package, or their string values.
 *
 * @param list The arguments.
 * @return The string value of the client-side package.
 */
public Object exec(List list) throws TemplateModelException {
    if (list.size() < 1) {
        throw new TemplateModelException("The responseDocumentQName method method must have a web method as a parameter.");
    }
    TemplateModel from = (TemplateModel) list.get(0);
    Object unwrapped = FreemarkerUtil.unwrap(from);
    if (!(unwrapped instanceof WebMethod)) {
        throw new TemplateModelException("A web method must be provided.");
    }
    WebMethod webMethod = (WebMethod) unwrapped;
    if (webMethod.getSoapBindingStyle() != SOAPBinding.Style.DOCUMENT || webMethod.getSoapUse() != SOAPBinding.Use.LITERAL) {
        throw new TemplateModelException("No response document qname available for a " + webMethod.getSoapBindingStyle() + "/" + webMethod.getSoapUse() + " web method.");
    }
    if (webMethod.getResponseWrapper() != null) {
        return new QName(webMethod.getResponseWrapper().getElementNamespace(), webMethod.getResponseWrapper().getElementName());
    } else if (webMethod.getSoapParameterStyle() == SOAPBinding.ParameterStyle.BARE) {
        WebResult wr = webMethod.getWebResult();
        if (!wr.isHeader()) {
            return new QName(wr.getTargetNamespace(), wr.getElementName());
        }
    }
    return null;
}
Also used : WebMethod(com.webcohesion.enunciate.modules.jaxws.model.WebMethod) TemplateModelException(freemarker.template.TemplateModelException) QName(javax.xml.namespace.QName) TemplateModel(freemarker.template.TemplateModel) WebResult(com.webcohesion.enunciate.modules.jaxws.model.WebResult)

Aggregations

WebMethod (com.webcohesion.enunciate.modules.jaxws.model.WebMethod)1 WebResult (com.webcohesion.enunciate.modules.jaxws.model.WebResult)1 TemplateModel (freemarker.template.TemplateModel)1 TemplateModelException (freemarker.template.TemplateModelException)1 QName (javax.xml.namespace.QName)1