繁体   English   中英

WCF REST服务可在本地正常运行,在远程服务器上显示未授权(401)错误,而该服务具有匿名访问权限

[英]WCF REST Service works fine on local , gives Unauthorized (401) error on Remote server whereas the service has Anonymous access

我在网上漫步,但没有找到任何解决方案。
现在,WCF服务可以在本地完美运行,而在远程服务器上,它会为POST调用抛出401(未经授权)网络异常。 GET工作正常。

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.

该服务在web.config中具有为WCF指定的匿名访问权限。 对于身份验证,我们实现了AuthManager类,该类使用硬编码的用户名和密码对请求进行身份验证。

在呼叫方时,将添加网络凭据。

当我呼叫本地网络时,标题为:

Authorization: Basic dG9ueXXXXXXX

而调用服务器时:

Authorization: Negotiate TlRMTVNTUAABAAAAl4IIXXXXXXX

这就是给我找鱼的样子。

下面给出的是Service的Web.config:

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

编辑:仅在进行需要检查的POST的情况下才调用AuthManager,而这些都是失败的。

编辑2:我在AuthManager中添加了一个跟踪,它没有接收到凭据,它的值为空。 似乎问题在于传递凭据。

提前致谢。

问题已解决:

我已启用了匿名访问,但已对Windows身份验证启用了一项检查,该检查已删除并开始工作 解

我需要有关发生这种情况的原因的帮助,以便在请求到达我的跟踪时删除凭据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM