java - WCF 身份验证服务 - 如何使用 Apache Axis 生成客户端?

标签 java .net wcf forms-authentication axis

我有一个托管一些 WCF 服务的 ASP.NET 应用程序,使用 ASP.NET 成员资格来确保安全。我已经通过 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 - WCF 身份验证服务 - 如何使用 Apache Axis 生成客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7199739/

相关文章:

从sql数据库列获取最大值时java列未找到异常

java - 如何在Java中优化这种代码?

java - 通过Java代码获取MasterNotRunningException

json - InstanceContextMode.WCF wsHttpBinding、webHttpBinding 和 REST 中的 Single

wcf - 从 Web.config 启用 net.tcp 协议(protocol)

wcf - WCF 中的服务契约是什么?

java - "for"循环没有按照我想要的方式迭代

c# - 如何使用 C# 和 .NET 3.5 创建 SAML 2.0 响应?

c# - 去除图像透明度

c# - 是否可以在已经创建的实例上直接调用构造函数?