title: wsimport of two WCF services overwrites objectFactory - how to resolve
body: <p>Sorry, this is long.  I'm new to Java web services, and have been moving through examples on the web to create a Java client to a pair of WCF services hosted by a vendor application.  I am able to create the client for each separately, but when I try and put them together, the second service bindings overwrite the first.  I'm pretty sure it's the ObjectFactory class that's getting overwritten.</p>
  
  <p>I'm using Metro (not installed in eclipse) and the following ant build in exclipse. </p>
  
  <p>build.xml:</p>
  
  <pre><code>&lt;project default="wsimport"&gt;
    &lt;target name="wsimport"&gt;
      &lt;exec executable="C:/Metro/bin/wsimport.bat"&gt; 
          &lt;arg line="-keep -s ../src -d ../bin -extension -Xnocompile -XadditionalHeaders -b ../build/wcf.jaxb -B-XautoNameResolution http://my.host.name/ptsqamt/Maintain/services/reports/2010/09/ReportServices.svc?singleWSDL"/&gt;
      &lt;/exec&gt;
  
      &lt;exec executable="C:/Metro/bin/wsimport.bat"&gt; 
          &lt;arg line="-keep -s ../src -d ../bin -extension -Xnocompile -XadditionalHeaders -b ../build/wcf.jaxb -B-XautoNameResolution http://my.host.name/ptsqamt/Maintain/services/reports/2010/09/ReportFileService.svc?singleWSDL"/&gt;
      &lt;/exec&gt;
    &lt;/target&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Connecting to the ReportFileService works, but when I connect to the ReportServices service, I get the following exception: </p>
  
  <blockquote>
    <p>Exception in thread "main" javax.xml.ws.WebServiceException:
    {<a href="http://tempuri.org/" rel="nofollow noreferrer">http://tempuri.org/</a>}ReportServices is not a valid service. Valid
    services are: {<a href="http://tempuri.org/" rel="nofollow noreferrer">http://tempuri.org/</a>}ReportFileService</p>
  </blockquote>
  
  <p>I have tried to put the build's in separate packages, which works, but I get a similar issue at runtime.</p>
  
  <p>I have looked at various threads, to either change the target name space from <a href="http://tempuri.org/" rel="nofollow noreferrer">http://tempuri.org/</a> to something else, or change the ObjectFactory class name to something custom.</p>
  
  <p>I have this inline code (found <a href="https://stackoverflow.com/questions/15783166/wsimport-multiple-wsdl-overwrite-objectfactory">here</a>), but I don't know how to use it / change it to an external file.</p>
  
  <pre><code>&lt;xsd:complexType name="ObjectFactory"&gt;
    &lt;xsd:annotation&gt;
    &lt;xsd:appinfo&gt;
       &lt;jxb:class name="ReportServicesObjectFactory" /&gt;
    &lt;/xsd:appinfo&gt;
    &lt;/xsd:annotation&gt;
  &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>Can anyone help on how I can resolve this.</p>