[英]IIS CRM 2011 web service invocation issue
I had a simple program , a asp.net website in which i added a webservice 我有一个简单的程序,一个asp.net网站,其中添加了一个Web服务。
One of the web methods accessed a CRM ` 一种网络方法访问了CRM`
[WebMethod]
public bool RecordExists (String projectName)
{
var service = GetService("http://localhost/EventoCorp/");
Entity project = new Entity("new_project");
/*PROJECT DETAILS*/
project.Attributes["new_name"] = projectName;
var request = new RetrieveDuplicatesRequest
{
BusinessEntity = project,
MatchingEntityName = "new_project",
PagingInfo = new PagingInfo() { PageNumber = 1, Count = 50 }
};
Console.WriteLine("Retrieving duplicates");
var response = service.Execute(request);
EntityCollection collection = (EntityCollection)response.Results["DuplicateCollection"];
return collection.Entities.Count > 1 ? true : false;
}
When I press F5. 当我按F5键时。 the project runs fine . 该项目运行良好。 I invoke this record exists method , and it correctly brings data from the CRM 2011 我调用此record exist方法,并正确地从CRM 2011中获取数据
However when i deploy this application on IIS 7.5 . 但是,当我在IIS 7.5上部署此应用程序时。 I get greeted by this terribly uninformative exception 我被这个极其无聊的例外所招呼
System.ServiceModel.FaultException: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.
Server stack trace: 服务器堆栈跟踪:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
I am a CRM 2011 noob . 我是CRM 2011新手。 No idea what is going on . 不知道发生了什么。 Please help me 请帮我
This exception happens in the client you use when trying to connect your web service. 尝试连接Web服务时使用的客户端中会发生此异常。 It says only that unhandled exception happened on server side, but has no information about exception. 它说只有未处理的异常发生在服务器端,但是没有有关异常的信息。 Also there is advice to enable IncludeExceptionDetailInFaults
in order to pass to the client unhandled exception details. 另外,建议启用IncludeExceptionDetailInFaults
以便将未处理的异常详细信息传递给客户端。 But there is also other way to see what is going on, it's attach to IIS process and debug your web service. 但是,还有其他方法可以查看正在发生的情况,它附加在IIS进程上并调试Web服务。
Also it would be better add exception handling to your code, because now code is completely unsafe. 另外,最好将异常处理添加到您的代码中,因为现在代码是完全不安全的。 Different exceptions can happen when you are accessing CRM, like authentication exception etc. Also you can just get null instead of collection you suppose to be there. 当您访问CRM时,可能会发生不同的异常,例如身份验证异常等。此外,您只能获取null而不是您想在那里的集合。
When you deploying this code to IIS authentication issues are possible, since IIS is working under NETWORK SERVICE account. 当您将此代码部署到IIS时,可能会出现身份验证问题,因为IIS在NETWORK SERVICE帐户下运行。 And in case if CRM uses Windows Authentication it's possible your request will not be authorized. 而且,如果CRM使用Windows身份验证,则您的请求很可能未被授权。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.