Question

I am trying to consume this service that requires wsse header as

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

I am creating proxy dynamically as

    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[].....

How do I pass header to this. I did some research and installed WSE 3.0 and added reference for service3. However i am not able to get RequestSoapContext or clientcredential method in t. client(o) is being generated from soaphttpclientprotocol and not WebServicesClientProtocol and that should be cause of all problems. Please help.

Also since generating proxy dynamically , not sure i can do like

       MessageServiceWse client = new MessageServiceWse()

Also I am not sure about wsse type . How to define this. Just to note that I am using VS 2010

This is my first service experience so please excuse me in case I did some obvious mistake(s). Need expert help.

Was it helpful?

Solution

changed end point to include header as it is common across request.

  <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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top