I am trying to create an Account using DynamicEntity in MsCrm4.0. Following is the code snippet. I would like to mention the following:
1. The same code(ref Code 2 below) creates an Account successfully when used in MsCrm3.0
2. I am able to create Account in MsCrm4.0, if I dont use DynamicEntity(ref Code 1 below).
3. The MsCrm4.0, the IIS security - IWA and Basic authentication is enabled.
Could someone pl suggest what am I doing wrong w.r.t MsCrm 4.0? I dont see any issue with security, as I am able to create record if I use Code 1 below. Maybe I am wrong?
Regards
Code 1: This works in same CRM, MSCrm 4.0
-------
try{
Account account=new Account();
account.setName("ac crm3-2");
account.setAddress1_city("cityy1");
String id = binding.create(account);
System.out.println("Account id = "+id);
}catch(Exception e){
e.printStackTrace();
}
Code 2 : This DOESNT work in same CRM, MSCrm 4.0
------
try {
// Set the properties of the contact using property objects.
StringProperty firstname = new StringProperty();
firstname.setName("firstname");
firstname.setValue("Jesper");
StringProperty lastname = new StringProperty();
lastname.setName("lastname");
lastname.setValue("Aaberg using Dyn Entity-3");
DynamicEntity contactEntity = new DynamicEntity();
contactEntity.setName("Contact");
Property[] property = new Property[] {firstname, lastname};
contactEntity.setProperties(property);
TargetCreateDynamic targetCreate = new TargetCreateDynamic();
targetCreate.setEntity(contactEntity);
CreateRequest create = new CreateRequest();
create.setTarget(targetCreate);
// Execute the request.
CreateResponse created = (CreateResponse)binding.execute(create);
System.out.println("\nContact Created : "+created.getId());
} catch (RemoteException e) {
e.getLocalizedMessage();
e.getMessage();
System.out.println("Create result RemoteException "+e);
e.printStackTrace();
}
Failed Response :
<?xml version="1.0" encoding="utf-8"?><
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:Client</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>