0

I made in my controller method that should creat another product

[HttpPost]
        public ActionResult Create(ProductType product)
        {
            if (ModelState.IsValid){
                ServiceReference1.Service1Client proxy = new ServiceReference1.Service1Client();
                proxy.AddProduct(product);             
                return RedirectToAction("Index");
            }

And the AddProduct is In WCF service

public void AddProduct(ProductType product)
        {
            Product _product = new Product();

            _product.Name = product.Name;
            _product.AddDate = DateTime.Now;
            _product.Price = product.Price;
            _product.isActive = product.isActive;
            _product.CategoryID = product.CategoryID;

            BaseShopEntities productToAdd = new BaseShopEntities();
            productToAdd.AddToProduct(_product);
        }

But I have an error I saw some infos in net but can't find solution on my problem.

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.

Service References\ServiceReference1\Reference.cs Line: 78

Line 76:         
Line 77:         public void AddProduct(Shop.Data.ProductType product) {
Line 78:             base.Channel.AddProduct(product);
Line 79:         }
Line 80:     }

Any1 know solution for this ?

tereško
  • 58,060
  • 25
  • 98
  • 150
Dox
  • 158
  • 1
  • 10
  • Did you enable the trace file in the web service. For enabling the tracing, you can refer to : http://stackoverflow.com/questions/4271517/how-to-turn-on-wcf-tracing or http://msdn.microsoft.com/en-us/library/ms733025.aspx. Once done, you can check the exact reason from the trace file and post here if you are not able to track the reason. – Saravanan May 19 '13 at 11:00
  • I made everything like in the link and I dont have any errors while page is going but now I have this trace in program but I have no idea what should I look for there are so many things Any clues ? please – Dox May 19 '13 at 13:12
  • Is Shop.Data.ProductType defined in your MVC or WCF project? – MotoSV May 19 '13 at 19:07
  • I solved my problem already but I have no idea how :P – Dox May 19 '13 at 19:45

1 Answers1

0

Looking at the code you provided it is not immediately obvious what the problem is. From what I can see it could be the call to productToAdd.AddProduct.

You should add the IncludeExceptionDetailInFaults attribute to your configuration file because when AddProduct, on your web service, throws an exception it can be handled in your MVC application and WCF will place information about the exception thrown by AddProduct inside of the handled exception.

You should also be able to run your WCF and MVC applications at the same time within Visual Studio which will allow you to debug AddProduct on your WCF service.

MotoSV
  • 2,348
  • 17
  • 27