title: Why is my WCF web service presenting this object in a different namespace with different field names?
body: <p><strong>The Context:</strong> I'm trying to integrate with DocuSign's Connect notification service. I've set up a WCF service with a method called DocuSignConnectUpdate which takes a DocuSignEnvelopeInformation as its only parameter, as specified by DocuSign. This DocuSignEnvelopeInformation object comes from a reference to <a href="https://demo.docusign.net/api/3.0/api.asmx" rel="nofollow">their API</a>, so that they can pass this object to my web service, and I know exactly what to expect. DocuSign asks for my service address and the namespace, which I have configured on their site.</p>
  
  <p><strong>The Problem:</strong> The XML that DocuSign sends is what I would expect. The DocuSignEnvelopeInformation and its children are in the namespace "<a href="http://www.docusign.net/API/3.0" rel="nofollow">http://www.docusign.net/API/3.0</a>" and the element names match the object names:</p>
  
  <pre><code>&lt;DocuSignEnvelopeInformation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.docusign.net/API/3.0"&gt;
      &lt;EnvelopeStatus&gt;...&lt;/EnvelopeStatus&gt;
  &lt;/DocuSignEnvelopeInformation&gt;
  </code></pre>
  
  <p>But my web service is expecting something different, in the wrong namespace, and with modified element names. This is how the DocuSignConnectUpdate method is defined in my WSDL:</p>
  
  <pre><code>&lt;xs:element name="DocuSignConnectUpdate"&gt;
      &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element minOccurs="0" name="DocuSignEnvelopeInformation" nillable="true" type="tns:DocuSignEnvelopeInformation"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>And this is how this is how the DocuSignEnvelopeInformation type is defined in my WSDL:</p>
  
  <pre><code>&lt;xs:complexType name="DocuSignEnvelopeInformation"&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/System.ComponentModel" name="PropertyChanged" nillable="true" type="q1:PropertyChangedEventHandler"/&gt;
          &lt;xs:element name="documentPDFsField" nillable="true" type="tns:ArrayOfDocumentPDF"/&gt;
          &lt;xs:element name="envelopeStatusField" nillable="true" type="tns:EnvelopeStatus"/&gt;
          &lt;xs:element name="timeZoneField" nillable="true" type="xs:string"/&gt;
          &lt;xs:element name="timeZoneOffsetField" type="xs:int"/&gt;
          &lt;xs:element name="timeZoneOffsetFieldSpecified" type="xs:boolean"/&gt;
      &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>Element names like envelopeStatusField are the names of the <em>private</em> variables used in the auto-generated code. The public property names match the xml that DocuSign sends. The auto-generated code also tags each object with the correct docusign namespace using XmlTypeAttribute. So from looking at the auto-generated code, I would expect my service to be happy with the input, but the WSDL generated is different, as shown above, and my service fails to deserialize the xml.</p>
  
  <p><strong>Some Code:</strong>
  The auto-generated declaration of DocuSignEnvelopeInformation:</p>
  
  <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.docusign.net/API/3.0")]
  public partial class DocuSignEnvelopeInformation : object, System.ComponentModel.INotifyPropertyChanged {
  
      private EnvelopeStatus envelopeStatusField;
  
      private DocumentPDF[] documentPDFsField;
  
      private string timeZoneField;
  
      private int timeZoneOffsetField;
  
      private bool timeZoneOffsetFieldSpecified;
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Order=0)]
      public EnvelopeStatus EnvelopeStatus {
      ...
      ...
  </code></pre>
  
  <p>The OperationContract for the only method:</p>
  
  <pre><code>[SoapHeaders]
  [ServiceContract(Namespace = "http:/MyNameSpace")]
  public interface IDocusignEventListener
  {
      [OperationContract]
      [FaultContract(typeof(ErrorMessageCollection), Action = Constants.FaultAction)]
      string DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation);
  }
  </code></pre>
  
  <p>The method that DocuSign calls</p>
  
  <pre><code>[ServiceBehavior(Namespace = "http:/MyNameSpace", ConfigurationName = "DocusignEventListener")]
  public class DocusignEventListener : IDocusignEventListener
  {
      public string DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation)
     {
         ...
  
         return DocuSignEnvelopeInformation.EnvelopeStatus.EnvelopeID;
      }
  }
  </code></pre>
  
  <p>So, again, the question is why is the wsdl showing up this way? Why is the object different from the reference I pulled it from? And more importantly, can I fix it?</p>