WCF showing the "You have created a service." page instead of WSDL - asp.net-mvc

I have a WCF service running inside an ASP.NET MVC 4 application. The site is running on IIS8 on Server 2012. Until recently, the WSDL pages loaded without any problems. This week, the WSDL no longer loads. The link from the "Welcome" page is correct, but when I click it or attempt to generate a client, the same Welcome page is returned.
I have tried this using a ServiceRoute and also using an .svc file.
The ServiceRoute looks like this:
/DataService
Its WSDL link is:
/DataService?wsdl
The .svc file looks like:
/directory/otherdir/DataService.svc
The WSDL link is
/directory/otherdir/DataService.svc?wsdl
I never needed any configuration in the web.comfic section before, using the SerivceRoute.
How can I get WCF to show the WSDL correctly?

I ran into this before and there can be multiple reasons, the service is not functioning due to errors in the operations or you may be using WebServiceHostFactory instead of ServiceHostFactory
RouteTable.Routes.Add(new ServiceRoute("DataService", new ServiceHostFactory(), typeof(MyServiceType)));

Related

Web API in an MVC project not working after publishing

I have an mvc project which has a web api controller. The web api has a Get method which returns a list of objects. This call is made from the client using JQuery ajax method and the data is exchanged as JSON object. Everything works fine when I run the application from within Visual Studio. The pages load correctly and on clicking the 'Search' button, the ajax call is made and the records are loaded successfully on the page. The routes are properly mapped to the areas and there is absolutely no problem.
The problem arises when I publish the application in IIS and then try to 'Search' the records. On clicking the 'Search' button, I get 500 Internal Server Error which I believe suggests that the web api service is not available to the application and is not running.
Do I need to deploy/publish the web api separately? If thats the case then how can I do that deploy it separately given that it is part of the same MVC project (there is no separate Web API project).

Calling Web API from MVC Application when both in same Solution

So I am totally new to the Web API and I thought to myself I would start a test project to learn it and AngularJS and how they can work together nicely ... etc.
I have created a multi-tier architecture within my solution, and inside my TPlan.API project, I have the following route configured in the Global.asax
GlobalConfiguration.Configuration.Routes.Add("default",
new HttpRoute("api/{controller}"));
TPlan.WEB is my MVC application, and it is set up as "Start Up Project". When I run it, I want to be able to go to:
mysite:port/api/test
And get the value from the API from my test controller in there.
However it is not working for me, I get the following:
No HTTP resource was found that matches the request URI 'mysite:port/api/test'.
Er, in visual studio, right click on the solution and go to properties.
Go to startup and select the "multiple projects" option and tick the website and the webservice to both start up.
That will start both of them. But as has been pointed out, they're running on separate ports, they're completely separate applications...
I don't think you can register a route that belongs outside of the website.
We work like this
View => POST / GET => MVC Controller => HTTP Request => API Controller
So our mvc views post or get to our mvc controllers, and then we fire off a separate http request to the web api. this is a server to server call, its like calling any external web service. we wait for the response from the api and then return whatever is required to the view...
What you are attempting isn't logically possible without installing your WebAPI project into IIS ahead of time, which I'm sure is not what you want. Both projects cannot be run at the same time, as only one project will be able to launch a debug session of IIS Express. Even if both projects were able to run at the same time, they would be on different logical ports, and routing from one project would have to be manually sent to the listening port of the other instance. Basically, your Global.asax on your API project will never run, as that project will be built as a class library.
Make your TPlan.API project a simple Assembly, reference it from TPlan.Web and pass the GlobalConfiguration.Configuration property over to a Register method that is in your API assembly. When the MVC project starts, both the MVC routes and the Web Api routes will be active on the same web host.
Here is an example of an API that has both a console host and a web host in the same solution.
Please check the following site. I believe the issue lies in the configuration of the route
http://www.asp.net/web-api/overview/extensibility/configuring-aspnet-web-api

Error when attempting to run application

I am moving an asp.net web forms application over to mvc. I want to re-use as much code as possible so I decided use my existing linq to sql library.
I am new to MVC, but have viewed numerous videos from PluralSite for direction.
I created a model library to work between the linq to sql and the web api. I had read that I needed to do this because of linq to sql's complexities.
I have also created a web api and started adding linq queries to the controllers.
public IList<Model.vSchedulesFill> GetCustomerSchedules(int id)
{
var sch = from p in _context.vSchedulesFills
where p.CustomerID == id
orderby p.SchedStartDateTime descending
select new Model.vSchedulesFill(p);
return sch.ToList();
}
I tested the above query using Fiddler and the result were good, so I tried to run the program and received the HTTP Error 403.14 - Forbidden error.
The database is on a remote server, but I am running the app in debug mode on my local machine.
The error mentions no default document or IIS directory browser not turned on.
I looked up the default document and saw a lot about adding the web api help file. So I went to NuGet and installed it, but the application still will not run.
I have looked all over for solution to this problem...
What am I doing wrong and what do I need to do to fix this?
Thanks for your help
Added
<directoryBrowse enabled="true" />
to web config under section system.webServer.
Can view directory but that's not what I needed. I basically wanted to be able to run the program and then type in the path in the address bar, like I did in Fiddler.
I didn't remove any of the default layout forms included in the web api project.
Thanks

Integrating FedEx Web Services into .Net, stuck at step 1

I'm signed up, I've downloaded sample code, I've got a WSDL...and yet I have no idea how to get this stuff into my existing .Net application. The WSDL was in a zip file, not a URL so I can't just "Add Web Reference." I've run the wsdl tool from the .Net command prompt, and it made a nice class for me...yet dropping that into my web_reference folder doesn't give me any kind of instantiatable class.
I know I'm missing something stupid. Can someone point me in the right direction please?
The proper way to load the FedEx API WSDL file in Visual Studio 2010:
Open the Solution Explorer
Right click your project
Click 'Add Service Reference'
Click the 'Advanced...' button
Click the 'Add Web Reference...' button
Enter the exact path to the WSDL file for the specific FedEx web reference you're using. For example, I extracted mine to the root of my C:\ drive, so all I entered into the URL field was "C:\ShipService.wsdl" without quotes. If you leave quotes, it won't work.
When you hit go, Visual Studio should consume the wsdl into workable classes for you. Click Add Reference and enjoy!
Note: Make sure you read the FedEx documentation well - a lot of their services have gotchyas and implementation can be a nightmare. For example, their address validation service is consumed incorrectly and creates two-dimensional arrays in Reference.cs where they shouldn't exist - this is detailed in the documentation. Worse yet, the fact that they don't allow address validation on their dev environment isn't documented anywhere! Good luck!
Actually, you can just "Add Web Reference". Give the path to the URL.
OTOH, you should be doing all new web service development (even client development) using WCF. Microsoft now considers ASMX web services to be "legacy technology".
BTW, I just tried using their address validation service, and it won't work with .NET. Both ASMX and WCF clients will attempt to use the XML serializer to consume this service, and there is a bug there that prevents that service from being used.
Matt, the WSDL zip file has the WSDL and its associated transactions for that service. Unzip the file and then "Add the reference" to the WSDL in your code.
Try changing the namespace of the proxy class to that of your application. I currently use the proxy class with C# and it works in spite of FedEx's limited documentation and samples.

I am not able to run Asp.Net MVC 2 Application

I am trying an sample application in Asp.Net MVC 2 Application
given in http://www.codeproject.com/KB/aspnet/aspnet_mvc_tutorial.aspx
But i am getting the error as below
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Views/PersonalInformation/Index.aspx
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
Please let mw know wat is the problem
The problem is the requested url. In an ASP.NET MVC application, the url corresponds to a controller action instead of the aspx page. See this link for an explanation: http://www.asp.net/LEARN/mvc/tutorial-02-cs.aspx.
The url should be something like http://localhost:xxxx/PersonalInformation (where xxxx is your port number)
To avoid getting this error everytime you start up your website through Visual Studio. Go to the properties of your web project and under the Web tab there is a property called Start URL. Change this to http://localhost:xxxx/ or something that is a valid MVC route.
Are you deploying to Cassini or IIS 6. Take a look at these articles
http://guyellisrocks.com/coding/deployed-asp-net-mvc-app-gives-404-on-about-page/
http://www.techdreams.org/microsoft/aspnet/how-to-fix-404-errors-of-aspnet-mvc-website-deployed-on-iis-6-windows-server-2003/2572-20090515
MVC runs fine in Cassini but requires some config modifications to run in IIS. I am still evaluating it in Cassini so i havent crossed that bridge yet but this info should help.

Resources