【问题标题】:passing wsse security header with dynamicserviceproxy使用动态服务代理传递 wsse 安全标头
【发布时间】:2013-03-19 20:42:36
【问题描述】:

我正在尝试使用这个需要 wsse 标头的服务

   <soapenv:Header>
  <wsse:Security soapenv:actor="AppID" soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
     <wsse:UsernameToken>
        <wsse:Username>domain1\UNM1</wsse:Username>
        <wsse:Password wsse:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PWD1</wsse:Password>
     </wsse:UsernameToken>
  </wsse:Security>

我正在动态创建代理

    string[] assemblyReferences = new string[3] { "System.Web.Services.dll", "System.Xml.dll", "Microsoft.Web.Services3.dll" };
        CompilerParameters parms = new CompilerParameters(assemblyReferences);
        CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1);

        if (results.Errors.Count > 0)
        {
            foreach (CompilerError oops in results.Errors)
            {
                Console.WriteLine("========Compiler error============");
                Console.WriteLine(oops.ErrorText);
            }
            return;
        }        


        //Invoke the web service method
        object o = results.CompiledAssembly.CreateInstance("DynamicServiceProxy.servicename");
        //object o = results.CompiledAssembly.CreateInstance("DynamicServiceProxy.WebService");

        Type t = o.GetType();
       BindingFlags bf = BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.DeclaredOnly;

        MethodInfo m = t.GetMethod("Methodname", bf);
     stroutput = (string) m.Invoke(o, new object[].....

如何将标头传递给此。我做了一些研究并安装了 WSE 3.0 并为 service3 添加了参考。但是我无法在 t 中获取 RequestSoapContext 或 clientcredential 方法。 client(o) 是从 soaphttpclientprotocol 而不是 WebServicesClientProtocol 生成的,这应该是所有问题的原因。请帮忙。

而且由于动态生成代理,我不确定我是否可以这样做

       MessageServiceWse client = new MessageServiceWse()

我也不确定 wsse type 。这个怎么定义。 请注意,我使用的是 VS 2010

这是我的第一次服务体验,如果我犯了一些明显的错误,请原谅。 需要专家帮助。

【问题讨论】:

    标签: header wsse soaphttpclientprotocol web-services-enhancements


    【解决方案1】:

    将端点更改为包含标头,因为它在请求中很常见。

      <endpoint address="https://wsext.test.com/gfr/ext/test1/"
        binding="basicHttpBinding" bindingConfiguration="GLEditServiceSOAP"
        contract="test1.GLEditServicePort" name="GLEditServicePort">
    
        <headers  >
          <wsse:Security  s:actor="AppID" s:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
            <wsse:UsernameToken>
              <wsse:Username>test1\testuserid</wsse:Username>
              <wsse:Password wsse:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
            </wsse:UsernameToken>
          </wsse:Security>
        </headers>
      </endpoint>
    

    【讨论】:

    • 不再有动态代理。添加为网络参考并更改 web.config 以包含标题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多