zoukankan      html  css  js  c++  java
  • Web Service Client使用Microsoft WSE 2.0

    我安装了WSE 2.0 SP3,Setup Type选择Runtime。如果想要让Visual Studio 2005以上版本集成WSE需稍费周折,默认集成Visual Studio 2005。

    1、引用Microsoft.Web.Services2.dll。

    2、修改Visual Studio自动生成的Web Service Client,继承Microsoft.Web.Services2.WebServicesClientProtocol(如果Update Web Reference需要再次手动编辑)。

    3、假设对方的Web Service需要提供WS-Securtiy简单的Username Token认证,但我们不需要对Response进行校验,需要实现自定义的UsernameTokenManager(不同的PasswordOption重写对应的VerifyPassword)。下面以PasswordOption.SendHashed为例:

    public class CustomUsernameTokenManager : UsernameTokenManager
    {
        protected override void VerifyHashedPassword(UsernameToken token, String authenticatedPassword)
        {
    
        }
    }

    4、配置securityTokenManager:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="microsoft.web.services2"
                 type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </configSections>
    
      <microsoft.web.services2>
        <security>
          <securityTokenManager xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
                                qname="wsse:UsernameToken"
                                type="Demo.CustomUsernameTokenManager, Demo"/>
        </security>
      </microsoft.web.services2>
    </configuration>
  • 相关阅读:
    论架构在嵌软设计中的重要性
    妙用typeof关键字
    说说动态内存分配
    3个实用shell脚本,建议收藏!
    GNU C语法扩展(7)
    Ubunt_配置_nfs(文件挂载)
    Ubunt_配置_samba(文件共享)
    Ubunt_配置_tftp(文件传输)
    Ubunt_配置_net
    驱动_Platform平台总线
  • 原文地址:https://www.cnblogs.com/junchu25/p/3904317.html
Copyright © 2011-2022 走看看