title: Error when trying to consume WCF service returning file
body: <p>One of my methods returns byte[], of a file. All other methods return either string objects or custom objects</p>
  
  <p>I can view the WSDL via a browser and as i have used WCfExtras, I can even view the documentation. </p>
  
  <p>In my test app, C# web application, I add the reference to my svc, hosted on a test server. I get an error as such:</p>
  
  <pre><code>     The document was understood, but it could not be processed.
    - The WSDL document contains links that could not be resolved.
    - There was an error downloading ...
    - Unable to connect to remote server
    - No connection could be made because the target machine actively refused it
  
      Content Type application/soap+xml; charset=utf-8 was not supported by service .  The client and service bindings may be mismatched.
      The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
      If the service is defined in the current solution, try building the solution and adding the service reference again.
  </code></pre>
  
  <p>This is my app.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="TestApp.Properties.Settings.TestDBConnectionString"
        connectionString="Data Source=192.168.2.130;Initial Catalog=TestDB;Persist Security Info=True;User ID=sa;Password=xerox"
        providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" /&gt;
    &lt;/system.web&gt;
    &lt;!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --&gt;
    &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="TestApp.Service1Behavior"
          name="TestApp.SearchService"&gt;
          &lt;endpoint address="" behaviorConfiguration="Sample.WsdlSampleEndpointBehavior"
            binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding" contract="TestApp.ISearchService"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8731/TestApp/Service1/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
         &lt;endpointBehaviors&gt;
          &lt;behavior name="Sample.WsdlSampleEndpointBehavior"&gt;
            &lt;wsdlExtensions location="http://localhost:8731/TestApp/Service1/"/&gt;
          &lt;/behavior&gt;
          &lt;/endpointBehaviors&gt;
          &lt;serviceBehaviors&gt;
          &lt;behavior name="TestApp.Service1Behavior"&gt;
            &lt;!-- To avoid disclosing metadata information, 
            set the value below to false and remove the metadata endpoint above before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="True"/&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, 
            set the value below to true.  Set to false before deployment 
            to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
          &lt;/behavior&gt;
  
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;extensions&gt;
        &lt;behaviorExtensions&gt;
          &lt;!-- Declare that we have an extension called WSDL Extras--&gt;
          &lt;add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/&gt;
        &lt;/behaviorExtensions&gt;
      &lt;/extensions&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="WsHttpMtomBinding" messageEncoding="Mtom" transferMode="StreamedResponse" /&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Any ideas on how I would resolve this? Should I have 2 different bindings, one for methods returning non bytes[] and Mtom for method returning byte[]? If so how does one apply bindings per method exposed?</p>
  
  <p>Tried running it with WcfTestClient.exe and this is the error</p>
  
  <pre><code>rror: Cannot import wsdl:portTypeDetail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporterError: Schema with target namespace 'http://tempuri.org/' could not be found.XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISearchService']Error: Cannot import wsdl:bindingDetail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISearchService']XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_ISearchService']Error: Cannot import wsdl:portDetail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_ISearchService']XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='SearchService']/wsdl:port[@name='BasicHttpBinding_ISearchService']Warning: No code was generated.If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or servicesor because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.
  </code></pre>