|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Help with Soap ClientHi All,
I am using the following code to build a SoapClient with some web service: //////////////// <?php ini_set("soap.wsdl_cache_enabled", "0"); ini_set('default_socket_timeout', 600); $client = new SoapClient("http://iaspub.epa.gov/webservices/StationService/index.html?WSDL",array('trace' => 1)); try { $sc = $client->getStationCount(43.1,43.5,-83.5,-83.1); print $sc; } catch (SoapFault $exception) { echo $exception; } ?> ////////////// But I got the following error: /////////////// Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Unspecified encodingStyle in /var/www/myphp/wqxststest.php:5 Stack trace: #0 /var/www/myphp/wqxststest.php(5): SoapClient->SoapClient('http://iaspub.e...', Array) #1 {main} thrown in /var/www/myphp/wqxststest.php on line 5 /////////////// Also when I tried same code (See below) with another service, it seems working fine. /////////////// <?php $huc = $_REQUEST['huc']; ini_set("soap.wsdl_cache_enabled", "0"); ini_set('default_socket_timeout', 600); $client = new SoapClient("http://iaspub.epa.gov/webservices/WatershedSummaryService/index.html?WSDL",array('trace' => 1)); try { $client->getCharacteristicSummary($huc); print $client->__getLastResponse(); } catch (SoapFault $exception) { echo $exception; } /////////////// ?> I tried to find what's causing this error on Google but no success. Anyone know what's going on? Your help is highly appreciated! Tom -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
|
|
|
Re: Help with Soap ClientHi Naveen,
Now I can get the soap response back with the following code, but my new problem is how I can parse out information from returned stdClass Object. Originally I thought about using simplexml to get what I need, but it didn't work since the returned results are in stdClass Objects. I also listed the response I got from this code. //////////////////// <?php ini_set("soap.wsdl_cache_enabled", "0"); ini_set('default_socket_timeout', 600); $client = new SoapClient("ss.wsdl", array('trace'=> 1, 'exceptions'=> 1, ) ); try { $a=$client->getStationCount(43.1,43.5,-83.5,-81.2); $stresults=$client->getStationsForMap(43.1,43.5,-83.5,-81.2); print $a; print_r($stresults); } catch (SoapFault $exception) { echo $exception; } ?> ///////////////////////////////// //////////////////////////// stdClass Object ( [WQX] => stdClass Object ( [Organization] => Array ( [0] => stdClass Object ( [OrganizationDescription] => stdClass Object ( [OrganizationIdentifier] => 21MICH [OrganizationFormalName] => Michigan Department of Environmental Quality ) [MonitoringLocation] => Array ( [0] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760172 [MonitoringLocationName] => BERRY DRAIN AT UPSTREAM SANDUSKY WWTP; T11N R14E S04 [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.41801 [LongitudeMeasure] => -82.81985 ) ) [1] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760089 [MonitoringLocationName] => BERRY DRAIN AT CUSTER ROAD BRIDGE; CUSTER TOWNSHIP, SEC 24 [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.452781 [LongitudeMeasure] => -82.752227 ) ) [2] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760197 [MonitoringLocationName] => Lake Huron, Birch Beach South #1 [MonitoringLocationTypeName] => BEACH Program Site-Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.20194 [LongitudeMeasure] => -82.51139 ) ) [3] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760174 [MonitoringLocationName] => BERRY DRAIN AT DOWNSTREAM SANDUSKY WWTP; T11N R14E S04 [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.4211 [LongitudeMeasure] => -82.8199 ) ) [4] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760201 [MonitoringLocationName] => Lake Huron, Lexington Beach [MonitoringLocationTypeName] => BEACH Program Site-Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.26965 [LongitudeMeasure] => -82.52617 ) ) [5] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760180 [MonitoringLocationName] => MILLER CREEK AT HURON VIEW ROAD; SANILAC TOWNSHIP, SEC 21 [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.4694 [LongitudeMeasure] => -82.5745 ) ) [6] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 250444 [MonitoringLocationName] => HOLLOWAY RES. IN S.CENT.BAS. RICHFIELD TOWNSHIP SEC12 [MonitoringLocationTypeName] => Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.112504 [LongitudeMeasure] => -83.462782 ) ) [7] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760207 [MonitoringLocationName] => BERRY DRAIN UPSTREAM OF STRINGER ROAD (U/S MICHIGAN PEAT OUT [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.4223957 [LongitudeMeasure] => -82.790092 ) ) [8] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 790157 [MonitoringLocationName] => EVERGREEN CREEK AT WATERMAN ROAD; T11N R08E S01 [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.3943 [LongitudeMeasure] => -83.476 ) ) [9] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760090 [MonitoringLocationName] => BERRY DRAIN 0.1 MILES FROM MOUTH; BRHAMPTON TOWNSHIP, [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.453337 [LongitudeMeasure] => -82.745837 ) ) [10] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760199 [MonitoringLocationName] => Lake Huron, Birch Beach Middle #2 [MonitoringLocationTypeName] => BEACH Program Site-Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.19766 [LongitudeMeasure] => -82.5093 ) ) [11] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760198 [MonitoringLocationName] => Lake Huron, Birch Beach North #3 [MonitoringLocationTypeName] => BEACH Program Site-Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.20249 [LongitudeMeasure] => -82.51188 ) ) [12] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760206 [MonitoringLocationName] => DWIGHT DRAIN AT STRINGER ROAD, T12N R14E S34 [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.4405246 [LongitudeMeasure] => -82.792078 ) ) [13] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760087 [MonitoringLocationName] => BERRY DRN AT STRINGER ROAD BRIDGE; CUSTER TOWNSHIP, SEC 35 [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.422503 [LongitudeMeasure] => -82.790838 ) ) [14] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 440103 [MonitoringLocationName] => OTTER LK. IN S-CENT.BASIN,MARATHON TOWNSHIP.,SEC.6 [MonitoringLocationTypeName] => Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.21667 [LongitudeMeasure] => -83.458892 ) ) [15] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760200 [MonitoringLocationName] => Lake Huron, Lexington County Park [MonitoringLocationTypeName] => BEACH Program Site-Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.31639 [LongitudeMeasure] => -82.52889 ) ) [16] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 730088 [MonitoringLocationName] => CASS RIVER AT STUDOR ROAD; T11N R05E S17 [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.351949 [LongitudeMeasure] => -82.91528 ) ) [17] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760202 [MonitoringLocationName] => Lake Huron, Port Sanilac Park [MonitoringLocationTypeName] => BEACH Program Site-Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.43832 [LongitudeMeasure] => -82.54007 ) ) ) ) [1] => stdClass Object ( [OrganizationDescription] => stdClass Object ( [OrganizationIdentifier] => NARS [OrganizationFormalName] => EPA National Aquatic Resource Survey Data ) [MonitoringLocation] => Array ( [0] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => OWW04440-0418 [MonitoringLocationName] => Bottom Creek [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.2 [LongitudeMeasure] => -83.2 ) ) [1] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => OWW04440-0482 [MonitoringLocationName] => HEMMINGWAY AND WHIPPLE DRAIN [MonitoringLocationTypeName] => River/Stream ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.18 [LongitudeMeasure] => -83.4 ) ) ) ) [2] => stdClass Object ( [OrganizationDescription] => stdClass Object ( [OrganizationIdentifier] => 21MICH_WQX [OrganizationFormalName] => Michigan Department of Environmental Quality ) [MonitoringLocation] => Array ( [0] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 740413 [MonitoringLocationName] => Washington Street Park [MonitoringLocationTypeName] => BEACH Program Site-Great Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.112637 [LongitudeMeasure] => -82.487213 ) ) [1] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 740405 [MonitoringLocationName] => Jeddo Road Beach [MonitoringLocationTypeName] => BEACH Program Site-Great Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.155186 [LongitudeMeasure] => -82.498795 ) ) [2] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760200 [MonitoringLocationName] => Lexington County Park [MonitoringLocationTypeName] => BEACH Program Site-Great Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.316391 [LongitudeMeasure] => -82.528893 ) ) [3] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760202 [MonitoringLocationName] => Port Sanilac Park [MonitoringLocationTypeName] => BEACH Program Site-Great Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.43832 [LongitudeMeasure] => -82.54007 ) ) [4] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 760201 [MonitoringLocationName] => Lexington Beach [MonitoringLocationTypeName] => BEACH Program Site-Great Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.26965 [LongitudeMeasure] => -82.526169 ) ) [5] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 740406 [MonitoringLocationName] => Burtchville Township Park [MonitoringLocationTypeName] => BEACH Program Site-Great Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.145527 [LongitudeMeasure] => -82.495018 ) ) [6] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 740401 [MonitoringLocationName] => Lakeport State Campground [MonitoringLocationTypeName] => BEACH Program Site-Great Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.126648 [LongitudeMeasure] => -82.492172 ) ) [7] => stdClass Object ( [MonitoringLocationIdentity] => stdClass Object ( [MonitoringLocationIdentifier] => 740400 [MonitoringLocationName] => Lakeport State Park [MonitoringLocationTypeName] => BEACH Program Site-Great Lake ) [MonitoringLocationGeospatial] => stdClass Object ( [LatitudeMeasure] => 43.107735 [LongitudeMeasure] => -82.486801 ) ) ) ) ) ) ) ////////////////////////////////////// Again, thanks a lot for your help! Tom On Sun, Apr 19, 2009 at 9:15 AM, NAVEEN <naveenkr2001@...> wrote: > Hi Tom, > > The problem is in the WSDL. > Search for those lines having use="encoded" in WSDL file and append > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" with them. > > Previous: > use="encoded" > After Modification : > use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" > > Hope it works! > > Naveen > > --- On Sun, 4/19/09, EPA WC <epawcweb@...> wrote: > > From: EPA WC <epawcweb@...> > Subject: [SOAP] Help with Soap Client > To: soap@... > Date: Sunday, April 19, 2009, 9:57 AM > > Hi All, > > I am using the following code to build a SoapClient with some web service: > > //////////////// > <?php > > ini_set("soap.wsdl_cache_enabled", "0"); > ini_set('default_socket_timeout', 600); > $client = new > SoapClient("http://iaspub.epa.gov/webservices/StationService/index.html?WSDL",array('trace' > => 1)); > try { > $sc = $client->getStationCount(43.1,43.5,-83.5,-83.1); > print $sc; > } catch (SoapFault $exception) { > echo $exception; > } > > ?> > ////////////// > > But I got the following error: > /////////////// > Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing > WSDL: Unspecified encodingStyle in /var/www/myphp/wqxststest.php:5 > Stack trace: #0 /var/www/myphp/wqxststest.php(5): > SoapClient->SoapClient('http://iaspub.e...', Array) #1 {main} thrown > in /var/www/myphp/wqxststest.php on line 5 > /////////////// > > Also when I tried same code (See below) with another service, it seems > working fine. > /////////////// > <?php > $huc = $_REQUEST['huc']; > ini_set("soap.wsdl_cache_enabled", "0"); > ini_set('default_socket_timeout', 600); > $client = new > SoapClient("http://iaspub.epa.gov/webservices/WatershedSummaryService/index.html?WSDL",array('trace' > => 1)); > try { > $client->getCharacteristicSummary($huc); > print $client->__getLastResponse(); > } catch (SoapFault $exception) { > echo $exception; > } > /////////////// > ?> > > I tried to find what's causing this error on Google but no success. > Anyone know what's going on? > > Your help is highly appreciated! > > Tom > > -- > PHP Soap Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Help with Soap ClientTom,
On 04/19/2009 12:58 PM, EPA WC wrote: > Now I can get the soap response back with the following code, but my > new problem is how I can parse out information from returned stdClass > Object. Originally I thought about using simplexml to get what I need, > but it didn't work since the returned results are in stdClass Objects. > I also listed the response I got from this code. > No parsing is required. That's kind of the point of using the soap client. You get back a php object with all the data you would normaly have to parse out of the xml yourself. For example, to display the organization names in a list, you just walk the array for ( $i=0; $i < count($stresults->Organization); $i++ ) { echo $stresults->Organization[$i]->OrganizationDescription->OrganizationFormalName; } Make sense? Roger -- Roger Roelofs Datacomp Appraisal Services rer@... -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Help with Soap ClientThanks Roger. Yes I figured it out too once I changed my mindset from
simplexml to object. But I'd like to see some generic code that can take xml schema and extract data needed from soap response objects. Tom On Sun, Apr 19, 2009 at 6:20 PM, Roger Roelofs <rer@...> wrote: > Tom, > > On 04/19/2009 12:58 PM, EPA WC wrote: >> >> Now I can get the soap response back with the following code, but my >> new problem is how I can parse out information from returned stdClass >> Object. Originally I thought about using simplexml to get what I need, >> but it didn't work since the returned results are in stdClass Objects. >> I also listed the response I got from this code. >> > > No parsing is required. That's kind of the point of using the soap client. > You get back a php object with all the data you would normaly have to parse > out of the xml yourself. For example, to display the organization names in > a list, you just walk the array > > for ( $i=0; $i < count($stresults->Organization); $i++ ) { > echo > $stresults->Organization[$i]->OrganizationDescription->OrganizationFormalName; > } > > Make sense? > > Roger > -- > Roger Roelofs > Datacomp Appraisal Services > rer@... > > > -- > PHP Soap Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Help with Soap ClientTom,
You would use the same kind of code you would use to iterate over any php object. I suppose if you were looking to draw a map you could write a callback that gets called for particularly named elements. The code that follows is off the top of my head and untested, but it might give you an idea. function doRealWork(item) { // whatever } function recurse($data, $find, $callback) { $type = gettype($data); if (( $type == "array" ) || ( $type == "object" )) { foreach ( $type as $key => $val ) { if ( $key == $find ) $callback($val); elseif ( ! is_scalar($val ) recurse($val, $find, $callback); } } } recurse($stresults, "elementToFind", "doRealWork"); On 04/19/2009 08:25 PM, EPA WC wrote: > Thanks Roger. Yes I figured it out too once I changed my mindset from > simplexml to object. But I'd like to see some generic code that can > take xml schema and extract data needed from soap response objects. > > Tom > > On Sun, Apr 19, 2009 at 6:20 PM, Roger Roelofs<rer@...> wrote: > >> Tom, >> >> On 04/19/2009 12:58 PM, EPA WC wrote: >> >>> Now I can get the soap response back with the following code, but my >>> new problem is how I can parse out information from returned stdClass >>> Object. Originally I thought about using simplexml to get what I need, >>> but it didn't work since the returned results are in stdClass Objects. >>> I also listed the response I got from this code. >>> >>> >> No parsing is required. That's kind of the point of using the soap client. >> You get back a php object with all the data you would normaly have to parse >> out of the xml yourself. For example, to display the organization names in >> a list, you just walk the array >> >> for ( $i=0; $i< count($stresults->Organization); $i++ ) { >> echo >> $stresults->Organization[$i]->OrganizationDescription->OrganizationFormalName; >> } >> >> Make sense? >> >> -- Roger Roelofs Datacomp Appraisal Services rer@... -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Help with Soap ClientFirst retrieve the WSDLs for both services and look at the XML line at the top to see what encoding is specified. Then set your soap client to use the same encoding when you create it. Most of the time this is set to UTF-8.
Ciao, Andrew
|
| Free embeddable forum powered by Nabble | Forum Help |