【问题标题】:WCF Authentication Service - How to generate client using Apache Axis?WCF 身份验证服务 - 如何使用 Apache Axis 生成客户端?
【发布时间】:2023-03-18 08:20:01
【问题描述】:

我有一个托管一些 WCF 服务的 ASP.NET 应用程序,使用 ASP.NET Membership 来保证安全。我已经通过 SVC 文件 (AuthenticationService.svc) 公开了 System.Web.ApplicationServices.AuthenticationService,如下所示:

<%@ ServiceHost Language="C#" Debug="true" Service="System.Web.ApplicationServices.AuthenticationService" %>

我对该服务的 WCF 配置如下:

<service name="System.Web.ApplicationServices.AuthenticationService" behaviorConfiguration="AuthenticationServiceBehaviors">
  <endpoint contract="System.Web.ApplicationServices.AuthenticationService" binding="basicHttpBinding"/>
</service>

...

<behavior name="AuthenticationServiceBehaviors">
  <serviceMetadata httpGetEnabled="true"/>
  <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
</behavior>

...

<bindings>
  <basicHttpBinding>
    <binding allowCookies="true"></binding>
  </basicHttpBinding>
</bindings>

我已经在我的 web.config 中启用了身份验证服务,如下所示:

<system.web.extensions>
  <scripting>
    <webServices>
      <authenticationService enabled="true" requireSSL="false"/>
    </webServices>
  </scripting>
</system.web.extensions>

我创建了一个 .NET 控制台应用程序来测试该服务。 Visual Studio 生成了一个客户端,并且该服务按预期工作。我的问题是我需要从 Java 应用程序中使用此服务,但是当我尝试使用 Apache Axis 在 Eclipse 中生成客户端时,出现以下错误:

IWAB0399E Error in generating Java from WSDL: java.io.IOException: Emitter failure.
There is an undefined portType (AuthenticationService) in the WSDL document
http://localhost:17637/Services/AuthenticationService.svc?wsdl=wsdl0.
Hint: make sure <binding type=".."> is fully qualified.

感谢this post,我已将其追踪到 Apache Axis 在 ServiceContract 和 ServiceBehavior 中需要不同的命名空间和名称。正如该帖子所示,我已经更改了其他 WCF 服务,它们工作得很好。问题是 System.Web.ApplicationServices.AuthenticationService 看起来像这样(来自http://msdn.microsoft.com/en-us/library/system.web.applicationservices.authenticationservice.aspx):

[ServiceBehaviorAttribute(Namespace = "http://asp.net/ApplicationServices/v200", InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
[AspNetCompatibilityRequirementsAttribute(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceContractAttribute(Namespace = "http://asp.net/ApplicationServices/v200")]
public class AuthenticationService

注意 ServiceBehaviorAttribute 命名空间与 ServiceContractAttribute 命名空间相同吗?我需要它们不同,这样我才能让 Eclipse(Apache Axis)生成客户端。有什么想法吗?

【问题讨论】:

    标签: java .net wcf forms-authentication axis


    【解决方案1】:

    我认为无法更改内置服务的名称。您应该被允许在其他服务中包装内置服务或编写自定义服务句柄身份验证。

    【讨论】:

    • 几年前我最终推出了自己的身份验证服务来解决这个问题。这个问题已经很久没有回答了,我没想到会有答案。谢谢!
    猜你喜欢
    • 2012-06-10
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 1970-01-01
    • 2011-03-07
    • 2019-01-16
    相关资源
    最近更新 更多