开发者

WCF service binding wsHttp vs. basic with no authentication

开发者 https://www.devze.com 2023-01-18 05:28 出处:网络
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 attemptin

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; 开发者_Go百科 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,


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消