2

I'll try to explain the situation in the best way possible, I hope someone out there can guide me a bit.

We have a working .NET MVC 4 app where we've added a service reference to consume a WCF external service.

We've created several classes and methods to translate our data model to service's one, so we can call it's different methods from within our app using our data model.

Now we have a new requisite: to add our own service, which can be accessed from outside our environment, and who has to replicate some of the methods of the original service.

The idea is that users will post info to our environment through our service, we'll apply several treatments to the info, and then post it to the original service.

So my question here is: How do I create and attach the new service to my MVC app so I can get advantage of the classes and methods that are already developed and the data model of the original service?

Bardo
  • 2,470
  • 2
  • 24
  • 42
  • 1
    I hope that you have designed your MVC application with clear layers. Ex: You have reusable entities/models, your data layer is independent, you have written your business logic in a reusable manner. If that's the case you can simply add another WCF project to your solution and create necessary interfaces to expose the functionality that you need to expose to the external world. You will be able to derive you data contracts from your existing models, and you will also be able to use your business logic in your operation contracts. – Kosala W Nov 13 '15 at 10:01
  • you can make api for your application and create your data model from user posted info next you can use from your developed class and method to call yor external service – M.Azad Nov 13 '15 at 10:09
  • [Here's a post from me](http://stackoverflow.com/questions/32889748/how-to-completely-decouple-view-and-model-in-mvc/32890875#32890875) that might help with layering out your code and the objects required if you haven't already done it within your application. If you have your MVC application laid out this way you can create a bootstrapper for each application (MVC, WCF) and inject the correct implementations accordingly. – Luke Nov 13 '15 at 10:34
  • @KosalaW Could you extend yourself a bit more in depth in an answer? I'm more a RESTful guy and I'm feeling quite clumsy with WCF – Bardo Nov 13 '15 at 10:47
  • @M.Azad Although I like this approach, the specification forces us to use SOAP in the service. It wouldn't be difficult to create different api controllers to manage external petitions into methods that deserialize SOAP requests into model classes and work from there, but I wonder if a more natural approach exists. – Bardo Nov 13 '15 at 10:52
  • @Bardo What is your problem with soap?I think you can do this approach with soap – M.Azad Nov 13 '15 at 10:58

0 Answers0