this is my code
public class Class1 : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
//Context = Info passed to the plugin at runtime
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
//Service = access to data for modification
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
// Adding Basic Http Binding and its properties.
BasicHttpBinding myBinding = new BasicHttpBinding();
myBinding.Name = "BasicHttpBinding_Service";
myBinding.Security.Mode = BasicHttpSecurityMode.None;
myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
if (context.InputParameters.Contains("Target") && (context.InputParameters["Target"] is Entity))
{
{
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName == "account")
{
try
{
// Endpoint Address defining the asmx Service to be called.
EndpointAddress endPointAddress = new EndpointAddress(@"localhost/WebService1.asmx;);
// Call to the Web Service using the Binding and End Point Address.
localhost.WebService1 srv = new localhost.WebService1();
srv.CreateContact();
}
catch (Exception ex) { }
}
}
}
}