I have added CRM 2011 (on-premises) Deployment and Discovery Services as web Reference (instead of wcf references) in a .Net 3.0 class library project which is a part of a multi-tier solution which is in .Net 2.0 (and for the time being cant be upgraded and thats why i am trying to user wcf service as web service and use its basichttpbinding). The class library a.k.a executes at remote server, lets say the Remote library, using .Net remoting. I am using the following code to create CRM 2011 Organization.
_CrmDeployService = New DeploymentService()
_CrmDeployService.SoapVersion = SoapProtocolVersion.Soap12
_CrmDeployService.Url = CRMDeploymentServiceURl
_CrmDeployService.Credentials = DomainCredentials
' Do all sorts of Active Directory STuff,
'which is successfull
'Now Creat eCRM organization
Dim CRMOrg As CRM2011DeploymentSvc.Organization = New CRM2011DeploymentSvc.Organization()
CRMOrg.UniqueName = OrgUniqName
CRMOrg.FriendlyName = OrgDispName
CRMOrg.SqlServerName = SQLServerName
CRMOrg.SrsUrl = ReportServerUrl
CRMOrg.BaseCurrencyCode = CurrencyCode
CRMOrg.BaseCurrencyName = CurrencyName
CRMOrg.BaseCurrencySymbol = ""
CRMOrg.State = CRM2011DeploymentSvc.OrganizationState.Enabled
'Initialize Request Object to Send CRM Organization Request and set properties
Dim req As New BeginCreateOrganizationRequest() With {.Organization = CRMOrg}
_CrmDeployService.Timeout = 720000
'Execute deployment service given createrequest object
Dim _
resp As BeginCreateOrganizationResponse = _
TryCast(_CrmDeployService.Execute(req), BeginCreateOrganizationResponse)
The above code works perfectly when i execute it in a separate application. However, when i write the same code a part of the project remote class library, operation seems to continue for more than 15 minutes and then the following message from CRM Service is returned and is being displayed
The operation timeout
I am very much sure that there is no problem with the remoting calls. I am using remoting calls throughout my solution and there is no problem of serialization either.
Also, previously, i was attempting to call CRM 2011 Service by not specifying soap12 protocol version i was getting the following error:
HTTP/1.1 415 Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.
So i added the following line to my code:
_CrmDeployService.SoapVersion = SoapProtocolVersion.Soap12
and the problem went away but now i have this timeout problem.
Question: Is this a problem with CRM configurations at the server or HTTP tiomeout setting at the server or WCF servuice settings at the server or is it that i am doing it all wrong? If there is a problem with the code please suggest how i should be doing it.
If any sort of configuration or settings are required please also tell so.
Responses are very much appreciated.
Thank you.
I guess i have found out the problem. The WCF service was not returning the error when i was using it basicHttpBinding mode (Legacy Support Mode) and had added WCF Service in compatibility mode as Web Service.
When I removed the web service reference and added them as WCF Service Reference after upgrading my library project to 3.0, the proper error was returned. The problem was the missing config files containing endpoint and binding/contract information.
When developing multi-tier systems(.Net Remoting) and communicating via WCF Services, it is necessary to place endpoint and binding information in application configuration files on all tiers involved in the communication. My scenario was like this:
Tier 01 ASP.Net Application + Class Library XYZ with WCf Reference
Tier 02 (Windows Service(.Net Exe) + Class Library XYZ with WCf Reference ) + CRM 2011 WCF Service)
The new architecture is now:
Tier 01 (Client) (ASP.Net Application(endpoint/binding info added in web.config) + Class Library XYZ with WCF Service Reference)
Tier 02 (Remote Server) .Net Windows Service (endpoint/binding info added in app.config) + Class Library XYZ with WCF Service Reference ) + CRM 2011 WCF Service