WCF Service - "The remote server returned an error: NotFound."

Discussion in 'ASP.NET WebServices' started by djordan, Sep 28, 2009.

  1. Hi, I have been working on this for several weeks now and I can't seem to figure out where I am going wrong. I have seen many threads on many forums with similar issues but when I try to implement them they still don't work. Below is my code.

    Interface:
    Code:
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    
    namespace SilverlightApplication2.Web
    {
        [ServiceContract(Namespace = "http://www.chicagoquant.com")]
        public interface ITestService
        {
            [OperationContract]
            string TestConnection();
        }
    }
    
    Code:
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    
    namespace SilverlightApplication2.Web
    {
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class TestService : ITestService
        {
            public string TestConnection()
            {
                return "SUCCESS!!";
            }
        }
    }
    
    Service model portion of Web.Config
    Code:
     <system.serviceModel>
      <behaviors>
       <serviceBehaviors>
        <behavior name="SilverlightApplication2.Web.TestServiceBehavior">
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
       </serviceBehaviors>
      </behaviors>
      <bindings>
       <customBinding>
        <binding name="customBinding0">
         <binaryMessageEncoding />
         <httpTransport />
        </binding>
       </customBinding>
      </bindings>
       <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
         <baseAddressPrefixFilters>
           <add prefix="http://www.chicagoquant.com"/>
         </baseAddressPrefixFilters>
       </serviceHostingEnvironment>
      <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />-->
      <services>
       <service behaviorConfiguration="SilverlightApplication2.Web.TestServiceBehavior"
                name="SilverlightApplication2.Web.TestService">
        <endpoint address="" 
                  binding="basicHttpBinding" 
                  contract="SilverlightApplication2.Web.ITestService" />
        <endpoint address="mex" 
                  binding="mexHttpBinding" 
                  contract="IMetadataExchange" />
       </service>
      </services>
     </system.serviceModel>
    
    ServiceReferences.ClientConfig
    Code:
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_ITestService" 
                             maxBufferSize="2147483647"
                             maxReceivedMessageSize="2147483647">
                        <security mode="None" />
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://www.chicagoquant.com/TestService.svc" 
                          binding="basicHttpBinding"
                          bindingConfiguration="BasicHttpBinding_ITestService" 
                          contract="ChicagoQuant.ITestService"
                          name="BasicHttpBinding_ITestService" />
            </client>
        </system.serviceModel>
    </configuration>
    
    ClientAccessPolicy.xml
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <access-policy>
      <cross-domain-access>
        <policy>
          <allow-from http-request-headers="SOAPAction">
            <domain uri="*"/>
          </allow-from>
          <grant-to>
            <resource path="/" include-subpaths="true"/>
          </grant-to>
        </policy>
      </cross-domain-access>
    </access-policy>
    
    TestService.svc
    Code:
    <%@ ServiceHost Language="C#" Debug="true" Service="SilverlightApplication2.Web.TestService" CodeBehind="TestService.svc.cs" %>
    
    I am calling the service from a silverlight application and just trying to change a text box as a test. Any ideas or suggestions would be greatly appreciated.

    -Joe
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    what is the problem?
     
  3. When I the page loads I have a silverlight application that that tries to subscribe to the webservice that I setup above. However, I keep getting the error "The remote server returned an error: NotFound." When I run the project on my local machine it works fine. It's just when I try and deploy it that i receive the error.
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    I tested the service directly and it seems to be working fine. If you are getting a Notfound error, you probably specified a wrong URL or somthing.
     
  5. Did you ever get this working? I'm having the same issue.
     
  6. "Not Found"...same problem

    Did anyone ever figure this out? We have the same problem System.Windows.Ria.DomainOperationException: Load operation failed for query "GetUsers". The romote server returned an error: NotFound
     
  7. I've not seen this problem with an application hosted on the DASP platform, but I have seen this same problem today with a Silverlight application hosted locally on my development box. It had me confused for a while but in the end I solved it by:
    • First specifying includeExceptionDetailInFaults="true" on the service behaviour.
    • Next when this first option didn't expose any further information, I ran a fiddler trace on the line to inspect the raw header response.
    In my case it turned out to be something silly I had done with the class that implemented my WCF service contract: I had put PrincipalPermission(SecurityAction.Demand, Authenticated=true) at class level which was not good (in my scenario at least) because the thread instantiating my WCF class was not authenticated. I moved the PrincipalPermissionAttribute down to the method level and this fixed the problem.

    I'm not suggesting that the cause will be the same in every case, but using the fiddler tool was definitely the thing that pointed me in the right direction.
     
  8. Can you change the SOAPHeaders in the crossdomain xml to:

    <allow-from http-request-headers="*"> ?
     

Share This Page