2017-09-13 53 views
0

嘿傢伙我已經在我的代碼有這一行的一個問題,而試圖插入到客戶表中資產淨值ID真的很感激任何反饋和可能的解決我的問題。 service.Create(參考文獻custArray); 我執行完整的代碼如下; **肯尼迪是我的web服務。公開Web服務中插入批次記錄對資產淨值

namespace PrintCustomerList 
    { 
    // Import newly generated Web service proxy. 
    using System; 
    using System.Collections.Generic; 
    using System.Text; 
    using System.Net; 
    using kenedy; 
    using System.Diagnostics; 
    using System.Xml; 

    class Program 
    { 


    static void Main(string[] args) 
    { 
     var service = new Customer_Service(); 
     service.UseDefaultCredentials = true; 
     service.Credentials = System.Net.CredentialCache.DefaultCredentials; 
     service.Url = "http://..:7047/DynamicsNAV90/WS/..%20LIMITED/Page/Customer"; 
     // Create instance of customer. 

     Customer custArray = new Customer(); 
     XmlDocument xmlDoc = new XmlDocument(); 
     xmlDoc.Load("C:\\Users\\..\\Desktop\\Product.xml"); 
     var nodeList = xmlDoc.DocumentElement.SelectNodes("/Table/Product"); 

     for(var i = 0; i < nodeList.Count; i++) 
     { 
      foreach (XmlNode node in nodeList) 
      { 
      custArray.Address = node.SelectSingleNode("Product_id").InnerText; 
      custArray.Name = node.SelectSingleNode("Product_name").InnerText; 
      custArray.Address_2 = node.SelectSingleNode("Product_price").InnerText; 
       Console.WriteLine(custArray.Name); 

      } 

     } 
     Console.WriteLine("Records Inserted"); 
     Console.WriteLine("End of Customers"); 
     Console.WriteLine("Press [ENTER] to exit program!"); 
     Console.ReadLine(); 
     service.Create(ref custArray); 


     // service.Update(ref custArray); 
     //service.CreateMultiple(ref custArray); 
     // Create instance of service and set credentials. 



    } 

} 

}}

回答

0

您必須聲明具有發佈數據的權限的用戶。將您的憑據更改爲:

NetworkCredential cred = new NetworkCredential("user", "password", "domain"); 

service.Credentials = cred; 

如果它拋出一個錯誤,請打我!