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

发布于 2024-12-01 06:48:28 字数 2871 浏览 5 评论 0原文

我有一个托管一些 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.

I've tracked it to Apache Axis need different namespace and name in 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) 生成客户端。有什么想法吗?

I have an ASP.NET application hosting a few WCF services, using ASP.NET Membership for security. I've exposed the System.Web.ApplicationServices.AuthenticationService through an SVC file (AuthenticationService.svc) as shown below:

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

My WCF configuration for this service is as follows:

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

I've enabled the authentication service in my web.config as shown below:

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

I created a .NET console application to test the service. Visual Studio generated a client, and the service worked as expected. My problem is that I need to use this service from a Java application, but when I try to generate a client in Eclipse using Apache Axis, I get the following error:

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.

I've tracked it down to Apache Axis needing different namespace and name in the ServiceContract and ServiceBehavior, thanks to this post. I've changed other WCF services as that post shows, and they work just fine. The problem is that System.Web.ApplicationServices.AuthenticationService looks like this (from 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

Notice the ServiceBehaviorAttribute namespace is the same as the ServiceContractAttribute namespace? I need them to be different so I can get Eclipse (Apache Axis) to generate a client. Any ideas?

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

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

发布评论

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

评论(1

情话墙 2024-12-08 06:48:28

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

I do not think is possible to change name of built-in service. You should be allowed for wrapping built-in service in other service or for writing custom service handle authentication.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文