我正在尝试使用需要 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
这是我的第一次服务体验,如果我犯了一些明显的错误,请原谅我。需要专家帮助。