Hello Every One
I am trying to call a wcf webservice in dynamic CRM Workflow, i am getting the following error
"Type 'SMS' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type 'System.Activities.CodeActivity' with DataContractAttribute or SerializableAttribute, or removing them from the derived type.
Here is my full method
using System;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using System.Net;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Runtime.Serialization;
namespace SendSMS
{
[DataContract]
[KnownType(typeof(smsnew))]
public class smsnew
{
[Input("ComplaintNo")]
[DataMember]
public InArgument<string> ComplaintNo { get; set; }
[Input("SMS_No")]
[DataMember]
public InArgument<string> SMS_No { get; set; }
[Input("SMS_GATEWAY")]
[DataMember]
public InArgument<string> SMS_GATEWAY { get; set; }
}
public sealed class SMS : CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
ITracingService tracingservice = context.GetExtension<ITracingService>();
try
{
IWorkflowContext workflowcontext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory servicefactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = servicefactory.CreateOrganizationService(workflowcontext.UserId);
using (WebClient client = new WebClient())
{
var sms = new smsnew();
sms.ComplaintNo = sms.ComplaintNo;
sms.SMS_No = sms.SMS_No;
sms.SMS_GATEWAY = "501";
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(smsnew));
MemoryStream memoryStream = new MemoryStream();
serializer.WriteObject(memoryStream, sms);
//var jsonObject = Encoding.Default.GetString(memoryStream.ToArray());
var webClient = new WebClient();
webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
var serviceUrl = "http://10.101.51.10:8080/MessageEventManagement.ProcedureExecuterBatch/ProcedureExecuterBatch.svc";
// upload the data using Post mehtod
string response = webClient.UploadString(serviceUrl, memoryStream.ToString());
}
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException(ex.Message);
}
}
}
}
*This post is locked for comments