Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all
I have a ASMX web service that query a SQL Server 2008 and must return it's results as a table.
i want to use this web service in a PHP web application.
my question is how to transfer a table over a web serivce
please help me out

Best Regards
abforce
Posted
Comments
jkirkerx 10-Apr-13 13:30pm    
That depends on a couple of factors,

You can create a universal web service in asp.net, that can be accessed by PHP or whatever from a different domain.

But if your talking about using PHP and Jquery in a different domain, that gets a bit more tricky, because if the cross domain security issues.

As far as the table goes, I assume your talking about the entire table of columns, so I would personally use JOSN for a JQuery Request, or XML or WSDL for a cross domain request.

You should improve your question and add those details to get the right answer.
Kschuler 10-Apr-13 13:57pm    
..I might be making this up...but I don't think that you can return a datatable. Something about it not being serializeable. You have to put the datatable in a dataset and return the dataset, which is someone serializeable even though it contains a non-serializeable datatable. I can't remember the details, just remember running into that when I created an asmx webservice years ago. But maybe it's different because my client side wasn't PHP.
Kschuler 10-Apr-13 14:00pm    
I googled and found a post where someone said that .Net 2 made the DataTable Serializable. So...ignore me.

1 solution

I'm going to suggest using a ASHX page and soap since your using PHP to access the service, and I assume that a request with proper credentials from any domain can use the service.

Basically you write a WSDL file that defines your table request, and different possible responses that you may send back such as faults, warnings, errors, and the actual data requested.It's like XML, or sort of like XSD.

Then you write a class to receive the SOAP request, access the database, package the data, send back the response.

Now you register that class on the ASHX page, and place the page on the web server.

I could not find any easy to understand examples of the whole process, but found some simple examples, and talk about the subject.

http://www.dotnetperls.com/ashx[^]

http://blog.beacontechnologies.com/using-net-ashx-handlers-to-build-web-services-2/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900