I made my way through the network but found some solution.
Now WCF services work fine at the local level, while on the remote server it throws a 401 (unauthorized) web exception for POST calls. GETs work fine.
Implementation Details : On the Remote Server- IIS : 6.0 .NET : 4.0 Calling App : WPF app. On the Local Server- IIS : 7.0 .NET : 4.0 Calling App : WPF app.
The service has anonymous access specified for the rest of WCF in web.config. For authentication We have implemented the AuthManager class, which authenticates the request using hard-coded user names and passwords.
When calling the caller, network credentials are added.
The header when calling the local network:
Authorization: Basic dG9ueXXXXXXX
While on a server call:
Authorization: Negotiate TlRMTVNTUAABAAAAl4IIXXXXXXX
This is what looks suspicious to me.
The following is the Web.config service:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <connectionStrings> <add name="SqlServerConnectionString" connectionString="Data Source=BHUVINT\SQL2008R2;Initial Catalog=CPNS;User ID=sa; Password=orion@123 "/> </connectionStrings> <system.diagnostics> <trace> <listeners> <add name="myListener" type="System.Diagnostics.EventLogTraceListener" initializeData="Application" /> </listeners> </trace> </system.diagnostics> <system.web> <compilation debug="true" targetFramework="4.0" /> <machineKey decryption="AES" decryptionKey="0CA3EFAF0F7A5E7A62681C0BF656EE0ECE31ACEE3E1023BA3FAD20EA5F199DE8" validation="SHA1" validationKey="3E4528C0FFE94A75DF02052B358BD9DE40800DD89DE62168764FF0DCE537184F0535D5D9AD66DEDC97DC1ABFF7FA540B4DFD82E5BB196B95D15FF81F75AD5328" /> </system.web> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="Mg"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.Push"> <endpoint binding="webHttpBinding" name="firstBinding" contract="ApmWcfServiceWebRole.IPushService" /> </service> <service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.WP7Device"> <endpoint binding="webHttpBinding" name="secondBinding" contract="ApmWcfServiceWebRole.IWP7Service" /> </service> <service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.iOSDevice"> <endpoint binding="webHttpBinding" name="thirdBinding" contract="ApmWcfServiceWebRole.IIOSService" /> </service> <service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.AndroidDevice"> <endpoint binding="webHttpBinding" name="fourthBinding" contract="ApmWcfServiceWebRole.IAndroidService" /> </service> </services> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"> </serviceHostingEnvironment> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> </system.webServer> </configuration> = "0CA3EFAF0F7A5E7A62681C0BF656EE0ECE31ACEE3E1023BA3FAD20EA5F199DE8" validation = "SHA1" validationKey = "3E4528C0FFE94A75DF02052B358BD9DE40800DD89DE62168764FF0DCE537184F0535D5D9AD66DEDC97DC1ABFF7FA540B4DFD82E5BB196B95D15FF81F75AD5328" /> <?xml version="1.0" encoding="UTF-8"?> <configuration> <connectionStrings> <add name="SqlServerConnectionString" connectionString="Data Source=BHUVINT\SQL2008R2;Initial Catalog=CPNS;User ID=sa; Password=orion@123 "/> </connectionStrings> <system.diagnostics> <trace> <listeners> <add name="myListener" type="System.Diagnostics.EventLogTraceListener" initializeData="Application" /> </listeners> </trace> </system.diagnostics> <system.web> <compilation debug="true" targetFramework="4.0" /> <machineKey decryption="AES" decryptionKey="0CA3EFAF0F7A5E7A62681C0BF656EE0ECE31ACEE3E1023BA3FAD20EA5F199DE8" validation="SHA1" validationKey="3E4528C0FFE94A75DF02052B358BD9DE40800DD89DE62168764FF0DCE537184F0535D5D9AD66DEDC97DC1ABFF7FA540B4DFD82E5BB196B95D15FF81F75AD5328" /> </system.web> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="Mg"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.Push"> <endpoint binding="webHttpBinding" name="firstBinding" contract="ApmWcfServiceWebRole.IPushService" /> </service> <service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.WP7Device"> <endpoint binding="webHttpBinding" name="secondBinding" contract="ApmWcfServiceWebRole.IWP7Service" /> </service> <service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.iOSDevice"> <endpoint binding="webHttpBinding" name="thirdBinding" contract="ApmWcfServiceWebRole.IIOSService" /> </service> <service behaviorConfiguration="Mg" name="ApmWcfServiceWebRole.AndroidDevice"> <endpoint binding="webHttpBinding" name="fourthBinding" contract="ApmWcfServiceWebRole.IAndroidService" /> </service> </services> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"> </serviceHostingEnvironment> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> </system.webServer> </configuration>
EDIT: AuthManager is called only when POSTs are performed that require checks, and those that do not work.
EDIT 2: I added Trace to AuthManager, no credentials were received by it, and it gets an empty value. The problem seems to be with credential transfer.
Thanks in advance.
source share