0

I have an MVC5 application that serves as a framework and uses plugins to extend functionality. Each plugin is its own MVC5/WebAPI project, and I have my framework project configured to dynamically install plugins and retrieve embedded resources.

My problem is each plugin can have WCF web services, WebAPI endpoints, and standard MVC controllers. For example, my directory structure might be:

MyFramework Resources Controllers (my framework level controllers) Plugins CoolNewPlugin Services CoolService.svc Controllers CoolAPIController OtherPlugin Controllers OtherAPIController CollectionOfPlugins AnotherPlugin Services AnotherWCFService.svc etc.... 

My goal is to have the following routes available:

/api/REST/{plugin}/{controller}/{action}

/api/SOAP/{plugin}/Services/Servicename.svc

Essentially I want hide the complexity of the application's directory structure from the end users trying to consume the web services (either SOAP or REST).

The REST stuff I think I have handled using a custom IHttpControllerSelector.

The problem is the WCF service endpoints. They are defined inside of each plugin independently (each plugin has its own web.config file that its services are using), and therefore I can't just modify the element to support the other address.

In the above example, the SOAP Service endpoints would currently look like:

http://example.com/plugins/CoolNewPlugin/Services/CoolService.svc

http://example.com/plugins/CollectionOfPlugins/AnotherPlugin/Services/AnotherWCFService.svc

and what I want is:

http://example.com/api/SOAP/CoolNewPlugin/Services/CoolService.svc

http://example.com/api/SOAP/AnotherPlugin/Services/AnotherWCFService.svc

Thanks for the help.

1 Answer 1

1

What you need to do is to create the WCF endpoint dynamically, instead of using the configuration on the web.config. In tis way you can host the WCF address in the desired URL. You have the MSDN documentation to do this here: How to: Create a Service Endpoint in Code

You'll probably also have to ignore the routes in your route configuration code for MVC / Web API.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.