Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Using Orgservice reference in WCF service

$
0
0

Hello All,

We have created WCF service and inside that we are using CRM org service reference. When accessing WCF on client side we are doing it in following way:

WCFServiceRef.OrganizationServiceClient obj =new WCFServiceRef.OrganizationServiceClient();              

               obj.ClientCredentials.UserName.UserName =ConfigurationManager.AppSettings[ServiceConstants.UsernameKey];

                obj.ClientCredentials.UserName.Password =ConfigurationManager.AppSettings[ServiceConstants.PasswordKey];

                obj.ClientCredentials.ClientCertificate.Certificate =newX509Certificate2(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath +"//app_data//tdc_ws_crm.pfx", "123456");           

                Entity account = obj.Retrieve("account",newGuid(guid),new Microsoft.Xrm.Sdk.Query.ColumnSet(true));

On client side we are getting following exception:

 Could not find default endpoint element that references contract 'WSCRMServiceRef.IWSCRMService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
   at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
   at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
   at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
   at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
   at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
   at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
   at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
   at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
   at System.ServiceModel.ClientBase`1..ctor()
   at TDC.CRM.WSCRM.Services.TestApplication.WSCRMServiceRef.WSCRMServiceClient..ctor()
   at TDC.CRM.WSCRM.Services.TestApplication.CrmService.InvokeService(String methodCode)
   at TDC.CRM.WSCRM.Services.TestApplication.CrmService.btnGetaccName_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

CRM server and WCF client both are on different networks. Is there anything which we are missing?

Please reply if anyone has any suggestions.

Thanks in advance,

Jayashree


Viewing all articles
Browse latest Browse all 8223

Trending Articles