I am getting a 401 error when I am sending a soap request to a nav web service -


i trying send xml soap request dynamics nav web service. xml wsdl. have created web access key , 1 in key parameter of xml.

<s11:envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>   <s11:body>     <ns1:create xmlns:ns1='urn:microsoft-dynamics-schemas/page/customerws'>       <ns1:customerws>         <ns1:key>+gn8nu4i7iw7d/g9vcai8hze5iei1nbktbqdp5qfxe4=</ns1:key>         <ns1:shipping_advice></ns1:shipping_advice>         <ns1:shipment_method_code></ns1:shipment_method_code>         <ns1:shipping_agent_code></ns1:shipping_agent_code>         <ns1:shipping_agent_service_code></ns1:shipping_agent_service_code>         <ns1:shipping_time></ns1:shipping_time>         <ns1:base_calendar_code></ns1:base_calendar_code>         <ns1:customized_calendar></ns1:customized_calendar>         <ns1:currency_code></ns1:currency_code>         <ns1:language_code></ns1:language_code>         <ns1:vat_registration_no></ns1:vat_registration_no>       </ns1:customerws>     </ns1:create>   </s11:body> </s11:envelope> 

and code using send request:

console.writeline("we have started");                                                 string pagename = "http://hrp-dmu.uganda.hrpsolutions.co.ug:9047/dynamicsnav80/ws/uganda%20management%20institute/page/customerws";                         httpwebrequest req = (httpwebrequest)webrequest.create(pagename);             req.method = "post";             req.contenttype = "text/xml;charset=utf-8";             req.protocolversion = new version(1, 1);             req.headers.add("soapaction", @"urn:microsoftdynamicsschemas/page/customerws:create");                         console.writeline("after preparing request object");             string xmlrequest = gettextfromxmlfile("e:\\tst3.xml");             console.writeline("xml request : "+xmlrequest);             byte[] reqbytes = new utf8encoding().getbytes(xmlrequest);             req.contentlength = reqbytes.length;             try             {                 using (stream reqstream = req.getrequeststream())                 {                     reqstream.write(reqbytes, 0, reqbytes.length);                 }             }             catch (exception ex)             {                 console.writeline("getrequeststreamexception : " + ex.message);             }             httpwebresponse resp = null;             try             {                 resp = (httpwebresponse)req.getresponse();             }             catch (exception exc)             {                 console.writeline("getresponseexception : " + exc.message);             }             string xmlresponse = null;             if (resp == null)             {                 console.writeline("null response");             }             else             {                 using (streamreader sr = new streamreader(resp.getresponsestream()))                 {                     xmlresponse = sr.readtoend();                 }                 console.writeline("the response");                 console.writeline(xmlresponse);             }             console.readkey(); 

when using navuserpassword authentication you'll need certificate.

see here on msdn

cheers!


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -