2
votes

I have a Silverlight 4 application using RIA Services 1.0 SP1.

In the web application that hosts the Silverlight app I have a few RIA services and a pure WCF service that is there for other consumers (not the Silverlight app).

RIA Services is attempting (and failing) to generate client proxy code in the Silverlight app to call the WCF service. I do not need to call that service from Silverlight.

How can I prevent RIA Services from generating the client code for that service?
I there an attribute I can use to ignore that service?

EDIT
I was assuming that it would be RIA Services trying the generate the proxy, but I'm not sure. Here's more info:

I have the following compilation warning:

Client proxy generation for service 'MyNamespace.MyWcfService' failed: Error: Endpoint 'WSHttpBinding_SurveyCentreWcfService' at address 'http://localhost/Service' is not compatible with Silverlight 4. Skipping...

I haven't manually added any Service Reference in my Silverlight application, but the WCF RIA Services Link is set in the project properties.

My service class looks like this:

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(Namespace = "http://www.xxx.com/services/")]
public class MyWcfService
{
    ...
}
2

2 Answers

0
votes

Ria, as far as I knew, only generated code from DomainService classes. Is your WCF Service inheriting from DomainService?

This kind of sounds like it could be the proxy code generator on the silverlight side. RIA services doesn't require a web reference. If you have a web reference in the silverlight project, remove it.

Also, you can see in the build.log file which proxy generation tools are looking at what files. It's a little hard to decipher, but it might help with your issue.

Very unlikely, but make sure no custom tools are set on any files in your silverlight application.

0
votes

You could look to use the DomainServiceHostFactory to restrict what requests can initiate what services, an example below:

 public class RestrictedServiceHost : DomainServiceHostFactory
 {
    private static List<string> _allowedSchemes;

    static RestrictedServiceHost ()
    {
        RestrictedProtocolServiceHost._allowedSchemes = new List<string>();
        RestrictedProtocolServiceHost._allowedSchemes.Add( Uri.UriSchemeHttp );
        RestrictedProtocolServiceHost._allowedSchemes.Add( Uri.UriSchemeHttps );
    }

    protected override ServiceHost CreateServiceHost ( Type serviceType, Uri[] baseAddresses )
    {
        baseAddresses = baseAddresses.Where( uri => RestrictedProtocolServiceHost._allowedSchemes.Contains( uri.Scheme ) ).ToArray();
            return base.CreateServiceHost( serviceType, baseAddresses );
    }
 }

Which you then use if your web.config like:

 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
      <serviceActivations>
        <add service="RIA.FooDomainService"
             relativeAddress="Services/FooProject-FooDomainService.svc"
             factory="YourWebProject.RestrictedProtocolServiceHost"/>
      </serviceActivations>
    </serviceHostingEnvironment>