Hello,
I have a strange problem happening when I try to update/set customer no on sales order
Creating the order via web services works ok
Dynamics NAV 2009 R2
Heres the code.
// Create Service Reference
var service = new Order.Order_Service();
service.UseDefaultCredentials = true;
// Create the Order header
var newOrder = new Order.Order();
newOrder.No = "WEB12035";
service.Create(ref newOrder);
Order.Order getOrder = new Order.Order();
getOrder = service.Read("WEB12035");
getOrder.Sell_to_Customer_No = "1004003";
service.Update(ref getOrder);
service.Update(ref getOrder) generates Soapexception "Object reference is not set to an instance of an object"
Service:
User:
Type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
StackTrace:
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceForm.WriteField(MetaControl control, String value)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.WriteEntity(XmlElement entity)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.ModifyEntity(XmlElement entity, Boolean versionCheckHasBeenDone)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.<>c__DisplayClass24.<Update>b__1f()
at Microsoft.Dynamics.Nav.Runtime.NavConnection.TransactionScope(TransactedCode code)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.Update(XmlElement input, XmlWWriter output)
Source: Microsoft.Dynamics.Nav.Service.WebServices
Service: MicrosoftDynamicsNavWS
Type: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.<>c__DisplayClass3d.<Microsoft.Dynamics.Nav.Service.WebServices.IXmlRequestHandler.Dispatch>b__39()
at Microsoft.Dynamics.Nav.Service.WebServices.XmlWWriter.SetNamespace(QNamespace namespace, XmlCallback nodeHandler)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.Microsoft.Dynamics.Nav.Service.WebServices.IXmlRequestHandler.Dispatch(XmlElement input, XmlWWriter output)
at Microsoft.Dynamics.Nav.Service.WebServices.SoapHandler.<>c__DisplayClass4.<Microsoft.Dynamics.Nav.Service.WebServices.IXmlRequestHandler.Dispatch>b__0()
at Microsoft.Dynamics.Nav.Service.WebServices.SoapHandler.<>c__DisplayClass9.<BuildEnvelop>b__8()
at Microsoft.Dynamics.Nav.Service.WebServices.XmlWWriter.Element(String name, XmlCallback elementHandler)
at Microsoft.Dynamics.Nav.Service.WebServices.SoapHandler.<>c__DisplayClass9.<BuildEnvelop>b__7()
at Microsoft.Dynamics.Nav.Service.WebServices.XmlWWriter.Element(String name, XmlCallback elementHandler)
at Microsoft.Dynamics.Nav.Service.WebServices.SoapHandler.<>c__DisplayClass9.<BuildEnvelop>b__6()
at Microsoft.Dynamics.Nav.Service.WebServices.XmlWWriter.SetNamespace(QNamespace namespace, XmlCallback nodeHandler)
at Microsoft.Dynamics.Nav.Service.WebServices.SoapHandler.BuildEnvelop(XmlWWriter output, ContentHandler handler)
at Microsoft.Dynamics.Nav.Service.WebServices.SoapHandler.Microsoft.Dynamics.Nav.Service.WebServices.IXmlRequestHandler.Dispatch(XmlElement input, XmlWWriter output)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceBroker.DispatchSoap(UrlParser relivantURLPart, XmlReader input, TextWriter output)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceBroker.Invoke(Boolean isSoapMessage, String serviceName, Uri url, XmlReader input, TextWriter output, String sid)
Source: mscorlib
Type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
StackTrace:
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceForm.WriteField(MetaControl control, String value)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.WriteEntity(XmlElement entity)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.ModifyEntity(XmlElement entity, Boolean versionCheckHasBeenDone)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.<>c__DisplayClass24.<Update>b__1f()
at Microsoft.Dynamics.Nav.Runtime.NavConnection.TransactionScope(TransactedCode code)
at Microsoft.Dynamics.Nav.Service.WebServices.ServiceFormXmlAdapter.Update(XmlElement input, XmlWWriter output)
Source: Microsoft.Dynamics.Nav.Service.WebServices
Comments
Pargesoft
And when you debug, is order object null on Update line?
Pargesoft
Thanks for looking into this.
I have debugged oninsert and customer no validation trigger in the table. I beleive its the record36.cs source file. No problem there.
I think the problem is in the generated proxy class for the web service. In my event log it says:
Object reference not set to an instance of an object.
Line 393: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:microsoft-dynamics-schemas/page/order:Update", RequestNamespace="urn:microsoft-dynamics-schemas/page/order", ResponseElementName="Update_Result", ResponseNamespace="urn:microsoft-dynamics-schemas/page/order", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 394: public void Update(ref Order Order) {
Line 395: object[] results = this.Invoke("Update", new object[] {
Line 396: Order});
Line 397: Order = ((Order)(results[0]));
Source File: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\navweborder002\311bdc07\37869510\App_WebReferences.qsq7mnha.0.cs
Is it possible to debug the proxy?
Pargesoft