wcf wshtpbinding on IIS错误 - 服务未通过服务验证来验证

发布于 2025-02-04 16:22:33 字数 3170 浏览 2 评论 0原文

我有一个简单的WCF服务,该服务使用WSHTTPBINDING并在Visual Studio开发环境中工作,但在IIS上部署时不使用。我用来测试遇到错误的控制台客户端应用程序:当我将其引导到IIS端点时,“呼叫者未经服务验证”,在该端点部署了我的service1.svc。我在stackoverflow中查看类似的帖子,但对我来说无济于事。感谢任何人的建议。

我在IIS中的webconfig如下:

<system.serviceModel>
      <bindings>
          <wsHttpBinding>
              <binding name="wsHttpBinding">
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
              </binding>
          </wsHttpBinding>
      </bindings>
    <services>
      <service name="WCFOA416_WSHttp.OA_Services">
        <endpoint binding="wsHttpBinding" 
            bindingConfiguration="wsHttpBinding" 
            name="WSHttp_OA_Server_Endpoint" contract="WSHttp_OA_ServerSoap" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
            contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>         
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="wsHttpBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
    multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

我的client app.config是:

<system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttp_OA_Server_Endpoint2" >
                    <readerQuotas maxDepth="2147483647" 
            maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
    maxNameTableCharCount="2147483647" />
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://example.com/Service1.svc"
                binding="wsHttpBinding" bindingConfiguration="WSHttp_OA_Server_Endpoint2" 
        contract="ServiceReference4.WSHttp_OA_ServerSoap" name="WSHttp_OA_Server_Endpoint2">
                <identity>
                    <servicePrincipalName value="host/AMAZONA-XXXXXX1" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>

我的客户端控制台代码是:

ServiceReference4.WSHttp_OA_ServerSoapClient c1 = new ServiceReference4.WSHttp_OA_ServerSoapClient();

            string[] a = c1.GetMethods();
            foreach (string ss in a)
            {
                Console.WriteLine(ss);
            }

我的IIS网站设置IIS Authentication是匿名的.authentication-status已启用。

I have a simple WCF service that uses wsHttpBinding and works on Visual Studio development environment but not when deployed on IIS. My console client app that I use to test encounters the error: "The caller was not authenticated by the service" when I direct it to IIS endpoint where I deploy my service1.svc. I look on similar posting here in Stackoverflow but none works for me. I appreciate any advice from anyone.

My webconfig in IIS is as follows:

<system.serviceModel>
      <bindings>
          <wsHttpBinding>
              <binding name="wsHttpBinding">
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
              </binding>
          </wsHttpBinding>
      </bindings>
    <services>
      <service name="WCFOA416_WSHttp.OA_Services">
        <endpoint binding="wsHttpBinding" 
            bindingConfiguration="wsHttpBinding" 
            name="WSHttp_OA_Server_Endpoint" contract="WSHttp_OA_ServerSoap" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
            contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>         
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="wsHttpBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
    multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

My client app.config is:

<system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttp_OA_Server_Endpoint2" >
                    <readerQuotas maxDepth="2147483647" 
            maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
    maxNameTableCharCount="2147483647" />
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://example.com/Service1.svc"
                binding="wsHttpBinding" bindingConfiguration="WSHttp_OA_Server_Endpoint2" 
        contract="ServiceReference4.WSHttp_OA_ServerSoap" name="WSHttp_OA_Server_Endpoint2">
                <identity>
                    <servicePrincipalName value="host/AMAZONA-XXXXXX1" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>

My client console code is:

ServiceReference4.WSHttp_OA_ServerSoapClient c1 = new ServiceReference4.WSHttp_OA_ServerSoapClient();

            string[] a = c1.GetMethods();
            foreach (string ss in a)
            {
                Console.WriteLine(ss);
            }

My website setting for IIS Authentication is Anonymous.Authentication-Status is Enabled.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So尛奶瓶 2025-02-11 16:22:33

我通过设置以下内容来获得此功能:

server web.config:

<wsHttpBinding>
<security mode="None">
                      <transport clientCredentialType="None" />
                      <message establishSecurityContext="false" />
                  </security>
</wsHttpBinding>

客户端应用程序配置:

<wsHttpBinding>
<binding name="WSHttp_OA_Server_Endpoint3">
                    <security mode="None" />
                </binding>
</wsHttpBinding>

<endpoint address="http://ms.pwrmetrixonline.com/OA416WSHTTP/Service1.svc"
                binding="wsHttpBinding" bindingConfiguration="WSHttp_OA_Server_Endpoint3"
                contract="ServiceReference5.WSHttp_OA_ServerSoap" name="WSHttp_OA_Server_Endpoint3" />

I got this working by setting the following:

Server web.config:

<wsHttpBinding>
<security mode="None">
                      <transport clientCredentialType="None" />
                      <message establishSecurityContext="false" />
                  </security>
</wsHttpBinding>

Client app config:

<wsHttpBinding>
<binding name="WSHttp_OA_Server_Endpoint3">
                    <security mode="None" />
                </binding>
</wsHttpBinding>

<endpoint address="http://ms.pwrmetrixonline.com/OA416WSHTTP/Service1.svc"
                binding="wsHttpBinding" bindingConfiguration="WSHttp_OA_Server_Endpoint3"
                contract="ServiceReference5.WSHttp_OA_ServerSoap" name="WSHttp_OA_Server_Endpoint3" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文