• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Creating simple REST webservice using IIS6.0, PHP

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Team,

I am new to Web-services. I have created simple web-service. I am trying to put it on IIS web-server. But whenever I try to access it from client, I am getting just listing of pages at URL. I am not getting expected result.



Is there any settings required at server side to host REST web-services? What change in my script is required to make it run? I am not specifying the file name in URL anywhere then how application server will know that request is to be directed to which page?



I am attaching my script with this. I am  putting in browser_



http://tmpneadveng01/trial/?name=c

& I am expecting output as 300.

My PHP script is
phpScript.PNG
[Thumbnail for phpScript.PNG]
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gajanan Udas,

First of all, a warm welcome to CodeRanch!

Gajanan Udas wrote:Is there any settings required at server side to host REST web-services? What change in my script is required to make it run? I am not specifying the file name in URL anywhere then how application server will know that request is to be directed to which page?


I rarely use IIS to run my PHP code. But I am pretty sure you need to define some rewrite rules to redirect the URL (you enter in your browser) to the appropriate php file. When you are using Apache as a web server, you have to enable the mod_rewrite module and add a .htaccess file containing the rewrite rules. Here is a very good tutorial to create a PHP RESTful Web Service.

Hope it helps!
Kind regards,
Roel

PS. Why do you post code snippets as screenshots and not the plain code snippets (and you should of course UseCodeTags )? If I want to execute your code snippets, I know have to type them myself. So I'll be losing precious time which I could otherwise be spending on typing a nice reply... And another reason: attached images are not searchable using the search engine, plain text or a code snippet definitely is.
 
Gajanan Udas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel De Jijs,

Thanks for your reply. I will search for the rewrite rule settings for IIS.

Here is the code..
 
Saloon Keeper
Posts: 11899
253
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Honestly, I think this approach is very low-level and easy to get wrong.

I would get a PHP framework that handles the front-controller stuff for you, and all you have to do then is use an IIS specific rewrite to direct the request to the framework's front controller.

I can strongly recommend the Laravel framework. Once you have it up and running, it's very easy to set up REST controllers and have the front controller direct requests to the correct REST actions.

Google Laravel IIS, and I'm sure something good will pop up.
 
This one time, at bandcamp, I had relations with a tiny ad.
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic