views:

16

answers:

1

I am attempting to create a WCF service with anonymous authentication. When I deploy the service to the destination server that is not on my current domain I receive the following error when attempting to call it:

Content Type application/soap+xml; charset=utf-8 was not supported by the service http://myserver.com/page.svc. The client and service bindings may be mismatched.

as it stands now I have the following section in my web.config file for the service:

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
    </modules>
  </system.webServer>

I have been trying various bindings (wsHttpBinding and basicHttpBinding) but I either receive the error above (using basicHttpBinding) or an "Access is Denied" message (using wsHttpBinding). Here is the web.config section I tried to use when using wsHttpBinding

 <system.serviceModel>
  <services>
   <service behaviorConfiguration="AMP.MainBehavior" name="AMP.Main">
    <endpoint address="" binding="wsHttpBinding" contract="AMP.IMain">
      <identity>
        <dns value="myservice.com"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
   </service>
  </services>
  <behaviors>
    <serviceBehaviors>
    <behavior name="AMP.MainBehavior">
     <serviceMetadata httpGetEnabled="true"/>
     <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
   </serviceBehaviors>
  </behaviors>
 </system.serviceModel>

The service has been created with the .NET 4.0 framework. I need it to be anonymous but I'm not sure what I'm missing. I'm new to WCF so I don't have all my ducks in a row yet.

Thank you,

+1  A: 

The error says that you are sending HTTP request with content type which is not supported. Mentioned content type is used in SOAP 1.2 but BasicHttpBinding uses SOAP 1.1 with different content type (text/xml; charset=utf-8). So there is probably some mismatch between your service and client configuration.

In your second example the problem is default WsHttpBinidng configuration. WsHttpBinding is by default secured with message security and Windows authentication => exception because machines are in different domains so Windows auhtentication cannot work. You have to define your own WsHttpBinding configuration. Try this (same binding configuration has to be used on client):

<system.serviceModel>
  <bindings>
    <wsHttpBinding>
      <binding name="Unsecured">
        <security mode="None" />   
      </binding>
    </wsHttpBinding>
  </bindings>
  <services>
    <service ...>
      <endpoint address="..." contract="..." 
         binding="wsHttpBinding" bindingConfiguration="Unsecured" />
      ...
    </service>
  </services>
</system.serviceModel>
Ladislav Mrnka
@Ladislav Thank you for your response! I added in the configuration you suggested and set the endpoint address to the URL where the service lives and now I receive a different error. It starts off as "Secure channel cannot be opened because security negotiation with the remote endpoint has failed."
Scott Vercuski