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

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.)

Related

Web API Missing on deployment

So I have a C# MVC Web API and Web Application that is an all-in-one project. I've created something similar to this in the past but the Web Application and Web API were two different projects with two different URLs.
For example:
The Web Application would be hosted at mywebsite.com/webapp
The Web API would be hosted at mywebsite.com/webapi
Any time I wanted to call the Web API from the Web Application all I had to do is send an Ajax request using the URL mywebsite.com/webapi/api/getdata
However, with my current project it's all-in-one. So in testing I would simply call /api/getdata and it would work just fine in Visual Studio debug. But when I deploy this site for testing and actually host it all my API calls are met with HTTP 404 errors.
So how do I call the Web API when the Web API doesn't have it's own distinct URL?
In IIS I converted the folder to an application and then made sure to switch the calls from
mywebsite.com/api/getdata
to
mywebsite.com/myproject/api/getdata
and it's working now.
Credit to #mxmissile for pointing it out.

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

SOAP WebService... How?

I have a sharepoint web service running at specified host + "/_vti_bin/UserProfileWebService.asmx". I would like to instantiate a web service client, so that i could interact with this service. This is basically what I am trying to do: http://msdn.microsoft.com/en-us/library/ms550407.aspx.
How is this done in .NET? And do I have to use the MOSS API to know what functions it supports?
EDIT:
I guess I should add that I want to connect programmatically, not through a web reference, because that seems to be static.
In VS (2008/2010) you can add a web service reference to your console project for example. It will auto-generate the proxy classes for you to use in your code.

Web Service deployment in IIS?

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.

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.

Categories