Error calling WCF webservice through channelfactory - not permissioned

By : NZJames
Source: Stackoverflow.com
Question!

I am using a ChannelFactory to call into a WCF service (as the target service location will change depending on environment and I need the URL to be configurable). However I get the error:

The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.

My calling code

var myBinding = new BasicHttpBinding();
var myEndpoint = new EndpointAddress(webserviceAddress);
var myChannelFactory = new ChannelFactory<IObjectService>(myBinding, myEndpoint);
var serviceClient = myChannelFactory.CreateChannel();

My WCF service web.config system.servicemodel section

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding>
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />
  </system.serviceModel>

The service should be authenticated based on Windows Authentication. I would have thought by default the calling code above would use Windows Authentication to pass the account that the code is running as (a service account) but it seems to be sending anonymous

By : NZJames


Answers

You must set the mode to transport with message credentials, as shown in the following code:

var myBinding = new BasicHttpBinding();
myBinding.Security.Mode = SecurityMode.TransportCredentialOnly;

As an alternative, you can set the mode in the constructor of the binding:

var myBinding = new BasicHttpBinding(SecurityMode.TransportCredentialOnly);

Also set the ClientCredential:

myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;


MUL requires all operands to be registers, so you must use the form MUL r0, rn, r0 where rn is some other suitable register.

If the result and the first operand are the same the result is unpredictable as the error says. This is due to the internal operation of the processor. This is why you must use r0, rn, r0 and not r0, r0, rn



Alternatively, you could omit return and block braces, but the function body should be one liner with implicit return:

render() {
  return(
    <div>
      {array.map((element, index) => <MyComponent disturbingVariable={100 + index}/>)}
    </div>
  )
}

More about implicit return here

By : leo


This video can help you solving your question :)
By: admin