我正在尝试使用需要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方法。客户端(o)是从soaphttpclientprotocol生成的,而不是WebServicesClientProtocol,这应该是所有问题的原因。请帮忙。
此外,由于动态生成代理,不确定我能做什么
MessageServiceWse client = new MessageServiceWse()
我也不确定wsse类型。如何定义这个。 请注意我正在使用VS 2010
这是我的第一次服务体验,所以请原谅我,以防我做了一些明显的错误。 需要专家帮助。
答案 0 :(得分: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>