现在的位置: 首页 > 综合 > 正文

采用类似Java WS-*的方式,在一个ASP.NET服务中将不同的类暴露为多个的Port

2012年03月18日 ⁄ 综合 ⁄ 共 1606字 ⁄ 字号 评论关闭

下面是JBoss的一个SSO的例子片断:

  • sso2.war#RoleComponent (wsdl)
    • getRoles
    • getTheRoleFunctions
    • getTheRoleFunctionsByCode
    • getTheSystemRoles
    • getUserBySystemNameAndRoleId
    • isFunctionInRole
  • sso2.war#UserComponent (wsdl)
    • Login
    • LoginUser
    • getFilterNodes
    • getFunctions
    • getTheUserFunctions
    • getTheUserNodes
    • getTheUserRoles
    • getTheUserRoles2
    • getUserByID
    • getUsers
    • isInFunction
    • isInFunctionByCode
    • isInRole
    • isInRoleByCode
    • getUsers
  • sso.war#RoleComponent (wsdl)
    • getRoles
    • getTheRoleFunctions
    • getTheRoleFunctionsByCode
    • getTheSystemRoles
    • getUserBySystemNameAndRoleId
  • 不难看出在一个Service中,提供了不同的类,以及WebMethod。
    但如果在ASP.NET Web Service中直接登记2个会出现下列错误:
     

    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: There can be only one 'webservice' directive.

    Source Error:

     
    Line 1:  <%@ WebService Language="C#" CodeBehind="UserService.asmx.cs" Class="Inventory.UserService" %>
    Line 2:  <%@ WebService Language="C#" CodeBehind="UserService.asmx.cs" Class="Inventory.GroupService" %>


    Source File: /UserService.asmx    Line: 2

    所以如果要采用类似方式剔掉Java的Web Service,同时又不让服务客户程序修改过多代码,可以采用Port来分割一个Web Service:
     

       <service name="SSOService">

    <port binding="tns:NodeServiceBinding" name="NodeServicePort">

     <soap:addresslocation="http://win2003/sso2/service/NodeService" />

         </port>

                <port binding="tns:UserServiceBinding" name="UserServicePort">

     <soap:addresslocation="http://win2003/sso2/service/UserService" />

            </port>

                <port binding="tns:RoleServiceBinding" name="RoleServicePort">

     <soap:addresslocation="http://win2003/sso2/service/RoleService" />

    </port>

     </service>

    转自:沈同学和袁同学的邮件。

    抱歉!评论已关闭.