C # and PHP: a simple example of a PHP web service used by C #

Can someone give me a small and simple example of how to do this? Or some good recommendations on how to get started.

I would like to create a C # client that can send a file or some text or xml or something else to a web service or something similar in PHP, where the PHP web service stores it in a file or database or something else like that. Just not sure how to get started.

I guess the first step would be to create a php web service. And then it might be quite easy to use it in C #, since I could pretty much use the "Add Web Link" button in vs and then go from there?

+4
source share
5 answers

You can see this tutorial , which shows how to develop a web service using php. The .NET client will be pretty simple, as you mentioned.

+3
source

I do not understand the C # aspect of your question, which you intend to be a consumer. But if you don't mind using the library to speed up the web service launch process, you can install it very quickly using the Zend Framework . Check out the Zend_Rest_Server configuration documentation.

+1
source

Just a thought ... if a service should only support simple operations, such as “upload a file”, maybe bypassing WSDL together? I assume that PHP can handle raw requests, so you can use the oh-so-complex.NET client:

using (WebClient client = new WebClient()) { client.UploadFile("http://some/upload.php", "foo.bar"); client.UploadString("http://some/upload.php", "some text"); } 

etc .. Similarly, you can often easily use POX / REST without the complexity of a formal contract with a web service. The above code just makes a simple HTTP request with the contents / contents of the file in the body.

+1
source

you're right. all you have to do is create a simple PHP web service that accepts the request / xml / file and then saves it to the database. then you can use webservice using any technology, C # for confidence. in order to write a web service in PHP, I think it is better to choose the type of webservice in the first step. it can be a REST, SOAP, or XML-RPC web service. it depends on the difficulty level of your application.

if your application is as simple as just throwing a string in a web service or file URL, so the web service can store that string or extract a file from the URL and store it in the database, I return REST. because it is easier. as simple as writing a simple PHP script that uses it as input to HTTP.

but you want it to be safer or have more complex needs. It is easy to have SOAP services in PHP. if you want to work with SOAP, PHP has an extension (php-soap) that you can install and use the built-in functions of PHP-SOAP. if you are using an older version of PHP that does not support the extension, or your application is placed where php-soap is not installed, there is a pure PHP SOAP protocol implementation called nusoap. It is open source and works very well.

http://sourceforge.net/projects/nusoap/

0
source

I did a job in the PHP NuSOAP webservice and my C # mobile client getting data from web services. Below is the link

http://khanmubeen.wordpress.com/2010/11/18/web-services-with-php-nusoap-c-mobile-client/

If you like to know more from me, welcome to the “I” folder in mubeen44us at gmail.com

0
source

All Articles