title: cdata in jax-ws / wsimport
body: <p>I created a soap client with wsimport and i need to send xml data inside of a string field in the message to the webserver. I know that i dont really need to use a cdata in a webservice call but the webservice needs this field to be in cdata tags.</p>
  
  <p>The question is how to do it.</p>
  
  <p>To generate the code from the wsdl i use the jaxws-maven-plugin. 
  in the maven config i use a binding file</p>
  
  <pre><code>bindingFiles
     binding Filebinding.xjb /bindingFile
  /bindingFiles
  </code></pre>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>jxb:bindings version="2.0"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:tns="urn:uniface:applic:services:BRF_IN"
      xmlns:jxb="http://java.sun.com/xml/ns/jaxb"&gt;
  
      &lt;jxb:globalBindings generateElementProperty="false"/&gt;
      &lt;jxb:bindings scd="//element::tns:DATA"&gt;
          &lt;jxb:javaType 
                  name="String"                          
                  parseMethod="de.xyz.CdataConverter.unmarshal"                      
                  printMethod="de.xyz.CdataConverter.marshal"
                  /&gt;
      &lt;/jxb:bindings&gt;
  </code></pre>
  
  <p></p>
  
  <p>and marshal/unmarschal looks like this:
  </p>
  
  <pre class="lang-java prettyprint-override"><code>public class CdataConverter {
  private static final Pattern PATTERN = Pattern.compile("((?&lt;=\\&lt;\\!\\[CDATA\\[)[\\S\\s]+(?=\\]\\]\\&gt;))");
  private static final String CDATA_START = "&lt;![CDATA[";
  private static final String CDATA_END = "]]&gt;";
  private final static Logger logger =    
  
  Logger.getLogger(LgTestServer.class.getName());
  
  public static String marshal(String input) {
      if (input == null) {
          return null;
      }
      PropertyConfigurator.configure(".\\log4j.properties");
      logger.info("input ---------------------&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;\n" + input);
      return CDATA_START + input + CDATA_END;
  }
  
  public static String unmarshal(String cdatainput) {
      if (cdatainput == null) {
          return null;
      }
      Matcher matcher = PATTERN.matcher(cdatainput);
      if (matcher.find()) {
          return matcher.group();
      }
      return cdatainput.trim();
  }
  </code></pre>
  
  <p>With this i get a ![CDATA[ in the data field but the xml is encoded like this</p>
  
  <pre class="lang-java prettyprint-override"><code>&amp;lt;![CDATA[&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&amp;#13;
  </code></pre>
  
  <p>Now i found this here (how to do cdata with jaxb):
  <a href="http://odedpeer.blogspot.de/2010/07/jaxb-sun-and-how-to-marshal-cdata.html" rel="noreferrer">http://odedpeer.blogspot.de/2010/07/jaxb-sun-and-how-to-marshal-cdata.html</a></p>
  
  <p>but i dont understand how to do this with the maven plugin and wsimport.
  i mean, i cant code this it has to be configured in any way.</p>
  
  <p>do you have any ideas how to do this?</p>