Silverlight wcf Service does not work when deployed


  • Hi I have seen many threads related to this bu I still can't solve this problem. I have a silverlight busiless application in which I have a silverlight enabled wcf service added. Everything works fine on the developement server but when I deploy the application on ISS7 on same machine, when I access the service I get an error

    An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.

       at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
       at QTMS.QTMSWcfService.GetTestArtifactHierarchyCompletedEventArgs.get_Result()
       at QTMS.Views.AutomationStatus.QTMSWcfServiceProxy_GetTestArtifactHierarchyCompleted(Object sender, GetTestArtifactHierarchyCompletedEventArgs TestArtifactsList)
       at QTMS.QTMSWcfService.QTMSWcfServiceClient.OnGetTestArtifactHierarchyCompleted(Object state)

     Here's my web.config content

            <behavior name="QTMS.Web.QTMSWcfServices.QTMSWcfServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            <binding name="customBinding0">
              <binaryMessageEncoding />
              <httpTransport />
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
          <service behaviorConfiguration="QTMS.Web.QTMSWcfServices.QTMSWcfServiceBehavior"
            <endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
              contract="QTMS.Web.QTMSWcfServices.QTMSWcfService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

     Here's the content of the ServiceReferences.ClientConfig file

                    <binding name="CustomBinding_QTMSWcfService">
                        <binaryMessageEncoding />
                        <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                <endpoint address="http://localhost:9702/QTMSWcfServices/QTMSWcfService.svc"
                    binding="customBinding" bindingConfiguration="CustomBinding_QTMSWcfService"
                    contract="QTMSWcfService.QTMSWcfService" name="CustomBinding_QTMSWcfService" />

    I can't resolve the following

    • Why is the service not working when deployed? I tried to put the clientaccesspolicy.xml in the /bin folder and also in the folder where svc file sits, but that did not help.I also changed the endpoint address to point to the ip of my machine.
    • How do I see the content of inner exception?
    • How to check if my  wcf service is running?

    By the way, my wcfservice return a custom object and makes a database connection in each function call which i close.

    I just can't seem to get it to work. Please help! I can provide more details if required.

    Thursday, October 01, 2009 7:12 PM


All replies

  • It sounds like the error is on the service side.  Usually when a service works in the built-in visual studio web server and then doesn't work under IIS it is security related. 

    I would setup your service to run under IIS by going to the properties for your service project and selecting the "Web" tab.  This way you will get debugging on the service while running in IIS.

    I hope this helps.

    Thursday, October 01, 2009 7:39 PM
  • Thanks but i'm still stuck. When I tried to run this using IIs service (by setting the web prohect properties to use IIS server), I got this error in the debugger

    System.ServiceModel.CommunicationException was unhandled by user code
      Message="An error occurred while trying to make a request to URI 'http://localhost:9702/QTMSWcfServices/QTMSWcfService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details."
           at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
           at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
           at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
           at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
           at QTMS.QTMSWcfService.QTMSWcfServiceClient.QTMSWcfServiceClientChannel.EndGetTestArtifactHierarchy(IAsyncResult result)
           at QTMS.QTMSWcfService.QTMSWcfServiceClient.QTMS.QTMSWcfService.QTMSWcfService.EndGetTestArtifactHierarchy(IAsyncResult result)
           at QTMS.QTMSWcfService.QTMSWcfServiceClient.OnEndGetTestArtifactHierarchy(IAsyncResult result)
           at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
      InnerException: System.Security.SecurityException
                at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
                at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
                at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
           InnerException: System.Security.SecurityException
                Message="Security error."
                     at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
                     at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
                     at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)

    I don't know what to do since I have the ClientAccessPolicy.xml and CrossDomain.xml in the C:\inetpub\wwwroot. In fact al also put these files in the bin follder of the deployed application and the folder where the svc file resides. But no luck.

    What am I missing? 

    This is the content of those files


    <?xml version="1.0" encoding="utf-8" ?>

          <allow-from http-request-headers="*">
          <domain uri="*" />
          <resource path="/" include-subpaths="true" />


       <allow-http-request-headers-from domain="*" headers="*" secure="true" />



    Thursday, October 01, 2009 8:12 PM
  • I put the client access policy file in the web project root folder and then deployed the application. And then it workedd.

    But I ahve another problem that if the dev server is stopped, the service doesn't work. But since that's a different problem, I started another thread.

    Thursday, October 01, 2009 11:15 PM