Saturday, July 4, 2009
Wednesday, June 24, 2009
Web service Http GET and POST
Create Web service in .Net
1. Create web service project
2. Create web methods
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public EntityCollection GetApplications()
{
EntityCollection applications = new EntityCollection(new AppEntityFactory());
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(applications,null);
return applications;
}
}
3. Http POST and GET enable for localhost by default. But Hosting we have to enable it. If you want to check your service with inputs you have to do following changes
Edit your web.config file with following tag
webServices>
protocols>
add name="HttpPost"/>
add name="HttpGet"/>
add name="Documentation"/>
add name="HttpPostLocalhost"/>
/protocols>
/webServices>
4. For disable http POST do following changes in web.config file
webServices>
protocols>
remove name="HttpPost" />
remove name="HttpGet" />
remove name="HttpPostLocalhost" />
/protocols>
/webServices>
note:
If this doen't work Edit your machine.config file
1. Create web service project
2. Create web methods
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public EntityCollection GetApplications()
{
EntityCollection applications = new EntityCollection(new AppEntityFactory());
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(applications,null);
return applications;
}
}
3. Http POST and GET enable for localhost by default. But Hosting we have to enable it. If you want to check your service with inputs you have to do following changes
Edit your web.config file with following tag
webServices>
protocols>
add name="HttpPost"/>
add name="HttpGet"/>
add name="Documentation"/>
add name="HttpPostLocalhost"/>
/protocols>
/webServices>
webServices>
protocols>
remove name="HttpPost" />
remove name="HttpGet" />
remove name="HttpPostLocalhost" />
/protocols>
/webServices>
note:
If this doen't work Edit your machine.config file
Subscribe to:
Posts (Atom)