Usage of web service in ASP.NET web application - web-services

To some this could be stupid question. But here's the deal. I have asp.net web application and I use jquery to call functions inside *.aspx.cs files that have [WebMethod] attribute attached to them. I had no clue that [WebMethod] is mainly using in web services. I never have worked with web services and I saw I can add .asmx file to my project. So from application architecture point of view where should I use and how can I use .asmx files, and if is it mistake to have [WebMethod] attribute inside *aspx.cs files.
Thanks :D:D

Unless you're stuck using .NET 2.0, you shouldn't do either one. .asmx files are now considered by Microsoft to be a "legacy technology". All new web service development should use WCF. See https://stackoverflow.com/tags/wcf/info.

you are rushing for a solution. it not that simple, read articles returned by a search term such as "asp.net web service" or "wcf web services"
and decide how you want to proceed
it will take some time to understand, say one to two weeks..

Related

Creating and using SOAP based web service in Laravel framework

In Laravel 4 framework, how to create a SOAP based web service. I would like to build a SOA based web application in laravel. Please clarify with an example how to use web service with some step by step examples or links as i am completely new to laravel
Thanks in advance..
You can use "php-wsdl-creator" (also supports SOAP). They have a great tutorial and many demo php files to get you started. It can also easily be implemented in laravel or any other framework for that matter. :)
You can find more information on Google Code: https://code.google.com/p/php-wsdl-creator/
Also note that SOAP requires an extension to be loaded in PHP.
For more recent needs, you should use a Project such as wsdl2phpgenerator or PackageGenerator from WsdlToPhp. This sort of projects, requirable with composer, use an OOP approach and allows to build a SOAP request easily with PHP objects then handle the response just as the request with PHP objects.

Is a servlet inside a portlet required to make the portlet as a web service?

I have few questions with respect to portlets and servlets. This may be a continuation of
my previous question.
I m trying to create a portlet which should act also as a web service. I dont know Why,
but the client requires it this way. I negotiated with the client that I can make a
separate web service application using simple jersey servlet... but cannot convince.
I have the following doubts:
A portlet by itself cannot represent independently to the outside world. If that is
the case then what is the benefit in making a portlet as a webservice than not making a
complete webservice project with just servlets?
By web searches, I came across few code sample which can make a portlet as a
webservice. These sample codes suggested me to create a portlet, in the web.xml include the jersey-servlet and servlet container to make the portlet as a web service. Though it might work(I m trying hard to make a working codebase) but why to include a servlet container inside the portlet container which is already residing inside a servlet container. Sounds confusing? The following image can convey by doubt:
In this the liferay is a the servlet which is visible to the browser first. This has
multiple portlets in it. If I am making a portlet as a web service then I have to make it
visible to the browser, so I m including a servlet inside the portlet(Its my assumption
according to the sample code from web). This is like taking a round trip to touch my nose.
I really dont understand why this architecture is like that. The following points which I
guess is sensible for making a portlet as web service are:
(i) If I make a servlet(a separate project) for web service then (working as a liferay developer in the team) we cannot claim this as a liferay project.
(ii) If the web service is a portlet then I can have inter-portlet communication. In case of servlet it cannot(if I m not wrong).
Please suggest.
I think this can drive you to what you need. A portlet can be called in a EXCLUSIVE mode, where no portal or portlet content are generate in the response. So you can produce whatever "HTML" or data you need as a response.
Im researching and starting with Restful, but it seams like a request/response HTML communication. The main difference is the annotation that map an HTML to a Class and methods in standard modes. In liferay you can assign an URL to your portlet. It can produce a behaviour like the one in Restful.

GWT: Expose the service implementation class as web service

Problem scenario is: I am writing a Google Gadget. Data presented in the gadget will come from my deployed GWT app. I am planing to call the web service from Java script to show the required data.
I need to know how I can expose the Service implementation class like GreetingServiceImpl(generated by default as sample in Eclipse GWT project) as web service.
I did tried to to expose the logic using approach suggested here(http://igorshare.wordpress.com/2009/05/20/building-gwt-web-clients-part-2-how-to-expose-rest-full-jax-rs-service-with-jersey-on-tomcat-server/).
But rather than creating the dynamic web project, I created the Google web project in Eclipse. And I am getting the 404 exception.
Any suggestions why I am getting 404 error?
Regards,
Vikram
Check this: Retrieving JSON Data

Building web services without a web server

OK, this is impossible, but I will try to explain the situation here.
Let's say we have cases, that we need a fast setup of a web server in order to have a simple soap web service running (querying a db and so on).
In VS though, upon debugging a web project, it creates a quick ASP.NET development server without relying on the actuall IIS that might be installed on the PC.
Is there any project that does something like that?
This would be ideal for small projects, where a simple executable would get a server ready to go and would allow web services to be executed right away.
I have looked at some stuff over the net like http://msdn.microsoft.com/en-us/magazine/cc163879.aspx and http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2004/05/24/4479.aspx but they seem to be quite outdated and i am not sure how well they work (havent tested them thoroughly)
EDIT: I have build an application like the one you suggest. However, how can i implement HTTP GET/POST requests to the service using this method? I tried using WebGet after my operationcontract but it didnt work. For example, my service is at http://localhost:8080/Service and i would like to use it such as http://localhost:8080/Service/getMethod?x=2.
I believe that the development server used by Visual Studio is based off of the Cassini code base (of which there is a fork here). I also found this article on hosting the asp.net runtime. It was also created a while back (2004), but has been updated since (2008). I think a lot of the core concepts are probably still the same.
Another approach would be a roll-your-own web server using the HttpListener class. This could take some work if you want to use it for hosting asmx type services, but if you were doing RESTful services, it isn't too bad of an option (this is actually how RavenDB works if you are not hosting it under IIS).
A WCF service can be hosted in almost any kind of application, including a Windows Service or a console application. There is no need for a web server at all.
Alright,
i've done it so im posting it here to help anyone who has issues with similar problems.
Create your WCF Service file as usual and then by using ServiceHost (or WebServiceHost) you can easily create a WCF service.
In order to use GET http requests to make it simple to communicate with mobile devices (such as iphone) you can use WebGet above your service methods and make sure you manually add a service endpoint using WebHttpBinding for WebServiceHost or WebHttpBinding with an WebHttpBehavior for ServiceHost.
Then you can call your service methods such as http://localhost:port/webhttpendpointaddress/mymethod?x=2.

Twitching Consumption of Web Services from Web Site to Web Application

I am trying to consume multiple Web Services that redefine some of the same common classes in their wsdl. I currently have them referenced in a Web Site, but I want to convert to Web Application.
Since some of the same classes are redefined from multiple Web Service, the problem is that when adding them in a web Application there is no way to make the namespaces the same across multiple Web Services, like you can in a Web Site.
Is there any way to do what I am looking for?
Show all files in your project, then hand-edit the autogenerated Reference.cs files to change the namespaces (and remove duplicates)? Ugly, but it ought to work.
Alternatively, use wsdl.exe from the command line -- it can generate a single proxy for multiple services -- and then add the generated file to the project manually. The syntax is something like: wsdl http://svr/foo.asmx http://svr/bar.asmx /namespace:Fnord.Proxies