title: Troubles with WCF client (for a non .Net service)
body: <p>In a c# project, I have to query some web services which is not build with .Net (actually WebLogic).</p>
  
  <p>Where I can query most of the web services with no problem, I have difficulties with one. When I call the method, I get the following error (stack trace removed) :</p>
  
  <pre><code>System.InvalidOperationException: There was an error reflecting 'in'. 
  ---&gt; System.InvalidOperationException: The top XML element 'in' from namespace '' references distinct types MyReference.DistantWS.firstMethodInType and MyReference.DistantWS.secondMethodInType.
   Use XML attributes to specify another XML name or namespace for the element or types.
  </code></pre>
  
  <p>After a bit of googling, I conclude this is due because the distant service have two methods <code>FirstMethod</code> and <code>SecondMethod</code>, both with a complex <code>FirstMethodRequest</code> type having a property "In" as input parameter. However, the In parameter have two distinct types(respectively <code>firstMethodInType</code> and <code>secondMethodInType</code>).</p>
  
  <p>I use <a href="http://msdn.microsoft.com/library/aa347733.aspx" rel="nofollow"><code>svcutil</code></a> for building the proxy code. This actually generate the code :</p>
  
  <p>Pseudo code :</p>
  
  <pre><code>class firstMethodRequest
  {
      public firstMethodintype @in; // First occurence of a "in" parameter
  }
  
  class firstMethodintype
  {
  }
  
  class secondMethodRequest
  {
      public secondMethodintype @in; // Second occurence of a "in" parameter
  }
  
  class secondMethodintype
  {
  }
  </code></pre>
  
  <p>Full code :</p>
  
  <pre><code>[System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  [System.ServiceModel.MessageContractAttribute(WrapperName="first-method", WrapperNamespace="http://mynamespace/ws/wsdl/first-method", IsWrapped=true)]
  internal partial class firstMethodRequest
  {
      [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
      public firstMethodintype @in;
  
      public firstMethodRequest()        {        }
      public firstMethodRequest(firstMethodintype @in)        {            this.@in = @in;        }
  }
  
  [System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.1")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(TypeName="first-method-in-type", Namespace="http://mynamespace")]
  public partial class firstMethodintype
  {
      private string site_origineField;
  }
  
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  [System.ServiceModel.MessageContractAttribute(WrapperName="second-method", WrapperNamespace="http://mynamespace/ws/wsdl/second-method", IsWrapped=true)]
  internal partial class secondMethodRequest
  {
      [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
      public secondMethodintype @in; // Problem is here
  
      public secondMethodRequest()        {        }
      public secondMethodRequest(secondMethodintype @in)        {            this.@in = @in;        }
  }
  
  [System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.1")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(TypeName="second-method-in-type", Namespace="http://mynamespace")]
  public partial class secondMethodintype
  {
      private string site_origineField;
  }
  </code></pre>
  
  <p>As I don't control the output code, how can I properly solve my problem ?</p>
  
  <p>thx in advance</p>
  
  <p><strong>[Edit]</strong> Don't know if it's related, but here is an extract of the WSDL definition :</p>
  
  <pre><code>&lt;message name="first-method-in"&gt;
      &lt;part name="in" type="tp:first-method-in-type"/&gt;
  &lt;/message&gt;
  &lt;message name="second-method-in"&gt;
      &lt;part name="in" type="tp:second-method-in-type"/&gt;
  &lt;/message&gt;
  </code></pre>
  
  <p><strong>[Edit 2]</strong> Also, if the source WSDL / Schema is not valid or respectful to the W3C standards, please tells me. I can negotiate with the customer to rewrite its WS</p>
  
  <p><strong>[Edit 3]</strong> If I manually patch the wsdl to (renamed the second part) :</p>
  
  <pre><code>&lt;message name="first-method-in"&gt;
      &lt;part name="in" type="tp:first-method-in-type"/&gt;
  &lt;/message&gt;
  &lt;message name="second-method-in"&gt;
      &lt;part name="inSecond" type="tp:second-method-in-type"/&gt;
  &lt;/message&gt;
  </code></pre>
  
  <p>then the problem disappeared (but of course the call to the second method stop working)</p>