c# - Getting "Unable to extract the User from the SOAP Header" exception -
here while making request web service getting exception faultexceptionwas un handled message unable extract user soap header code below.
static void main(string[] args) { request.servicesexternalclient se = new request.servicesexternalclient(); se.clientcredentials.username.username = "username"; se.clientcredentials.username.password = "password1"; bindingelementcollection elements = se.endpoint.binding.createbindingelements(); elements.add(securitybindingelement.createusernameforsslbindingelement()); system.uri uri = new system.uri("--url--"); se.endpoint.listenuri = uri; stringbuilder xml = new stringbuilder(); xml.append(@"<?xml version=""1.0"" encoding=""utf-8""?>"); xml.append(@"<newinvoicerequest >"); xml.append(@"<tracinglevel>off</tracinglevel>"); ' ' ' ' ' ' ' xml.append(@"</newinvoicerequest>"); request.newinvoicerequest newinvrequest = new request.newinvoicerequest(); request.invoice inv = new request.invoice(); using (memorystream stream = new memorystream()) { xmlserializer s = new xmlserializer(typeof(request.newinvoicerequest)); streamwriter sw = new streamwriter(stream); using (stringreader sr = new stringreader(xml.tostring())) { newinvrequest = (request.newinvoicerequest)s.deserialize(sr); } } request.newinvoiceresponse res = se.createnewinvoice(newinvrequest); }
wiki
Comments
Post a Comment