We help IT Professionals succeed at work.
Get Started

Create web service to return output of query

nonesuch
nonesuch asked
on
228 Views
Last Modified: 2012-05-06
I am fairly certain this is a simple task, but I can't find a simple example anywhere. What I want to do is create a web service (on PHP) that accepts various parameters that are used to build and execute a SQL query and return a set of data.  I want the XML response to be returned something like the attached code.

I am looking for a response with some example code of how to accomplish exactly this. Please please don't reply with some link to a web site introducing XML (read 'em), because then no one else will respond to the question. I have found tons of code and examples that produce something like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:si="http://soapinterop.org/xsd">
 <SOAP-ENV:Body>
  <ns1:helloResponse xmlns:ns1="http://tempuri.org">
   <return xsi:type="xsd:string">Hello, Scott</return>
  </helloResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

That's not what I need. Unless you're going to tell me (clearly) how I convert that to look like the output below. I will be happy to reward points for a complete answer. If you have some example PHP service code laying around and want to send it to me, I can just modify it to do what I want.  I just need an example that does what I need, because I am not making forward progress on my current attempts.

I've read other comments with "REST" and that sort of thing, again, if you can provide a clear explanation of code examples that accomplish what I want, great, but otherwise, all I know is I have XML extensions and SOAP extensions installed and working and I can get the XML service to return stuff but it's not in that type of cleaned up format... and that's what I need.



<listing>
<item>
<sku>1</sku>
<item_name>shirt</item_name>
<item_color>blue</item_color>
</item>
<item>
<sku>2</sku>
<item_name>jacket</item_name>
<item_color>green</item_color>
</item>
</listing>

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE