Web Service deployment in IIS? - c#

I started learning web services. I learnt about web services, UDDI, WSDL, SOAP etc. and architecture of web services. Visual Studio is running the service in local system successfully.
Then I deployed the entire folder of that web service in IIS wwwroot, and tested. Its running successfully.
But when I remove the other file from the wwwroot\webService1 folder (I left only service1.asmx and bin folder) then also service is running.
Here I see that only two file are used in ruuning the webservice one is .asmx and another one is webService.dll in bin folder.
I'm not able to understand where is SOAP, WSDL, namespace or other things, that are required to run web service.
Please clarify.

SOAP, WSDL, Namespace are all handled by IIS and ASP.NET. In your scenario, your web service endpoint is your asmx file (no .cs file required in your deployment), and the DLL in the bin folder contains the code that you wrote for your webservice (so it does something).
If you call up your webservice in a web browser, you should see your web methods listed out to test. IIS knows how to process *.asmx files to do this. If you click on one, you should see a sample form (if input parameters are expected) and a button. Again, IIS knows how to serve this out to you. When you click the button, IIS and ASP.NET handle the work of SOAPing your request, handling it with your code, and SOAPing the response back to you.
If you create a "test" project in Visual Studio, and set a web service reference that points to your deployed web service, Visual Studio will create a proxy class and pull in some additional code from it's discovery of the service. Try it. You should get at least: a WSDL which defines your web service, a file called reference.cs which contains the code that does the heavy lifting of calling your webservice (SOAPing the request from your application and unSOAPing from the response).
If you download a tool called Fiddler, you should be able to intercept and inspect the SOAP call to your web service.
Take a look at Web Services with ASP.NET for additional information.

There are no such 'files' at all. The asmx and dll files contain all of the code for the service. You can see some of that in the URLs that are requested for the SOAP/WSDL info.

I believe if you append ?WSDL after .asmx you will see the definitions.
Such as this example:
WSDL Example

I think these are protocols and does not require anything. IIS and the requesting applications understand these protocols.

Related

WCF Service and ajax call in same project

I hav a C# web application. In that I have added a WCF Service file (.svc) by Right Click project Add New Item >> WCF Service (wcfService.svc). ( Now I have IwcfService.cs and wcfService.cs in my App_Code folder) And also added a function WCFXmlData(string id) inside that.
I am trying to access the function inside wcf service file from an ajax call in my application (in an aspx file).
But I am not able to do that.
Also I tried to browse this .svc file directly. There I got a message like Metadata publishing for this service is currently disabled.
That really depends on your binding, if you use the WebHttpBinding you can simple access the data via a browser. In best case you should modify your contract in such a way that it returns JSON, this is less overhead than XML or even SOAP (which uses also XML).
It your webpage is also implemented in the webservice you have nothing special to care about, but if your service runs under another subdomain you need to implement JSONP or Cross-Origin Resource Sharing (CORS) to manage cross domain calls.

My First WCF Service and I'm Stuck

It took a good bit of trial and error, but I was finally able to host my WCF Service in IIS.
I can browse to the WSDL no problem, and see all of the different methods/attributes.
Now what? I need to use my service inside of another Web App. How do I do that?
I was able to use svcutil.exe to generate the *.cs and output.config files, add that to my web app, and add a reference to System.ServiceModel That worked fine.
BUT, I need to figure out how to use my service hosted in IIS.
In my web app I've added a web reference to the WSDL, but I can't figure out how to expose the methods/attributes.
I'm not ruling out the possibility that there's a better way to do this...so I'm open to suggestions.
Can anyone point me in the right direction?
Right click on the client project and click "Add Service Reference". Then put in the address of your WCF service and it will create the proxies and plumbing for you.
You can add Service Reference to your service. By doing this you don't need the svcutil.
Or you can use the .cs that svcutil generated for you.
http://msdn.microsoft.com/en-us/library/ms730144.aspx
Simply you have to use the class on your .cs file. Istantiate it and call wcf methods...

Webservices with dynamic urls

I have a project with several references to webservices and have made two different config files (one for dev/stage and one for production) with different URLs to the services. Whichever URL the webservices were originally added using works fine, but the other one fails.
For example, if I use the "add web reference" button to add a service at server1 everything works fine when I run my application. If I then switch out the config file so it's trying to use an identical service on server2 my application no longer works. Every call .net makes to the webservice returns null. If I use fiddler to see the XML the servers return they look identical.
Also, anytime the web services get rebuilt (even if nothing changes) I have to refresh all the references in my application. Don't know if that's related.
What would cause this and is there any way to fix it?
I'm doing a big project that has this.
A user creates an account with it's own web service endpoint, so I need them to be dynamic.
The trick is to always change the Endpoint address before each call to the service.
example of a Find service
FindClient wsFin = new FindClient();
wsFin.Endpoint.Address =
new System.ServiceModel.EndpointAddress(clientUrl.TrimEnd('/') + "/Find.svc");
just as a note: for WCF Services I have preferred to create a proxy using the svcutil instead of adding the reference, but for asmx web services, I did add reference :)

Problem to see Web Services running on local machine

I have written some web service, I run it and see it from my firefox and run it from there.
Now I want to call it from some other code/solution i trying to add there a web reference and Web Services on the Local Machine , but i cannot see there my web services.
Any idea what is missing ? Sorry for the newbie question it's my first time with web services.
Thanks.
when you run the web service you will get a url in browser.Copy that, in reference of your project Add Webreference , it will ask for the url paste it and click go.Add that to your project.
If you are not added in IIS. please add it to IIS and do the rest of operation.other wise when you try for that you wont get the web service.
Or run web service in visual studio debugger and dont close and to the operations.
please also ref: http://msdn.microsoft.com/en-us/library/d9w023sx(VS.80).aspx
If you created the Web service project in a file system, then it ll automatically assign the temporary port number to run the service. In this case you cannot see the service in other projects.
Try creating the IIS virtual directory for the web service and see.

How does calling a web service from a .net app work?

I added a web service as reference to a project and gave it name "days". But I don't actually understand how to work with it. Can someone show me the way how to get data from it?
In posh I get data from a web service this way:
$ws= New-WebServiceProxy -uri $xmld.Root.WebService.Address -credential $cred
$xml = $ws.getdays()
$xml
Have a look at
Walkthrough: Calling XML Web
Services from Windows Forms
Creating a .NET Web Service
Walkthrough: Accessing an XML Web
Service Using Visual Basic or Visual
C#
Fortunately, you don’t need to write a client application to test a web service because .NET includes a test web page that ASP.NET uses automatically when you request the URL of an .asmx file in a browser. This page uses reflection to read and show information about the web services, such as the names of the methods it provides.
To try the test page, request the xyz.asmx file of the web service in your browser. (In Visual Studio, you simply need to set this as the start page for your application and then run it.)

Categories