
global class SoapDemo1
{
webservice static void CreateContact(String accName,ID accountID)
{
Account a=new Account();
a.Name=accName;
Database.Insert(a);
//create contact
Contact con=new Contact();
con.LastName='LName1';
con.AccountID=accountID;
con.Account.Name=accName;
Database.Insert(con);
}
}
Code in flipkart account: (Below code is written in anonymous block)
Account acc=new Account();
acc.Name='SoapDemo1';
insert(acc);
P2.soap part = new p2.soap();
p2.LoginResult lr = part.login('hdfcBank@sfdc.com','ecom2B07O2OcHcXhN4kLd83M5eiAulN4');
Generated_From_WSDL.SoapDemo1 obj1 = new Generated_From_WSDL.SoapDemo1();
obj1.sessionHeader = new Generated_From_WSDL.SessionHeader_element();
obj1.sessionHeader.sessionId = lr.SessionId;
obj1.CreateContact(acc.Name,acc.ID);
well, I hope I am clear.
ThanksPooja biswasHi Pooja, You cannot make any DML before Callout, need to remove below code. Adjust your logic.
Hope this will help you!Account acc=new Account();
acc.Name='SoapDemo1';
insert(acc);