Which is the best method to get response from a web service URL? for example, we can use cURL, file_get_contents, file, .. to get response. Can anybody help me to find a best one?

Depends on your needs. If you only need GET parameters then file_get_contents should be fine. cURL on the other hand allows for much more customization in headers sent.

I will get an XML response from my web service. So in my site I want call my web service to get XML response and parse it. It is a search web service. So when users search, I will call this service. So it must be very faster. which is better way? file_get_contents() or cURL or anu other?

Are there parameters and if so do they need passed via GET or POST requests?

cURL will allow for GET and POST requests, but file_get_contents will only be able to open urls that can accept GET requests.

Since you're parsing XML and 90% of the web services I see work with GET requests I'm going to take a shot in the dark and recommend using SimpleXML to do both at the same time.

Here is a pretty good tutorial on parsing xml retrieved from a url with SimpleXML: http://www.ibm.com/developerworks/library/x-simplexml.html

Thanks...

I am using GET request and passing parameters. Can you please tell me file_get_contents() or cURL is better performance?

SimpleXML as it will eliminate having to first load the contents with either cURL or file_get_contents and then having to load that data into SimpleXML or the DOM to then parse the XML.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.