c# - how can i access webservice using auth header -


how access webservice. i.i new field.i have service authentication function. please me access this.

<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">   <soap:header>     <mqusernametoken xmlns="http://tempuri.org/">       <user_id>string</user_id>       <password>string</password>       <externalpartyname>string</externalpartyname>     </mqusernametoken>   </soap:header>   <soap:body>     <getcustomerinfo xmlns="http://tempuri.org/">       <customerinfoxml>string</customerinfoxml>       <referenceno>string</referenceno>     </getcustomerinfo>   </soap:body> </soap:envelope> 

configure ur envelope's headerout

    envelope.headerout= new element[1];     envelope.headerout[0] = buildauthheader(user_id,pwd,externalpartyname); 

define buildauthheader method follows

private element buildauthheader(string user_id, string pwd, string externalpartyname) {          element h = new element().createelement(namespace,"mqusernametoken");         element username = new element().createelement(namespace, "user_id");            username.addchild(node.text,user_id);         h.addchild(node.element, username);          element password = new element().createelement(namespace, "password");         password.addchild(node.text,pwd);         h.addchild(node.element, password);          element externalparty= new element().createelement(namespace, "externalpartyname");         pass.addchild(node.text,externalpartyname);         h.addchild(node.element, externalpartyname);         }         return h; } 

Comments