Nav 2009 R2 WebService

bnornes
Member Posts: 4
Anyone with a solution to this ?
Customer_Card_Service css = new Customer_Card_Service();
css.Credentials = CredentialCache.DefaultCredentials;
Customer_Card cust = new Customer_Card();
cust.Name = "TEST";
css.Create(ref cust);
This code errors with :
Customer No. '' does not exist.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Services.Protocols.SoapException: Customer No. '' does not exist.
Source Error:
Line 307: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:microsoft-dynamics-schemas/page/customer_card:Create", RequestNamespace="urn:microsoft-dynamics-schemas/page/customer_card", ResponseElementName="Create_Result", ResponseNamespace="urn:microsoft-dynamics-schemas/page/customer_card", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 308: public void Create(ref Customer_Card Customer_Card) {
Line 309: object[] results = this.Invoke("Create", new object[] {
Line 310: Customer_Card});
Line 311: Customer_Card = ((Customer_Card)(results[0]));
Stack Trace:
[SoapException: Customer No. '' does not exist.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +507386
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +215
Customer_Card_Ref.Customer_Card_Service.Create(Customer_Card& Customer_Card) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\2f133f42\e78cef49\App_WebReferences._eb_3n10.8.cs:309
crm2011_accountcreate_to_navision.Page_Load(Object sender, EventArgs e) in d:\Userfiles\My Documents\Visual Studio 2012\Projects\pcsdoc4\pcsdoc4\crm2011\accountcreate_to_navision.aspx.cs:89
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
Customer_Card_Service css = new Customer_Card_Service();
css.Credentials = CredentialCache.DefaultCredentials;
Customer_Card cust = new Customer_Card();
cust.Name = "TEST";
css.Create(ref cust);
This code errors with :
Customer No. '' does not exist.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Services.Protocols.SoapException: Customer No. '' does not exist.
Source Error:
Line 307: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:microsoft-dynamics-schemas/page/customer_card:Create", RequestNamespace="urn:microsoft-dynamics-schemas/page/customer_card", ResponseElementName="Create_Result", ResponseNamespace="urn:microsoft-dynamics-schemas/page/customer_card", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 308: public void Create(ref Customer_Card Customer_Card) {
Line 309: object[] results = this.Invoke("Create", new object[] {
Line 310: Customer_Card});
Line 311: Customer_Card = ((Customer_Card)(results[0]));
Stack Trace:
[SoapException: Customer No. '' does not exist.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +507386
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +215
Customer_Card_Ref.Customer_Card_Service.Create(Customer_Card& Customer_Card) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\2f133f42\e78cef49\App_WebReferences._eb_3n10.8.cs:309
crm2011_accountcreate_to_navision.Page_Load(Object sender, EventArgs e) in d:\Userfiles\My Documents\Visual Studio 2012\Projects\pcsdoc4\pcsdoc4\crm2011\accountcreate_to_navision.aspx.cs:89
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
0
Comments
-
Hi,
This is strange it looks like the variable "cust" is not instantiated at all.
It is difficult to say what is wrong as we also need to see the definition for the variables.
The correct code
https://msdn.microsoft.com/en-us/library/dd355316%28v=nav.80%29.aspx
isCustomer_Service service = new Customer_Service(); service.UseDefaultCredentials = true; // Creates instance of customer. Customer cust = new Customer(); cust.Name = "Customer Name"; Msg("Pre Create"); PrintCustomer(cust);
While in your case
Customer_Card_Service css = new Customer_Card_Service();
css.Credentials = CredentialCache.DefaultCredentials;
Customer_Card cust = new Customer_Card();
cust.Name = "TEST";
css.Create(ref cust);
So the line in read is wrong as this is not the correct variable for cust record.
You can also take a look at this example
http://moodle2.karelia.fi/mod/page/view.php?id=85476
I hope this helps
Thanks.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions