title: WCF: Can't call own WCF service
body: <p>I have my WCF service, I've created reference to it from MSTest project. Here is example how I am calling service methods:</p>
  
  <pre><code>IEnrollmentService serviceClient = ChannelFactory&lt;IEnrollmentService&gt;
      .CreateChannel(new BasicHttpBinding(),
                     new EndpointAddress("http://localhost/EnrollmentService.svc"));
  
  PublishResult res = serviceClient.PublishEnrollmentProfile(...);
  </code></pre>
  
  <p>Instead of execution I've got the following error:</p>
  
  <blockquote>
    <p>The content type application/xml;
    charset=utf-8 of the response message
    does not match the content type of the
    binding (text/xml; charset=utf-8). If
    using a custom encoder, be sure that
    the IsContentTypeSupported method is
    implemented properly. The first 710
    bytes of the response were: '<Code>Sendera:ActionNotSupported</Code>The message with
    Action '' cannot be processed at the
    receiver, due to a ContractFilter
    mismatch at the EndpointDispatcher.
    This may be because of either a
    contract mismatch (mismatched Actions
    between sender and receiver) or a
    binding/security mismatch between the
    sender and the receiver.  Check that
    sender and receiver have the same
    contract and the same binding
    (including security requirements, e.g.
    Message, Transport,
    None).'. ---> 
    System.Net.WebException: The remote
    server returned an error: (500)
    Internal Server Error..</p>
  </blockquote>
  
  <p>As far as I understood, there are some issues between ContractFilter and EndpointDispatcher. I've tried to goodgle, but found nothing understandable...</p>
  
  <p>I've also tried to call wcf service methods in another way:</p>
  
  <pre><code>EnrollmentServiceClient serviceClient = new EnrollmentServiceClient("http://localhost/EnrollmentService.svc");
  
  PublishResult res = serviceClient.PublishEnrollmentProfile(...);
  </code></pre>
  
  <p>That returns me another error:</p>
  
  <blockquote>
    <p>Could not find endpoint element with
    name
    '<a href="http://localhost/McActivation/EnrollmentService.svc" rel="nofollow noreferrer">http://localhost/McActivation/EnrollmentService.svc</a>'
    and contract
    'EnrollmentServiceReference.IEnrollmentService'
    in the ServiceModel client
    configuration section. This might be
    because no configuration file was
    found for your application, or because
    no endpoint element matching this name
    could be found in the client element..</p>
  </blockquote>
  
  <p><strong>Question1:</strong></p>
  
  <p>What is a correct way to instantiate wcf service client?</p>
  
  <p><strong>Questions2:</strong></p>
  
  <p>What is wrong in my case?</p>
  
  <p>Thanks a lot.</p>
  
  <p>P.S. With some issues I can connect to service with WcfTestClient, more details are here:
  <a href="https://stackoverflow.com/questions/4648922/wcf-service-cant-call-methods-through-the-webhttpbinding-endpoint">WCF service: Can&#39;t call methods through the &#39;WebHttpBinding&#39; endpoint</a></p>
  
  <p>P.P.S. Here is server side WCF service configuration:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
  &lt;services&gt;
    &lt;service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior"&gt;
      &lt;endpoint address="" binding="webHttpBinding" contract="McActivationApp.IEnrollmentService"/&gt;
      &lt;endpoint address="mex" binding="mexHttpBinding" contract="McActivationApp.IEnrollmentService" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="McActivationApp.EnrollmentServicBehavior"&gt;
        &lt;serviceMetadata httpGetEnabled="True"/&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="False" /&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>