Moiz Saifuddin
asked on
Webservice Data
I am trying to publish using webservice along with Navision and there is a doc file stating each step on how attached.
Now my question is below is the code where I am going to parse an xml file using the streamreader object and on processing where exactly is the data going to go, into a Navision database or where...I just need to know the concept
Now my question is below is the code where I am going to parse an xml file using the streamreader object and on processing where exactly is the data going to go, into a Navision database or where...I just need to know the concept
namespace R_and_M_XMLReader
{
using Cust;
using Items;
using SaleOrd;
class Program
{
public void ReadfromXML()
{
if (!Directory.Exists(@"E:\Old_R&M_XML_files"))
Directory.CreateDirectory(@"E:\Old_R&M_XML_files");
if (Directory.Exists(@"E:\R&M_XML files"))
{
Item_Service itm_svc = new Item_Service();
itm_svc.UseDefaultCredentials = true;
itm_svc.Url = @"http://absvii.abs.com:7087/DynamicsNAVRnM/WS/R%20&%20%20M/Page/Item";
DirectoryInfo Item_di = new DirectoryInfo(@"E:\R&M_XML files");
FileInfo[] Item_files = Item_di.GetFiles(@"*.xml");
foreach (FileInfo file in Item_files)
{
StreamReader Item_sr = new StreamReader(file.DirectoryName + @"\" + file.Name);
XmlDocument ItemXML = new XmlDocument();
ItemXML.LoadXml(Item_sr.ReadToEnd());
Item_sr.Close();
Item itm;
XmlNodeList nodelist = ItemXML.SelectNodes("/Items/item");
foreach (XmlNode node in nodelist)
{
string itmnum = String.Empty;
try
{
itm = new Item();
itm.No = node["itemNumber"].InnerText;
itmnum = itm.No;
itm_svc.Create(ref itm);
itm.Item_Category_Code = node["productGroup"].InnerText;
itm.Product_Group_Code = node["productGroup2"].InnerText;
itm.Description = node["articleDescription"].ChildNodes[1].InnerText.Substring(0,30);
itm.Business_Product_Group = node["kernelProductGroup"].InnerText;
itm.Units_per_Parcel = decimal.Parse(node["packingUnit"].InnerText);
itm.Excise_Prod_Posting_Group = node["customsTariffNumber"].InnerText;
itm.Country_Region_of_Origin_Code = node["itemProductionCountry"].InnerText;
itm.Net_Weight = decimal.Parse(node["netWeight"].InnerText);
itm.Minimum_Order_Quantity = decimal.Parse(node["minimumOrderQuantity"].InnerText);
itm.Reordering_Policy = Reordering_Policy.Lot_for_Lot;
itm.Large_Description = node["articleDescription"].ChildNodes[1].InnerText;
itm_svc.Update(ref itm);
Console.WriteLine("Item Created Successfully");
}
catch (Exception ex)
{
itm_svc.Delete(itmnum);
Console.WriteLine(ex.ToString());
}
}
}
}
static void Main(string[] args)
{
Program pg = new Program();
pg.ReadfromXML();
}
Build-on-CLIENTSIDE.docx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The Exception detail below....
System.Net.WebException was caught
Message=The remote name could not be resolved: 'items'
Source=System
StackTrace:
at System.Net.HttpWebRequest. GetRequest Stream(Tra nsportCont ext& context)
at System.Net.HttpWebRequest. GetRequest Stream()
at System.Web.Services.Protoc ols.SoapHt tpClientPr otocol.Inv oke(String methodName, Object[] parameters)
at R_and_M_XMLReader.items.It em_Service .Create(It em& Item) in C:\Users\abs_sali\Document s\Visual Studio 2010\Projects\R and M XMLReader\R and M XMLReader\Web References\items\Reference .cs:line 278
at R_and_M_XMLReader.Program. ReadfromXM L() in C:\Users\abs_sali\Document s\Visual Studio 2010\Projects\R and M XMLReader\R and M XMLReader\Program.cs:line 82
InnerException:
System.Net.WebException was caught
Message=The remote name could not be resolved: 'items'
Source=System
StackTrace:
at System.Net.HttpWebRequest.
at System.Net.HttpWebRequest.
at System.Web.Services.Protoc
at R_and_M_XMLReader.items.It
at R_and_M_XMLReader.Program.
InnerException:
ASKER
itm_svc.Create(ref itm);
exception.docx