0

我想消费这种服务需要我如何通过头WSSE头为通过WSSE安全头部与dynamicserviceproxy

<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方法。客户端(o)正在从soaphttpclientprotocol生成,而不是WebServicesClientProtocol,这应该是所有问题的原因。请帮忙。

此外,由于动态生成代理,不知道我能做到像

 MessageServiceWse client = new MessageServiceWse() 

而且我不知道有关WSSE类型。如何定义这个。 只是要注意,我正在使用VS 2010

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

回答

0

将端点更改为包含标头,因为它在请求中是通用的。

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

没有更多的动态代理。添加为web参考并将web.config更改为包含标题 – Purvin 2013-04-01 19:37:47