Search in sources :

Example 1 with MarkupBuilder

use of groovy.xml.MarkupBuilder in project ratpack by ratpack.

the class Markup method render.

@Override
public void render(Context context) throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    OutputStreamWriter writer = new OutputStreamWriter(out, CharsetUtil.encoder(getEncoding()));
    MarkupBuilder markupBuilder = new MarkupBuilder(writer);
    ClosureUtil.configureDelegateFirst(markupBuilder, markupBuilder, getDefinition());
    context.getResponse().contentType(getContentType()).send(out.toByteArray());
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) MarkupBuilder(groovy.xml.MarkupBuilder) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 2 with MarkupBuilder

use of groovy.xml.MarkupBuilder in project service-proxy by membrane.

the class WebServiceExplorerInterceptor method generateSampleRequest.

private String generateSampleRequest(final String portName, final String operationName, final String bindingName, final Definitions w) {
    StringWriter writer = new StringWriter();
    SOARequestCreator creator = new SOARequestCreator(w, new RequestTemplateCreator(), new MarkupBuilder(writer));
    creator.createRequest(portName, operationName, bindingName);
    return writer.toString();
}
Also used : RequestTemplateCreator(com.predic8.wstool.creator.RequestTemplateCreator) StringWriter(java.io.StringWriter) MarkupBuilder(groovy.xml.MarkupBuilder) SOARequestCreator(com.predic8.wstool.creator.SOARequestCreator)

Example 3 with MarkupBuilder

use of groovy.xml.MarkupBuilder in project groovy by apache.

the class ServletBinding method lazyInit.

private void lazyInit() {
    if (initialized)
        return;
    initialized = true;
    HttpServletResponse response = (HttpServletResponse) super.getVariable("response");
    ServletOutput output = new ServletOutput(response);
    super.setVariable("out", output.getWriter());
    super.setVariable("sout", output.getOutputStream());
    MarkupBuilder builder = new MarkupBuilder(output.getWriter());
    builder.setExpandEmptyElements(true);
    super.setVariable("html", builder);
    try {
        // load using reflection to avoid needing a hard requirement on groovy-json for those not needing JSON support
        Class jsonBuilderClass = this.getClass().getClassLoader().loadClass("groovy.json.StreamingJsonBuilder");
        Constructor writerConstructor = getWriterConstructor(jsonBuilderClass);
        super.setVariable("json", writerConstructor.newInstance(output.getWriter()));
    } catch (Throwable t) {
        t.printStackTrace();
    }
    // bind forward method
    MethodClosure c = new MethodClosure(this, "forward");
    super.setVariable("forward", c);
    // bind include method
    c = new MethodClosure(this, "include");
    super.setVariable("include", c);
    // bind redirect method
    c = new MethodClosure(this, "redirect");
    super.setVariable("redirect", c);
}
Also used : Constructor(java.lang.reflect.Constructor) HttpServletResponse(javax.servlet.http.HttpServletResponse) MarkupBuilder(groovy.xml.MarkupBuilder) MethodClosure(org.codehaus.groovy.runtime.MethodClosure)

Example 4 with MarkupBuilder

use of groovy.xml.MarkupBuilder in project gradle by gradle.

the class TestNGOptions method suiteXmlBuilder.

public MarkupBuilder suiteXmlBuilder() {
    suiteXmlWriter = new StringWriter();
    suiteXmlBuilder = new MarkupBuilder(suiteXmlWriter);
    return suiteXmlBuilder;
}
Also used : StringWriter(java.io.StringWriter) MarkupBuilder(groovy.xml.MarkupBuilder)

Example 5 with MarkupBuilder

use of groovy.xml.MarkupBuilder in project irontest by zheng-wang.

the class WSDLResource method getOperationInfo.

@GET
@Path("/{wsdlUrl}/bindings/{bindingName}/operations/{operationName}")
public SOAPOperationInfo getOperationInfo(@PathParam("wsdlUrl") String wsdlUrl, @PathParam("bindingName") String bindingName, @PathParam("operationName") String operationName) {
    SOAPOperationInfo info = new SOAPOperationInfo();
    WSDLParser parser = new WSDLParser();
    Definitions definition = parser.parse(wsdlUrl);
    StringWriter writer = new StringWriter();
    SOARequestCreator creator = new SOARequestCreator(definition, new RequestTemplateCreator(), new MarkupBuilder(writer));
    creator.createRequest(null, operationName, bindingName);
    info.setSampleRequest(writer.toString());
    return info;
}
Also used : RequestTemplateCreator(com.predic8.wstool.creator.RequestTemplateCreator) StringWriter(java.io.StringWriter) Definitions(com.predic8.wsdl.Definitions) MarkupBuilder(groovy.xml.MarkupBuilder) SOAPOperationInfo(io.irontest.models.teststep.SOAPOperationInfo) WSDLParser(com.predic8.wsdl.WSDLParser) SOARequestCreator(com.predic8.wstool.creator.SOARequestCreator) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

MarkupBuilder (groovy.xml.MarkupBuilder)7 StringWriter (java.io.StringWriter)4 RequestTemplateCreator (com.predic8.wstool.creator.RequestTemplateCreator)3 SOARequestCreator (com.predic8.wstool.creator.SOARequestCreator)3 Definitions (com.predic8.wsdl.Definitions)2 WSDLParser (com.predic8.wsdl.WSDLParser)2 Constructor (java.lang.reflect.Constructor)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 MethodClosure (org.codehaus.groovy.runtime.MethodClosure)2 SOAPOperationInfo (io.irontest.models.teststep.SOAPOperationInfo)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1