简体   繁体   中英

IIS CRM 2011 web service invocation issue

I had a simple program , a asp.net website in which i added a webservice

One of the web methods accessed a 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. the project runs fine . I invoke this record exists method , and it correctly brings data from the CRM 2011

However when i deploy this application on 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 . No idea what is going on . Please help me

This exception happens in the client you use when trying to connect your web service. 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. But there is also other way to see what is going on, it's attach to IIS process and debug your web service.
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.
When you deploying this code to IIS authentication issues are possible, since IIS is working under NETWORK SERVICE account. And in case if CRM uses Windows Authentication it's possible your request will not be authorized.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM