Answered by:
SOAP create contract

Question
-
Hi. I wont to create new contract by SOAP service from javascript in crmForm.onload() event.
I make request as in CRM SDK help example
Request (without header):
<soap:Body><Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>
<entity xsi:type='contract'>
<new_contracttype>6</new_contracttype>
<new_invoice_contract>028505BB-454C-DF11-A4C5-D8D3855D64BD</new_invoice_contract>
<customerid type="account">F70237F1-0517-DF11-BE9B-0015F2CC5159</customerid>
<contracttemplateid>e249e01b-2abe-de11-a291-0015f2cc5159</contracttemplateid>
<billingcustomerid>F70237F1-0517-DF11-BE9B-0015F2CC5159</billingcustomerid>
<title>myContract</title>
<activeon>2010-07-21T02:28:00</activeon>
<expireson>2011-07-21T02:28:00</expireson></entity>
</Create></soap:Body>
</soap:Envelope>
Result (full):
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body><soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request.</faultstring>
<detail>
<error>
<code>0x80040216</code>
<description>An unexpected error occurred.</description>
<type>Platform</type>
</error>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>whatisit: 0x80040216
Please help.
Thursday, April 22, 2010 9:01 AM
Answers
-
What is this field <new_invoice_contract>028505BB-454C-DF11-A4C5-D8D3855D64BD</new_invoice_contract> ?
Is it a Lookup, if yes then the field name is most likely wrong.
Also you can use tracing to see if a more informed error can be found.
MSCRM Bing'd - http://bingsoft.wordpress.com- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:48 AM
Thursday, April 22, 2010 9:19 AMModerator -
Yes new_invoice_contract - user defined field. type - lookup. Name is correct. : \
full trece log for error (i read it, and not have new ideas : \ ):
# CRM Tracing Version 2.0
# LocalTime: 2010-04-22 16:33:48.1
# Categories: *:Error
# CallStackOn: Yes
# ComputerName: CRM
# CRMVersion: 4.0.7333.2741
# DeploymentType: OnPremise
# ScaleGroup:
# ServerRole: AppServer, AsyncService, DiscoveryService, WebService, ApiServer, HelpServer, DeploymentService
[2010-04-22 16:33:48.1] Process: w3wp |Organization:31ea55b4-1361-445e-b035-bceb35d162ba |Thread: 5 |Category: Platform |User: 52703f6f-18cd-de11-84c3-0015f2cc5159 |Level: Error | MessageProcessor.Execute
at MessageProcessor.Execute(PipelineExecutionContext context)
at InternalMessageDispatcher.Execute(PipelineExecutionContext context)
at ExternalMessageDispatcher.Execute(String messageName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, PropertyBag fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
at CrmServiceInternal.Create(String namespaceName, BusinessEntityBase entity, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
at CrmService.Create(BusinessEntity entity)
at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at LogicalMethodInfo.Invoke(Object target, Object[] values)
at WebServiceHandler.Invoke()
at WebServiceHandler.CoreProcessRequest()
at SyncSessionlessHandler.ProcessRequest(HttpContext context)
at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>MessageProcessor fail to process message 'Create' for 'contract'.
[2010-04-22 16:33:48.2] Process: w3wp |Organization:31ea55b4-1361-445e-b035-bceb35d162ba |Thread: 5 |Category: Platform.Sdk |User: 52703f6f-18cd-de11-84c3-0015f2cc5159 |Level: Error | CompositeSoapExtensionExceptionHandler.Handle
at CompositeSoapExtensionExceptionHandler.Handle(Stream to, Stream from, Exception exception)
at CrmAuthenticationSoapExtensionBase.ProcessMessage(SoapMessage message)
at SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
at SoapServerProtocol.WriteException(Exception e, Stream outputStream)
at WebServiceHandler.WriteException(Exception e)
at WebServiceHandler.Invoke()
at WebServiceHandler.CoreProcessRequest()
at SyncSessionlessHandler.ProcessRequest(HttpContext context)
at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>CrmSoapExtension detected non-CrmException - report will be sent to Watson:
System.Web.Services.Protocols.SoapException: Серверу не удалось обработать запрос. ---> System.Reflection.TargetInvocationException: Адресат вызова создал исключение. ---> System.NullReferenceException: В экземпляре объекта не задана ссылка на объект.
в Microsoft.Crm.ObjectModel.OMUtil.ValidateCustomer(BusinessEntity entity, Boolean update, Boolean required, String customerIdName, String customerIdTypeName, Boolean allowInactive, ExecutionContext context)
в Microsoft.Crm.ObjectModel.ContractService.Create(IBusinessEntity entity, ExecutionContext context)
--- Конец трассировки внутреннего стека исключений ---
в System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
в System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
в Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IPluginExecutionContext context)
в Microsoft.Crm.Extensibility.PluginStep.Execute(PipelineExecutionContext context)
в Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
в Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
в Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
в Microsoft.Crm.Extensibility.ExternalMessageDispatcher.Execute(String messageName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, PropertyBag fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
в Microsoft.Crm.Sdk.CrmServiceInternal.Create(String namespaceName, BusinessEntityBase entity, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
в Microsoft.Crm.Sdk.Crm2007.CrmService.Create(BusinessEntity entity)
--- Конец трассировки внутреннего стека исключений ---
[2010-04-22 16:33:52.3] Process: w3wp |Organization:31ea55b4-1361-445e-b035-bceb35d162ba |Thread: 5 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Error | ErrorInformation.LogError
at ErrorInformation.LogError()
at MainApplication.Application_Error(Object sender, EventArgs eventArguments)
at EventHandler.Invoke(Object sender, EventArgs e)
at HttpApplication.RaiseOnError()
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Thursday, April 22, 2010 10:42 AM -
Does this problem go away when you use GenerateAuthenticationHeader() in your SOAP request?
(refer SDK for the usage)
- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Thursday, April 22, 2010 12:33 PM -
Ok, it is just that it looks like the relationship name and not the attribute name as it should have id at the end of the attribute name unless you changed it. I think it would have been new_invoiceid.
If this is not the case then what happens when you remove this line and then try and create a contract?
MSCRM Bing'd - http://bingsoft.wordpress.com- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Thursday, April 22, 2010 12:35 PMModerator -
I crop header of request in post. I use one function for any entity, and other entities created is successful.
- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Friday, April 23, 2010 3:17 AM -
Ok, it is just that it looks like the relationship name and not the attribute name as it should have id at the end of the attribute name unless you changed it. I think it would have been new_invoiceid.
If this is not the case then what happens when you remove this line and then try and create a contract?
MSCRM Bing'd - http://bingsoft.wordpress.comYes, really is relationship field.
I remove this fiel from SOAP request. Error trace is equal.
Now, i remove and recreate this field, i hope is fix problem.
- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Friday, April 23, 2010 3:32 AM -
Ok, it is just that it looks like the relationship name and not the attribute name as it should have id at the end of the attribute name unless you changed it. I think it would have been new_invoiceid.
If this is not the case then what happens when you remove this line and then try and create a contract?
MSCRM Bing'd - http://bingsoft.wordpress.comI remove line from soap, remove relationship from contract entity. Problem not fixed.
Is part of trace log:
>CrmSoapExtension detected non-CrmException - report will be sent to Watson:
System.Web.Services.Protocols.SoapException: Серверу не удалось обработать запрос(Server request processing is failed(my translation to English.). ---> System.Reflection.TargetInvocationException: Адресат вызова создал исключение(Caller make exception). ---> System.NullReferenceException: В экземпляре объекта не задана ссылка на объект(In the exemplar of object not defined link(relationship) to object).
в Microsoft.Crm.ObjectModel.OMUtil.ValidateCustomer(BusinessEntity entity, Boolean update, Boolean required, String customerIdName, String customerIdTypeName, Boolean allowInactive, ExecutionContext context)- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Friday, April 23, 2010 3:45 AM
All replies
-
What is this field <new_invoice_contract>028505BB-454C-DF11-A4C5-D8D3855D64BD</new_invoice_contract> ?
Is it a Lookup, if yes then the field name is most likely wrong.
Also you can use tracing to see if a more informed error can be found.
MSCRM Bing'd - http://bingsoft.wordpress.com- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:48 AM
Thursday, April 22, 2010 9:19 AMModerator -
Yes new_invoice_contract - user defined field. type - lookup. Name is correct. : \
full trece log for error (i read it, and not have new ideas : \ ):
# CRM Tracing Version 2.0
# LocalTime: 2010-04-22 16:33:48.1
# Categories: *:Error
# CallStackOn: Yes
# ComputerName: CRM
# CRMVersion: 4.0.7333.2741
# DeploymentType: OnPremise
# ScaleGroup:
# ServerRole: AppServer, AsyncService, DiscoveryService, WebService, ApiServer, HelpServer, DeploymentService
[2010-04-22 16:33:48.1] Process: w3wp |Organization:31ea55b4-1361-445e-b035-bceb35d162ba |Thread: 5 |Category: Platform |User: 52703f6f-18cd-de11-84c3-0015f2cc5159 |Level: Error | MessageProcessor.Execute
at MessageProcessor.Execute(PipelineExecutionContext context)
at InternalMessageDispatcher.Execute(PipelineExecutionContext context)
at ExternalMessageDispatcher.Execute(String messageName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, PropertyBag fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
at CrmServiceInternal.Create(String namespaceName, BusinessEntityBase entity, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
at CrmService.Create(BusinessEntity entity)
at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at LogicalMethodInfo.Invoke(Object target, Object[] values)
at WebServiceHandler.Invoke()
at WebServiceHandler.CoreProcessRequest()
at SyncSessionlessHandler.ProcessRequest(HttpContext context)
at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>MessageProcessor fail to process message 'Create' for 'contract'.
[2010-04-22 16:33:48.2] Process: w3wp |Organization:31ea55b4-1361-445e-b035-bceb35d162ba |Thread: 5 |Category: Platform.Sdk |User: 52703f6f-18cd-de11-84c3-0015f2cc5159 |Level: Error | CompositeSoapExtensionExceptionHandler.Handle
at CompositeSoapExtensionExceptionHandler.Handle(Stream to, Stream from, Exception exception)
at CrmAuthenticationSoapExtensionBase.ProcessMessage(SoapMessage message)
at SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
at SoapServerProtocol.WriteException(Exception e, Stream outputStream)
at WebServiceHandler.WriteException(Exception e)
at WebServiceHandler.Invoke()
at WebServiceHandler.CoreProcessRequest()
at SyncSessionlessHandler.ProcessRequest(HttpContext context)
at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>CrmSoapExtension detected non-CrmException - report will be sent to Watson:
System.Web.Services.Protocols.SoapException: Серверу не удалось обработать запрос. ---> System.Reflection.TargetInvocationException: Адресат вызова создал исключение. ---> System.NullReferenceException: В экземпляре объекта не задана ссылка на объект.
в Microsoft.Crm.ObjectModel.OMUtil.ValidateCustomer(BusinessEntity entity, Boolean update, Boolean required, String customerIdName, String customerIdTypeName, Boolean allowInactive, ExecutionContext context)
в Microsoft.Crm.ObjectModel.ContractService.Create(IBusinessEntity entity, ExecutionContext context)
--- Конец трассировки внутреннего стека исключений ---
в System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
в System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
в Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IPluginExecutionContext context)
в Microsoft.Crm.Extensibility.PluginStep.Execute(PipelineExecutionContext context)
в Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
в Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
в Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
в Microsoft.Crm.Extensibility.ExternalMessageDispatcher.Execute(String messageName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, PropertyBag fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
в Microsoft.Crm.Sdk.CrmServiceInternal.Create(String namespaceName, BusinessEntityBase entity, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
в Microsoft.Crm.Sdk.Crm2007.CrmService.Create(BusinessEntity entity)
--- Конец трассировки внутреннего стека исключений ---
[2010-04-22 16:33:52.3] Process: w3wp |Organization:31ea55b4-1361-445e-b035-bceb35d162ba |Thread: 5 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Error | ErrorInformation.LogError
at ErrorInformation.LogError()
at MainApplication.Application_Error(Object sender, EventArgs eventArguments)
at EventHandler.Invoke(Object sender, EventArgs e)
at HttpApplication.RaiseOnError()
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Thursday, April 22, 2010 10:42 AM -
Does this problem go away when you use GenerateAuthenticationHeader() in your SOAP request?
(refer SDK for the usage)
- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Thursday, April 22, 2010 12:33 PM -
Ok, it is just that it looks like the relationship name and not the attribute name as it should have id at the end of the attribute name unless you changed it. I think it would have been new_invoiceid.
If this is not the case then what happens when you remove this line and then try and create a contract?
MSCRM Bing'd - http://bingsoft.wordpress.com- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Thursday, April 22, 2010 12:35 PMModerator -
I crop header of request in post. I use one function for any entity, and other entities created is successful.
- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Friday, April 23, 2010 3:17 AM -
Ok, it is just that it looks like the relationship name and not the attribute name as it should have id at the end of the attribute name unless you changed it. I think it would have been new_invoiceid.
If this is not the case then what happens when you remove this line and then try and create a contract?
MSCRM Bing'd - http://bingsoft.wordpress.comYes, really is relationship field.
I remove this fiel from SOAP request. Error trace is equal.
Now, i remove and recreate this field, i hope is fix problem.
- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Friday, April 23, 2010 3:32 AM -
Ok, it is just that it looks like the relationship name and not the attribute name as it should have id at the end of the attribute name unless you changed it. I think it would have been new_invoiceid.
If this is not the case then what happens when you remove this line and then try and create a contract?
MSCRM Bing'd - http://bingsoft.wordpress.comI remove line from soap, remove relationship from contract entity. Problem not fixed.
Is part of trace log:
>CrmSoapExtension detected non-CrmException - report will be sent to Watson:
System.Web.Services.Protocols.SoapException: Серверу не удалось обработать запрос(Server request processing is failed(my translation to English.). ---> System.Reflection.TargetInvocationException: Адресат вызова создал исключение(Caller make exception). ---> System.NullReferenceException: В экземпляре объекта не задана ссылка на объект(In the exemplar of object not defined link(relationship) to object).
в Microsoft.Crm.ObjectModel.OMUtil.ValidateCustomer(BusinessEntity entity, Boolean update, Boolean required, String customerIdName, String customerIdTypeName, Boolean allowInactive, ExecutionContext context)- Marked as answer by Megabyte-Ceercop Friday, April 23, 2010 5:47 AM
Friday, April 23, 2010 3:45 AM -
Problem fixed.
billingcustomerid field need type='account'.
And i remove relation ship, and remake it. Now all working : )
Friday, April 23, 2010 5:47 AM