2013-01-12 39 views
0

我做了一个简单的程序,一个asp.net网站中,我增加了一个web服务IIS CRM 2011 Web服务调用的问题,

其中一个Web方法访问的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; 
} 

当我按下F5。该项目运行良好。我调用这个记录存在的方法,它正确地从CRM 2011带来的数据然而,当我在IIS 7.5上部署此应用程序时。

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) 

我是一个CRM 2011小白:我得到这个可怕的无信息例外

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. 

服务器堆栈跟踪迎接。不知道发生了什么事。请帮助我

+1

您可以在Web.config文件中启用'IncludeExceptionDetailInFaults',然后在浏览器中打开您的服务应用程序?这将显示确切的错误并澄清问题。或者您可以在事件查看器中查看异常详细信息。 – amartine

回答

0

这个异常发生在您尝试连接Web服务时使用的客户端中。它只说服务器端发生了未处理的异常,但没有关于异常的信息。还有建议启用IncludeExceptionDetailInFaults为了传递给客户端未处理的异常详细信息。但是还有其他方法可以看到发生了什么,它是attach以IIS处理和调试您的Web服务。
此外,它会更好地将异常处理添加到您的代码,因为现在代码是完全不安全的。当您访问CRM时,可能会发生不同的例外情况,例如认证异常等。您也可以只获得空值而不是您想要的收集值。
当您将此代码部署到IIS身份验证问题时,因为IIS正在NETWORK SERVICE帐户下工作。如果CRM使用Windows身份验证,则可能不会授权您的请求。