title: How to generate a SOAP message with a fully populated request from WSDL without code gen
body: <p>I would like to ask you how I can generate a SOAP request/response in a XML format on the basis of the WSDL file. The target platform is JVM so a wide set of languages can be used (e.g. Java, Scala, Groovy, JRuby, Jython, etc.). The SOAP request/response generation should be done purely on the XML level without any class-generation and class-loading (WSDL2Java, JAXB or similar approaches are inappropriate in this case). Generation should be done programmatically with the usage of open-source components. The generation technique should support document-literal, rpc-encoded and rpc-literal flavors, so proper encoding of parameters should be handled by the generator. Request/response messages should be fully-populated -> empty nodes should be generated even for empty/blank values.</p>
  
  <p>Cutting the long story short -> I would like to do programmatically the thing that is doable in SoapUI IDE. I already had a look at different Java-related libraries/frameworks (SAAJ, WSDL4J) or Ruby (Savon) but I am struggling to move it any further.</p>
  
  <p>A sample Web-Service definition (WSDL and XSD) that I am working on is
  <code>stockquote-ws.wsdl</code> and <code>stockquote-schema.xsd</code>.</p>
  
  <p>What I would like to do is:</p>
  
  <pre><code>SoapMessageGenerator generator = new SoapMessageGenerator("stockquote-ws.wsdl");
  String request = generator.generateSoapRequest();
  String response = generator.generateSoapResponse();
  </code></pre>
  
  <p>In this case a request should look like this:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:stoc="http://centeractive.com/stockquote.wsdl" xmlns:stoc1="http://centeractive.com/stockquote.xsd"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;stoc:GetLastTradePrice soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
           &lt;stoc1:TradePriceRequest&gt;
              &lt;tickerSymbol xsi:type="xsd:string"&gt;?&lt;/tickerSymbol&gt;
           &lt;/stoc1:TradePriceRequest&gt;
        &lt;/stoc:GetLastTradePrice&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>... whereas a response should look like this:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:stoc="http://centeractive.com/stockquote.wsdl" xmlns:stoc1="http://centeractive.com/stockquote.xsd"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;stoc:GetLastTradePriceResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
           &lt;stoc1:TradePrice&gt;
              &lt;price xsi:type="xsd:float"&gt;?&lt;/price&gt;
           &lt;/stoc1:TradePrice&gt;
        &lt;/stoc:GetLastTradePriceResponse&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>