Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB VB.NET
I have added a service reference to my Web Project by just creating an assembly and right clicking on it to "Add a service Reference..." now I just provide the WSDL path and created a service reference.
 
I am able to get all the method names and the parameter type from the object of this reference.Even I am able to successfully invoke the service.
 
For Example :
SecurityProcessHandler objProcessHandler = new SecurityProcessHandler();
string objReturn = objProcessHandler.getUserDataForLogin(objInput);
 
My problem is that I now need to add a header info to the request while invoking the service and the header info in SOAP format is as follows:
 
<soapenv:Header>
    <wss:Security
    xmlns:wss="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <wss:UsernameToken>
            <wss:Username>SRVNEST</wss:Username>
        </wss:UsernameToken>
    </wss:Security>
    <ent:EnterpriseContext
  xmlns:ent="http://contracts.it.nednet.co.za/Infrastructure/2008/09/EnterpriseContext">
       <ent:ContextInfo>
            <ent:ExecutionContextId>568e7eee-8b24-4865-9071-bad8506e3e61</ent:ExecutionContextId>
        </ent:ContextInfo>
        <ent:RequestOriginator>
            <ent:MachineIPAddress>10.58.42.55</ent:MachineIPAddress>
            <ent:UserPrincipleName>SRVNEST</ent:UserPrincipleName>
            <ent:MachineDNSName>nedicad</ent:MachineDNSName>
            <ent:ChannelId>0</ent:ChannelId>
        </ent:RequestOriginator>
        <ent:InstrumentationInfo>
            <ent:ParentInstrumentationIdElem>f44c492d-e57f-4f39-b549-74f23b61dfe7</ent:ParentInstrumentationIdElem>
        </ent:InstrumentationInfo>
    </ent:EnterpriseContext>
</soapenv:Header>
 

Now I don't know how to add a header info to my service call.
Is it possible to add header info to my service? I tried in google but with no success.
Posted 17-Dec-12 3:32am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I'm not sure if this is what you mean. But you can create a security token for the SOAP header via:
 
// Create the WS-Security token for the SOAP header
UsernameToken userToken = new UsernameToken(uid, pswd, PasswordOption.SendPlainText);
service.RequestSoapContext.Security.Tokens.Add(userToken);
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 645
1 Maciej Los 225
2 Abhinav S 171
3 Richard Deeming 160
4 Suvendu Shekhar Giri 159
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,135
2 Peter Leow 5,042
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581


Advertise | Privacy | Mobile
Web02 | 2.8.150327.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100