title: Ant WSGEN WSDL generation - include WSIT policy definition
body: <p>I'm using the WSGEN Ant task to generate a WSDL from a service class. The task runs fine and generates the required WSDL. The problem I'm having is trying to get it to incorporate the WSIT policy definition at the top of the WSDL.</p>
  
  <p>When I deploy the service in Netbeans (i.e. not using Ant to handle WSGEN), Netbeans generates a WSDL file which contains the WSIT policy definition. The WSIT policy is contained in an XML file generated by Netbeans - web-inf/wsit-com.mypackage.web.webservice.jaxws.MyServiceService.xml.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; MyService
  &lt;definitions 
   xmlns="http://schemas.xmlsoap.org/wsdl/" 
   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="Store" targetNamespace="http://jaxws.webservice.web.mypackage.com/" xmlns:tns="http://jaxws.webservice.web.mypackage.com/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp1="http://www.w3.org/ns/ws-policy" xmlns:fi="http://java.sun.com/xml/ns/wsit/2006/09/policy/fastinfoset/service" xmlns:tcp="http://java.sun.com/xml/ns/wsit/2006/09/policy/soaptcp/service" xmlns:wsaw="http://www.w3.org/2005/08/addressing" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" xmlns:sc="http://schemas.sun.com/2006/03/wss/server" xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:sp1="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
   &gt;
      &lt;portType name="MyService"&gt;
      &lt;/portType&gt;
      &lt;binding name="MyServicePortBinding" type="tns:MyService"&gt;
          &lt;wsp1:PolicyReference URI="#MyServicePortBindingPolicy"/&gt;
      &lt;/binding&gt;
      &lt;service name="Store"&gt;
          &lt;port name="MyServicePort" binding="tns:MyServicePortBinding"/&gt;
      &lt;/service&gt;
      &lt;wsp1:Policy wsu:Id="MyServicePortBindingPolicy"&gt;
          &lt;wsp1:ExactlyOne&gt;
              &lt;wsp1:All&gt;
                  &lt;wsam:Addressing wsp1:Optional="false"/&gt;
                  &lt;sp1:TransportBinding&gt;
                      &lt;wsp1:Policy&gt;
                          &lt;sp1:TransportToken&gt;
                              &lt;wsp1:Policy&gt;
                                  &lt;sp1:HttpsToken RequireClientCertificate="false"/&gt;
                              &lt;/wsp1:Policy&gt;
                          &lt;/sp1:TransportToken&gt;
                          &lt;sp1:Layout&gt;
                              &lt;wsp1:Policy&gt;
                                  &lt;sp1:Lax/&gt;
                              &lt;/wsp1:Policy&gt;
                          &lt;/sp1:Layout&gt;
                          &lt;sp1:IncludeTimestamp/&gt;
                          &lt;sp1:AlgorithmSuite&gt;
                              &lt;wsp1:Policy&gt;
                                  &lt;sp1:Basic128/&gt;
                              &lt;/wsp1:Policy&gt;
                          &lt;/sp1:AlgorithmSuite&gt;
                      &lt;/wsp1:Policy&gt;
                  &lt;/sp1:TransportBinding&gt;
                  &lt;sp1:SignedEncryptedSupportingTokens&gt;
                      &lt;wsp1:Policy&gt;
                          &lt;sp1:UsernameToken sp1:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"&gt;
                              &lt;wsp1:Policy&gt;
                                  &lt;sp1:WssUsernameToken10/&gt;
                              &lt;/wsp1:Policy&gt;
                          &lt;/sp1:UsernameToken&gt;
                      &lt;/wsp1:Policy&gt;
                  &lt;/sp1:SignedEncryptedSupportingTokens&gt;
                  &lt;sc:ValidatorConfiguration wspp:visibility="private"&gt;
                      &lt;sc:Validator name="usernameValidator" classname="com.mypackage.web.webservice.jaxws.validator.PlainTextPasswordValidator"/&gt;
                  &lt;/sc:ValidatorConfiguration&gt;
                  &lt;sp1:Wss11/&gt;
              &lt;/wsp1:All&gt;
          &lt;/wsp1:ExactlyOne&gt;
      &lt;/wsp1:Policy&gt;
  &lt;/definitions&gt;
  </code></pre>
  
  <p>I've added the location of this file to the classpath of the WSGEN task so it should be able to detect it. However, the WSDL that is being created by the WSGEN task does not include the WS Policy definition.</p>
  
  <p>There doesn't appear to be any argument that I can pass to the Ant task to tell it to include WS-Policy. Under the hood though, the WSGEN task is using the same wsgen as is being used by Netbeans i.e. the one from glassfishv2/lib/webservices-tools.jar.</p>
  
  <pre><code>&lt;taskdef name="wsgen"
      classname="com.sun.tools.ws.ant.WsGen"
      classpathref="wstools.classpath" /&gt;
  
  &lt;wsgen sourcedestdir="${wsgen.src.dir}"
      resourcedestdir="${wsproxy.resources.dir}"
      destdir="${wsgen.build.dir}"
      verbose="true"
      xendorsed="true"
      keep="true"
      genwsdl="true"
      sei="${store.client.service.name}"&gt;
      &lt;classpath refid="ws.codegen.classpath" /&gt;
  &lt;/wsgen&gt;
  </code></pre>
  
  <p>Has anyone had any luck getting the Ant task to include WS-Policy definitions? What am I doing wrong?</p>
  
  <p>Cheers,</p>
  
  <p>J</p>