Page 1 of 1

[SOLVED] PEAR::SOAP

Posted: Wed Sep 06, 2006 10:52 am
by chocolatetoothpaste
I need some help really bad. I am using pear::soap to connect to a webservice. I am connecting fine and receiving a proper response. The problem is I don't know how to parse that data into a usable php array. I need to be able to manipulate and format that data to display it on a website. I am not dead set on pear::soap, that is just what I have been using. If you can suggest something else I would use it. I don't like nusoap too much, and XML_RPC hasn't been working properly. Please any help you can give, thanks.

Posted: Thu Sep 07, 2006 12:16 pm
by chocolatetoothpaste
bump. please help!

Posted: Thu Sep 07, 2006 12:46 pm
by wtf
I haven't used PEAR::SOAP but I have used nuSOAP and from what I've used it for it returns an array all the time. Why don't you print_r() your return to see what's in there first, then post it up here.


~d

Posted: Thu Sep 07, 2006 4:25 pm
by chocolatetoothpaste
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


When I use print_r(), it just spits out the data but not the xml tags.  when I save the response to a file, the file still has all of the xml in place.  This is what my script looks like:

Code: Select all

<?php
    require_once 'SOAP/Client.php';
    $wsdl = new SOAP_WSDL('******');
    $client = $wsdl->getProxy();
    $result = $client->GetLeadsByDate('******', '******','2006-07-01','2006-07-09');
    
    ?><div align="left"><pre><?php print_r($result); ?></pre></div><?php
?>
The stars are the address, username, and password respectively. SO anyway, when I do print_r(), it looks a little like this:

Code: Select all

TrueCall was successful
6539811UT: Salt Lake City (All)1415626 S 1915 ECottonwoodUT84121USANewspaper07-03-200607-04-2006(801) 424-2188Do Not Call RegistryTrue5646 Nations WAYSalt Lake CityUT84121UnitedStatesKurtLarsen2.7540.24 Acre_265000UnknownHomeYesYesYesYes
6551434UT: Salt Lake City (All)141DraperUt84020USANewspaper07-05-200607-06-2006(801) 654-3826FalseSalt Lake CityUTUnitedStates2.0040.29 Acre259900Multi-LevelHomeYesYesYes
6539818UT: Salt Lake City (All)141East MillcreekUTUSANewspaper07-03-200607-04-2006(801) 859-7683FalseSalt Lake CityUTUnitedStates2.503_329900UnknownHomeYesBackyardYesYes
etc, etc.

Is there something wrong with my script?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Sep 07, 2006 7:06 pm
by wtf
Maybe you need to pass $result to a xml parser. What does the doc say?

OK... I just downloaded PEAR::SOAP-0.9.4. In the example folder there's an 'example' that shows you how to deal with wsdl docs. You should check it out.

Re: PEAR::SOAP

Posted: Fri Sep 08, 2006 9:40 am
by chocolatetoothpaste
chocolatetoothpaste wrote:The problem is I don't know how to parse that data into a usable php array. I need to be able to manipulate and format that data to display it on a website.
That was the intent of the original post. I don't know how to pass it to a parser. Does PEAR::SOAP have a parser, or are there some other functions or classes I can pass it to?

Posted: Fri Sep 08, 2006 2:55 pm
by wtf
If you're using PHP5, you can check out simple_xml to parse your xml

You would use it something like this

Code: Select all

$xml = new SimpleXMLElement($result);

echo $xml->node_name_in_your_xml[0]->element;

Posted: Fri Sep 08, 2006 6:25 pm
by Ollie Saunders
SOAP == XML:
DOM / SAX / XSLT are all worthy. Read a short article on what each isdoes (yes that's a word, biatch).
I generally use DOM mostly (used to it from JS) but I'm learning XSLT.

Posted: Sat Sep 09, 2006 1:52 pm
by wtf
There are 'biatches' in UK :?:

Posted: Sat Sep 09, 2006 1:59 pm
by Ollie Saunders
Here in the UK we pick and choose which bits of America we like. Biatch is one of them. Admittedly only Internet folk and people who watch South Park would know what I was talking about if I was to call somebody a 'biatch' but I'm sure they would appreicate the brilliance.

Posted: Sat Sep 09, 2006 2:40 pm
by wtf
Amazing, out of all 'bits' that have been invented to enhance English as a language 'Brits' adopt 'biaaatch'???? Very interesting.

Posted: Mon Sep 11, 2006 3:57 pm
by chocolatetoothpaste
I am using php 4. Does anyone have any ideas for parsing in php 4?
Here is the xml I need to parse:

Code: Select all

<result><success>True</success><message>Call was successful</message><data><Listings><Listing><id>6509880</id><AreaName>UT: Ogden (All)</AreaName><AreaId>157</AreaId><Street>3075 Polk</Street><City>Ogden</City><Locality>UT</Locality><PostalCode>84403</PostalCode><Country>USA</Country><SourceName>Newspaper</SourceName><ListingDate>07-01-2006</ListingDate><DeliveryDate>07-02-2006</DeliveryDate><Contacts><Contact><PhoneNumber>(801) 621-8017</PhoneNumber><IsOnDNC>False</IsOnDNC><Street>3075 Polk AVE</Street><City>Ogden</City><Locality>UT</Locality><PostalCode>84403</PostalCode><Country>UnitedStates</Country><FirstName>Philip</FirstName><LastName>Boyer</LastName></Contact><Contact><PhoneNumber>(801) 391-8300</PhoneNumber><IsOnDNC>False</IsOnDNC><City>Ogden</City><Locality>UT</Locality><Country>UnitedStates</Country></Contact></Contacts><DataValues><dv Name="Bathrooms">2.00</dv><dv Name="Bedrooms">4</dv><dv Name="Lot Size">.22Acre_</dv><dv Name="Price">184900</dv><dv Name="Property Style">Rambler</dv><dv Name="Property Type">Home</dv><dv Name="Fence">Yes</dv><dv Name="Fence Info">Backyard</dv></DataValues></Listing><Listing><id>6509929</id><AreaName>UT: Ogden (All)</AreaName><AreaId>157</AreaId><City>Ogden area</City><Locality>UT</Locality><Country>USA</Country><SourceName>Newspaper</SourceName><ListingDate>07-01-2006</ListingDate><DeliveryDate>07-02-2006</DeliveryDate><Contacts><Contact><PhoneNumber>(801) 336-6178</PhoneNumber><IsOnDNC>False</IsOnDNC><City>Kaysville</City><Locality>UT</Locality><Country>UnitedStates</Country></Contact></Contacts><DataValues><dv Name="Bathrooms">1.50</dv><dv Name="Bedrooms">3</dv><dv Name="Lot Size">_</dv><dv Name="Price">105999</dv><dv Name="Property Style">Unknown</dv><dv Name="Property Type">Home</dv><dv Name="Fence">Yes</dv><dv Name="Fence Info">Backyard</dv><dv Name="Garage">Yes</dv><dv Name="Garage Info">2</dv><dv Name="Family Room">Yes</dv><dv Name="Living Room">Yes</dv></DataValues></Listing><Listing><id>6513327</id><AreaName>UT: Logan (All)</AreaName><AreaId>168</AreaId><Street>350 W 880 N</Street><City>Logan</City><Locality>UT</Locality><PostalCode>84321</PostalCode><Country>USA</Country><SourceName>Newspaper</SourceName><ListingDate>07-01-2006</ListingDate><DeliveryDate>07-02-2006</DeliveryDate><Contacts><Contact><PhoneNumber>(435) 770-4224</PhoneNumber><IsOnDNC>False</IsOnDNC><City>Logan</City><Locality>UT</Locality><Country>UnitedStates</Country></Contact></Contacts><DataValues><dv Name="Bathrooms">2.00</dv><dv Name="Bedrooms">5</dv><dv Name="Lot Size">_</dv><dv Name="Price">156000</dv><dv Name="Property Style">Unknown</dv><dv Name="Property Type">Home</dv></DataValues></Listing><Listing><id>6513330</id><AreaName>UT: Logan (All)</AreaName><AreaId>168</AreaId><City>Smithfield</City><Locality>UT</Locality><PostalCode>84335</PostalCode><Country>USA</Country><SourceName>Newspaper</SourceName><ListingDate>07-01-2006</ListingDate><DeliveryDate>07-02-2006</DeliveryDate><Contacts><Contact><PhoneNumber>(435) 512-6933</PhoneNumber><IsOnDNC>False</IsOnDNC><City>Logan</City><Locality>UT</Locality><Country>UnitedStates</Country></Contact></Contacts><DataValues><dv Name="Price">72000</dv><dv Name="Property Style">Unknown</dv><dv Name="Property Type">Lot</dv></DataValues></Listing><Listing><id>6517396</id><AreaName>UT: Davis County (All)</AreaName><AreaId>176</AreaId><Street>2921 S 450Th W</Street><City>Bountiful</City><Locality>UT</Locality><PostalCode>84010</PostalCode><Country>USA</Country><SourceName>Newspaper</SourceName><ListingDate>07-01-2006</ListingDate><DeliveryDate>07-03-2006</DeliveryDate><Contacts><Contact><PhoneNumber>(801) 294-4597</PhoneNumber><DoNotCall>Do Not Call Registry</DoNotCall><IsOnDNC>True</IsOnDNC><Street>2921 S 450th W</Street><City>Bountiful</City><Locality>UT</Locality><PostalCode>84010</PostalCode><Country>UnitedStates</Country><FirstName>William C</FirstName><LastName>Hair</LastName></Contact><Contact><PhoneNumber>(801) 706-9780</PhoneNumber><DoNotCall>Do Not Call Registry</DoNotCall><IsOnDNC>True</IsOnDNC><City>Salt Lake City</City><Locality>UT</Locality><Country>UnitedStates</Country></Contact></Contacts><DataValues><dv Name="Bathrooms">3.00</dv><dv Name="Bedrooms">4</dv><dv Name="Lot Size">0.25 Acre</dv><dv Name="Price">260000</dv><dv Name="Property Style">Unknown</dv><dv Name="Property Type">Home</dv><dv Name="Jacuzzi">Yes</dv><dv Name="Open House">7/8 9-7</dv><dv Name="Open House Info">7/8 9-7</dv></DataValues></Listing><Listing><id>6517398</id><AreaName>UT: Davis County (All)</AreaName><AreaId>176</AreaId><City>Centerville</City><Locality>UT</Locality><PostalCode>84014</PostalCode><Country>USA</Country><SourceName>Newspaper</SourceName><ListingDate>07-01-2006</ListingDate><DeliveryDate>07-03-2006</DeliveryDate><Contacts><Contact><PhoneNumber>(801) 580-6739</PhoneNumber><IsOnDNC>False</IsOnDNC><City>Salt Lake City</City><Locality>UT</Locality><Country>UnitedStates</Country></Contact><Contact><PhoneNumber>(801) 499-1393</PhoneNumber><IsOnDNC>False</IsOnDNC><City>Kaysville</City><Locality>UT</Locality><Country>UnitedStates</Country></Contact></Contacts><DataValues><dv Name="Bathrooms">1.50</dv><dv Name="Bedrooms">3</dv><dv Name="Lot Size">_</dv><dv Name="Property Style">Unknown</dv><dv Name="Property Type">Home</dv><dv Name="Fireplace">Yes</dv></DataValues></Listing><Listing><id>6509915</id><AreaName>UT: Davis County (All)</AreaName><AreaId>176</AreaId><Street>2171 S 650 E</Street><City>Clearfield</City><Locality>UT</Locality><PostalCode>84015</PostalCode><Country>USA</Country><SourceName>Newspaper</SourceName><ListingDate>07-01-2006</ListingDate><DeliveryDate>07-02-2006</DeliveryDate><Contacts><Contact><PhoneNumber>(801) 603-5005</PhoneNumber><DoNotCall>Do Not Call Registry</DoNotCall><IsOnDNC>True</IsOnDNC><City>Ogden</City><Locality>UT</Locality><Country>UnitedStates</Country></Contact></Contacts><DataValues><dv Name="Bathrooms">4.00</dv><dv Name="Bedrooms">6</dv><dv Name="Price">319000</dv><dv Name="Property Style">Unknown</dv><dv Name="Property Type">Home</dv><dv Name="Fence">Yes</dv><dv Name="Garage">Yes</dv><dv Name="Garage Info">3</dv><dv Name="Parking">Yes</dv><dv Name="Parking Info">RV</dv><dv Name="Living Room">Yes</dv></DataValues></Listing></Listings></data></result>

Posted: Mon Sep 11, 2006 9:11 pm
by Ambush Commander

[SOLVED] PEAR::SOAP

Posted: Tue Sep 12, 2006 11:14 am
by chocolatetoothpaste
Excellent! That helped me get at least a temporary solution. Hopefully PEAR::SOAP finalizes a release and we get some better docs on the net. I wish I had the capacity to read the technical docs and figure it all out and be able to write a tut, but that is just not me. Thanks again!