Accessing C# webservices from PHP - c#

I have several web-services that I need to regularly query for data. These services were written in C#, and error out when I try to connect to them via mono. I am able to connect to them via c# and get whatever data I need. All data is in json, if that matters.
I have a php-based website that needs to be able to query these web-services. I'm looking for the best way to get this data from C# to PHP.
My idea so far is to have c# write to a database, then query the db from PHP. While this is an option, I'd prefer to be able to have php initiate the query, providing actual real-time data.

Check out PHP Soap Client

Related

How do I send a push notification from SQL Server to C# code?

I have a Stored Procedure that runs periodically (from a Database Trigger), and it returns a string. I want to send that string (whenever that SP runs) to my C# Code.
How do I do that in SQL Server? I'd rather not simply have the C# code poll a table in the database since I don't know how that will perform.
The cleanest way to do this is to write a SQLCLR procedure that sends a message to your C# code.
How is your C# code executing? Is it in IIS? If not can you make it start a web server and accept a SOAP or REST call?
SOAP calls are a little annoying on SQLCLR, but doable if your well invested in WCF. The path of least resistance is to make a REST call, or even just send the string via a POST body with content-type of text/plain. If you give me more details as to your setup and what your comfortable with on the C# side, I can give you more specific guidance.

Passing data from a MySQL to C# application through PHP

I've got a SSL connection working with my website alongside PHP sessions. I have created my own connection class to provide a single sign on, allowing my user to then interface with php script outputs from my website. I have a question though, currently I use my PHP scripts which query the database and formats the data into a HTML page, which my program then reads over the SSL connection. My program has to parse the data which may be slow for large data volumes. My question is:
without having to radically change my system architecture, is there a way to make passing the data between the server and the C# application more efficient. Currently I'm using string delimiter parsing to extract data in a way similar to command seperated values (CSR).
I've heard the word JSON passed around alot, but I think I might as well use XML instead.
SERVER: MySQL, PHP, APACHE
Thanks
Thomas
What you want to research is c# web applications and a SOA architecture. JSON or SOAP will be the transfer protocol on which your PHP will talk to your C#. What you will need to do if you decide to use soap is make a c# web service as an endpoint between your PHP and your database and the c# will talk to the DB and pass the data to the PHP. you may want to look into caching as well but that's only if you need scalablity. One thing that is nice about PHP 5 is that it has a built in method to talk to the soap protocal which just turns it into an array of values passed from your C# it makes it very easy to do. What your going to need to happen with your PHP is you will need to replace the SQL querys with SOAP connections. One more thing to consider is a WCF service because webservices have been "deprecated" in anything above .net 3.5. Hopefully it shouldn't be too painful
http://php.net/manual/en/class.soapclient.php
Scroll down a little on this page it has some good examples for your calls.
JSON is suppose to be a quicker protocol then SOAP I just do not have alot of experience with it myself.
Handling data in a PHP JSON Object
SOA the main concept apply to c# as well
http://www.javaworld.com/javaworld/jw-06-2005/jw-0613-soa.html
I am not 100% sure about c# and mysql connections I am sure there is stuff out there for it. I think the biggest problem you may have is hosting a C# service on an apache server.
Maybe check into using JAVA web services, I know it works well with apache and mysql and is used by alot of major websites.

Java android client communication with C# server

I am currently writing an application having a client server architecture.
The client is a Java android application
The server is a C# application.
The client will pull data from the server but in some cases push some data to the C# server as well.
The data that server needs to forward the clients is list of data structures (perhaps in the form of XML?), sometime binary data like files.
The client and server are communicating over a wireless network.
Speed and scalability is my top most priority in the design of the system,...
I have to write server as well as the client myself. I will be using sockets for communication.
I need your advise on the form of protocol I should use to exchange data between the Java client and C# server.
Should I write similar data structures (which seems redundant) in java and C# and serialize them ??
or should I exchange xml ??
I am not sure yet what is the best way to do it ..
Essentially there will be commands from client and server will respond with data
Please advise me on this topic the data communicated could be be as large as several gigs over wifi so speed is very important.
Well, there's always JSON. It should be well-supported on both ends and is easy for your server to generate and client to consume. Not sure it helps with your bandwidth concerns any...
I believe WCF might be approperiate for this, WCF uses soap so a Java implementation should work well. WCF also supports steaming, so transferring large files is possible, though I'm not sure if Java supports the streaming protocol.
As for performance, you will probably be limited by the speed of the device and not the protocol.
Have a look at this session from TechEd 2011: "My Customers Are Using iPhone/Android,But I'm a Microsoft Guy. Now What?"
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR304
It would probably be worth looking into MonoDroid if you want to share code between client and server (and if serialize/de-serialize makes sense).
As I don't know what you're building, I would advise you to read up on REST before you continue though. It should give you valuable pointers on how to create a nice API that can be easily consumed by various clients.

C# Http Server with PHP

I'm currently writing an http server in C# and I'm planning on allowing it to use PHP. How does PHP work? Like, the compiler or whatever it uses. I was thinking it takes php files in input and outputs the html or whatever file for the http server to give to the user's request. Is it possible to call on the php compiler or whatever with the file requested by the user? Please tell me if I'm thinking about this the wrong way.
Thanks
There are a couple ways to interact with PHP. The easiest way to get started is to implement CGI in your program.
Wikipedia has a nice example.
Basically, you execute PHP-CGI.exe, and send/receive data over standard in/out.

connecting my WP7(win phone 7) application to remote DB

I want my WP7 application to fetch data from the DB; so it sends the query as string, the server execute the query, then send the result back.
how can I do that?
whatever you can do for me I am so thankful to you, I appreciate, if you provide any sample code (I am using C#).
thank you,
Regards,
Lena
You can use web services (WCF, .asmx, REST, etc. - however you want to build them). However, you should not be sending your query across, that is very bad for security. You should just be passing in parameters to your web service functions.
I don't have sample code for it, but for any connected system (client application, mobile app, whatever) your two best choices (In my experience, and depending on needs) are publishing the data source as OData or using some more specific WCF (or other web-type service) service to handle pushing the data back and forth.
Then, to your phone app, the request is basically just a web call.

Categories

Resources