如何解决“操作超时”问题当尝试通过在 .Net 库项目中添加为 Web 引用来调用 CRM 2011 服务时?
我已将 CRM 2011(本地)部署和发现服务添加为 .Net 3.0 类库项目中的 Web 参考(而不是 wcf 参考),该项目是 .Net 2.0 中多层解决方案的一部分(并且用于目前无法升级,这就是为什么我尝试将 WCF 服务用作 Web 服务并使用其 basichttpbinding)。类库又名在远程服务器上执行,比如说远程库,使用 .Net 远程处理。我使用以下代码创建 CRM 2011 组织。
_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)
当我在单独的应用程序中执行上面的代码时,它可以完美地工作。但是,当我在项目远程类库的一部分编写相同的代码时,操作似乎持续了超过 15 分钟,然后从 CRM 服务返回并显示以下消息
操作超时
我非常确定有远程调用没有问题。我在整个解决方案中使用远程调用,并且也不存在序列化问题。
另外,之前,我尝试不指定soap12协议版本来调用 CRM 2011 服务,但出现以下错误:
HTTP/1.1 415 无法处理消息因为内容类型'text/xml; charset=utf-8' 不是预期的类型 'application/soap+xml; charset=utf-8'.
所以我在代码中添加了以下行:
_CrmDeployService.SoapVersion = SoapProtocolVersion.Soap12
问题消失了,但现在我遇到了超时问题。
问题:这是否是服务器上的 CRM 配置或服务器上的 HTTP 超时设置或服务器上的 WCF 服务设置有问题,还是我做错了? 如果代码有问题,请建议我应该如何做。
如果需要任何类型的配置或设置,也请告知。
非常感谢您的回应。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我已经发现问题了。当我使用 basicHttpBinding 模式(旧支持模式)并在兼容模式下将 WCF 服务添加为 Web 服务时,WCF 服务未返回错误。
当我将库项目升级到 3.0 后删除 Web 服务引用并将它们添加为 WCF 服务引用时,返回了正确的错误。问题是缺少包含端点和绑定/合同信息的配置文件。
当开发多层系统(.Net Remoting)并通过WCF服务进行通信时,有必要将端点和绑定信息放置在通信涉及的所有层的应用程序配置文件中。我的场景是这样的:
Tier 01
ASP.Net应用程序
+ 带有 WCF 参考的类库 XYZ
Tier 02
(Windows服务(.Net Exe)
+ 类库 XYZ 和 WCF 参考)
+ CRM 2011 WCF 服务)
新架构现已:
第 01 层(客户端)
(ASP.Net 应用程序(web.config 中添加的端点/绑定信息)
+ 带有 WCF 服务参考的类库 XYZ)
第 02 层(远程服务器)
.Net Windows 服务(app.config 中添加的端点/绑定信息)
+ 类库 XYZ 与 WCF 服务参考)
+ CRM 2011 WCF 服务
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