我正在尝试使用这个需要wsse header作为
的服务 <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>domain1UNM1</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[].....
如何传递header到this。我做了一些研究,安装了WSE 3.0,并为service3添加了参考。然而,我无法在t中获得RequestSoapContext或clientcredential方法。client(o)正在从soaphttpclientprotocol而不是WebServicesClientProtocol生成,这应该是所有问题的原因。请帮助。
也因为动态生成代理,不确定我可以做像
MessageServiceWse client = new MessageServiceWse()
我也不确定wsse类型。如何定义这个。要注意的是,我使用的是VS 2010
这是我的第一次服务经验,所以如果我犯了一些明显的错误,请原谅。需要专家帮助将end point更改为包含header,因为它在所有请求中都是常见的。
<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>test1testuserid</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>