Where's the ASP.Net WebService in Visual Studio 2010? - c#

I am trying to create my first webservice. I've been googling for a tutorial or examples and most of what I find is from previous versions of Visual Studio and say to create a new ASP.Net Webservice...but that doesn't exist in 2010!
What I need to do is have the service receive 2 strings, an agency and a man number. Then run a query to get some information and return a string with a date and time back to the requestor. I need to have a web interface available to call the service as well.
Any guidance on what I need to do to create the service in Visual Studio 2010 in C# will be appreciated!
Update: I've just been told that this process needs to authenticate the users...can someone guide me to information on implementing certificate or digital signatures into my web service? I've looked but most of what I'm finding is for authenticating through Active Directory or some other maintained list with usernames and passwords.

This puzzled me too. There's another puzzle to be had when you try and add a reference to an ASP.NET Web Service too, but I'll let you have fun with that one.
Change the target framework version in the dropdown list to .NET framework 2 and choose Web on the left hand side when creating a new project and it will appear.
Actually, I'm not going to be mean. If you are going to reference the web service from an application built using.NET 3.0 or higher:
Go to Add Service Reference
Go to Advanced
Click Add Web Reference at the bottom of the dialog.

In VS 2010, you can't create web services because this is covered with WCF services.
To create ASP.NET Web Services, you need to select ASP.NET app with Framework 3.5.

Visual Studio 2010 SP1, .NET Framwework 4.0
You need to create ASP.NET web site, and then Add New Item and there select from Web tab template Web Service.

Consider creating a WCF service instead. This is the evolutionary successor of the 'bare' Webservice.
When you configure the WCF server with BasicHttpBinfing you have a (SOAP) Webservice. Other binding-types (including more advanced WS-* webservices) only require changes in the config.
But for an old-style ASMX based webservice you can follow fletchers answer.

It looks like Microsoft have removed the ability to create Web Services with Visual Studio 2010 Ultimate SP1.
It does not matter what framework you are using (2, 3, 3.5, 4) the option is not available. It is unknown at this time why Microsoft made such a move. They have been hush hush over it for a while now.

THE BELOW SIMPLE STEPS WORKED THE BEST FOR ME....
create an empty website
rightclick -> add New item
and select Web Service .
This will create a empty webservice.

Related

Running a Angular front-end written in TypeScript in a C# Web API project?

Let's say I have an existing ASP.NET Web API project, complete with all the API controllers I need for some service. Previously when using this API, clients just did their typical URI routing to use this API.
Now, with ASP.NET Web API, they provide a simple front end. I'd like to add AngularJS to this, and I see one obvious way to do that, and that's through Angular's JavaScript library. How can one do this with TypeScript? I understand that TypeScript is a language that compiles down into JavaScript, which to me implies that I need to get some step in the build process for Visual Studio (not Visual Studio Code) that builds the TypeScript for my front end.
How can this be done? I have done some tutorials for TypeScript where they have you pull something off NPM that gives you the foundation for your website and you go from there. However, in all of these tutorials, I've done this in Visual Studio Code where you have the Angular CLI and you can ng serve --open to run the web server and develop your website, but I have no clue how to translate this feature into Visual Studio 2017 where both the Web API and the Angular front end are both running at the same time.
I envision the product I'm working on running on IIS and when clients navigate to the page, they'd be served up the Angular front end and the Web API would exist in the back end doing what it does, but I don't know how to marry these two together. Do you need to have two web servers running, one for the Web API and the other for the front end? If you can do it on a single web server, how can it be done? Thanks.
If you have a working API you can run this as normal, say on localhost:8000.
Now you create your SPA (angular or whatever) and run that on localhost:8001.
They run independently, all you do is query your endpoints, obviously passing paramters (say localhost:8000/api/something/3) in order to retrieve the data you're looking for.
If the API is not public, you simply don't expose it as such.

Use a Web Service in C# Windows App

I am new to using web services. I am assigned a task in which I need to use a web service in my Windows app. This is the web service I would be using:
https://api.betfair.com/global/v3/BFGlobalService.wsdl
Now, I've learned how to add a web reference to this service, but I could not find a basic tutorial that could help me learn how to make an object of this web service and use the service as I want to.
Basicaly, what I need is to create an object from the above web service in my form, and to call it's methods. A C# code snippet would be great.
Can anyone give me some directions? I am working in Visual Studio 2008 and a C# Windows App.
Right click on References
select Add Service Reference
give the wsdl address in the address textbox
click Discover
Give a name for the namespace eg;- BFG
You can access the resources like BFG.MethodName() from you code

WebService C# and HTML5

I want to realize an interface using HTML5 and bind it to an exisisting C# application. I saw that to realize this application i have to use a WebService , but I don't know how make comunication between the c# application and the page in HTML5. My questions are:
1) How create the webservice in Visual Studio 2010 Express Edition, and where it must be saved
2) How allow the comunication between application, web service and interface
I have already installed and running IIS.
Just make Restful services, whether in WCF or Asp.net MVC
Call those services using Ajax from jquery.
Actually you need to create the service and Access it with Ajax/jquery.
This Page will explain you step for step http://www.codeproject.com/Articles/37727/Prepare-a-JSON-Web-Service-and-access-it-with-JQue

How to post to a web service that has implemented Single Sign On?

(sorry in advance this got a bit long)
The web service in question is running on IIS that has enabled Windows Integrated Authentication.
The development environment is C#, Visual Studio 2008. I can use 2010 if I need to. My old projects are still in 2008.
The two applications I have are my 'fiddling around apps'.
One uses the standard methodology of calling a web service (i.e. adding the web reference, built the proxy classes, etc).
The other basically takes an external XML file and does an HTTP post to the URL (I built it before I knew of the existence of SOAPUI).
So now the web service is going to be behind SSO and I'm trying to figure out how to call the web service with these two different applications.
I assume there is two different ways to do it. The standard way is just to add the line
myproxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
This works great in my standard application.
How would I go about doing this manually in the HTTP post application?
I assume the same line of code would work on the HttpWebRequest object, but I would like to give it a shot manually.
thanks and again sorry for the length.
lee

My existing webparts won't work in SharePoint

I have a standard ASP.NET 2.0 website.
It has a webpage page.
I have a webpart in my Company.Web.dll that I display on my webpart page on my website.All is good!!!
I would like to use this same webpart in SharePoint 2007.
I have a "site definition" project in VS2008 using Extensions for SharePoint 1.2. I have tried various ways to add the webpart from an outside assembly to my site definition. I have been able to deploy the webpart (where it is added to the webpart list of a webpart page) but I have been unsuccessful at adding the it to a page.
My Glorious Failures:
Created a shell webpart to just display the existing web part, basically just using my part as a control.
Attempted to modify the X.webpart and X.xml files created by VS2008 when you create a new webpart.
Both result in the following error while adding the web part to the page:
Exception
Microsoft.SharePoint.WebPartPages.WebPartPageUserException:
Cannot import XXXX Web Part.
at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean
clearConnections) at
Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager
manager, XmlReader reader, Boolean
clearConnections, Uri webPartPageUri,
SPWeb spWeb) at
Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager
manager, XmlReader reader, Boolean
clearConnections, SPWeb spWeb) at
Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
Is there a special way I need to add my existing webpart to my site definition?
This sounds like a problem resolving the GUID at deployment time, as you can read about in this SO question.
To find the details of why the web part won't import, check the ULS logs. These are typically located at %CommonProgramFiles%\Microsoft Shared\web server extensions\12\LOGS. An entry will be logged here at the time you attempt to add the web part to the page. This should give you more detail.
My guess is that it is a code access security issue. Your web part must be strongly signed and needs a SafeControl entry in the web.config of the SharePoint web application. Apart from these things you should be able to just add it to the Global Assembly Cache to test if it works (best practice is to write a CAS policy file). See Deploying Web Parts in Windows SharePoint Services for more details.
I would try these steps before trying to integrate it as part of a site definition. Then at least you know the web part will actually run.
Also, VSeWSS is really designed for developing your web part using it from the very start. If you have the original source, you could try creating a new web part with VSeWSS and then replace with your custom code and update the .webpart and feature XML files. Then it should behave a little better. If you haven't committed to VSeWSS, try WSPBuilder as it's less painful.
ASP.NET webparts and Sharepoint Webparts are NOT the same. You should be able to use a ASPNET webpart within Sharepoint. See the following table:
ASP.NET 2.0 Web Part
For most business needs.
To distribute your Web Part to sites that run ASP.NET 2.0 or SharePoint sites.
When you want to reuse one or more Web Parts created for ASP.NET 2.0 sites on SharePoint sites.
To use data or functionality provided by Windows SharePoint Services 3.0. For example, you are creating a a Web Part that works with site or list data.
SharePoint-based Web Part
When you want to migrate a set of Web Parts using the SharePoint-based Web Part infrastructure to Windows SharePoint Services 3.0.
To create cross page connections.
To create connections between Web Parts that are outside of a Web Part zone.
To work with client-side connections (Web Part Page Services Component).
To use a data-caching infrastructure that allows caching to the content database.
For a Sharepoint webpart to work in a standard ASPNET application you would need to recreate your webparts in Visual Studio (as an ASPNET webpart) without the Sharepoint 2007 references for it to work correctly.
One nifty tool which I have used in the past is the SmartPart Worth checking out:
This lets you create a ASP.NET usercontrol (visually) in Visual Studio and then host this in Sharepoint. The smartpart acts as a wrapper wepart for your user control. Think of it like the page viewer webpart in Sharepoint except instead of it being HTML pages its ASP.NET UserControls.
You would need WSS 3.0, SharePoint MOSS or 2007 to use ASP.NET 2.0 WebParts. SharePoint 2003 or below and WSS 2.0 or below do not support ASP.NET WebParts.

Categories