Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien

SOAP Webservice, wsdl uitlezen

Pagina: 1
Acties:

  • Kenny_026
  • Registratie: Juli 2007
  • Niet online
(overleden)
Ik zag een soortgelijk ander topic alleen lijkt mijn probleem iets anders. Ik ben ook geen echte programmeur maar een XML uitlezen en de inhoud op het scherm toveren lukte me altijd wel maar een .wsdl uitlezen lijkt toch andere koek....

Dit is wat ik nu heb...

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php 

//require_once('SoapClientAuth.php');
date_default_timezone_set('Europe/Amsterdam');
ini_set("soap.wsdl_cache_enabled", "0");

#- verbinden met WSDL 

$client = new SoapClient("http://www.site.nl/api/v2/wsdl/products.wsdl", 
        array('login'=> "user",
              'password'=> "passwd"));

print_r( $client->__getFunctions() );
?><br /><br /><br /><?
print_r( $client->__getTypes() );
            
class Product {
        public $cat_id;
        public $item_id;
        public $title;
        public $minprice;
        public $image_url;
        public $direct_link;}
            
            
function productitemsearch()
  {
    $product = new Product();
    $product->cat_id = $cat_id;
    $product->item_id = $item_id;
    $product->title = $title;
    $product->minprice = $minprice;
    
    return $product;
  }     
  
$product = $client->productitemsearch("input", array('cat_id' =>4, 'item_id' => 68899));

echo ($product); 
?>


en de output geeft dan dit...
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error cannot find parameter in /home/indexxx/public_html/gamesite/wsdl/index2.php:41 Stack trace: #0 /home/indexxx/public_html/gamesite/wsdl/index2.php(41): SoapClient->__call('productitemsear...', Array) #1 /home/indexxx/public_html/gamesite/wsdl/index2.php(41): SoapClient->productitemsearch('input', Array) #2 {main} thrown in /home/indexxx/public_html/gamesite/wsdl/index2.php on line 41
wie o wie kan mij helpen?

  • Ealanrian
  • Registratie: Februari 2009
  • Nu online
Op regel 26 staat:
PHP:
1
function productitemsearch()

een functie zonder parameters dus. op regel 37 roep je die functie aan met parameters. Dat gaat niet werken volgens mij.

  • Kenny_026
  • Registratie: Juli 2007
  • Niet online
(overleden)
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function productitemsearch($product)
  {
    $product = new Product();
    $product->cat_id = $cat_id;
    $product->item_id = $item_id;
    $product->title = $title;
    $product->minprice = $minprice;
    
    return $product;
  }     
  
$product = $client->productitemsearch( array('cat_id' =>4, 'item_id' => 68899));

echo ($product); 
?>


Ik heb het nu aangepast zoals hierboven maar nu krijg ik een andere fout...
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'input' property in /home/indexxx/public_html/gamesite/wsdl/index2.php:41 Stack trace: #0 /home/indexxx/public_html/gamesite/wsdl/index2.php(41): SoapClient->__call('productitemsear...', Array) #1 /home/indexxx/public_html/gamesite/wsdl/index2.php(41): SoapClient->productitemsearch(Array) #2 {main} thrown in /home/indexxx/public_html/gamesite/wsdl/index2.php on line 41

  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 17:15

Creepy

Tactical Espionage Splatterer

Ealanrian schreef op woensdag 24 juli 2013 @ 08:48:
Op regel 26 staat:
PHP:
1
function productitemsearch()

een functie zonder parameters dus. op regel 37 roep je die functie aan met parameters. Dat gaat niet werken volgens mij.
Die functie is een losse methode van de door hem gedefinieerde class Product. Echter roept hij productitemsearch aan op de soapclient. Totaal 2 verschillende dingen dus.

Wat er mis gaat is dat je niet de juiste parameters meegeeft aan de productitemsearch call in de soap client. Hoe die er wel moeten uitzoen staat gedefinieerd in de WSDL, en als ik je code zo bekijk dan druk je alles al op het scherm af, dus zou je dat zelf goed moeten kunnen lezen.

Heel die eigen gedefinieerd Product class gebruik je op dit moment niet eens.

[ Voor 5% gewijzigd door Creepy op 24-07-2013 09:12 ]

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney


  • Kenny_026
  • Registratie: Juli 2007
  • Niet online
(overleden)
Dit is de output maar waar het bij mij dus fout gaat is de het aanroepen van de juiste parameters. Als ik dat eenmaal goed hebt komt de rest vanzelf maar voor nu loop ik vast...
Array ( [0] => ProductSearchResponse ProductSearch(ProductSearch $parameters) [1] => ProductItemSearchResponse ProductItemSearch(ProductItemSearch $parameters) [2] => ProductShopSearchResponse ProductShopSearch(ProductShopSearch $parameters) [3] => FilterOptionsResponse FilterOptions(FilterOptions $parameters) [4] => ProductSearchResponse ProductSearch(ProductSearch $parameters) [5] => ProductItemSearchResponse ProductItemSearch(ProductItemSearch $parameters) [6] => ProductShopSearchResponse ProductShopSearch(ProductShopSearch $parameters) [7] => FilterOptionsResponse FilterOptions(FilterOptions $parameters) )


Array ( [0] => struct ProductSearch { ProductSearchInput input; } [1] => struct ProductSearchInput { int cat_id; string link_id; string query; QueryNote querynote; int offset; int numresults; SortBy sortby; boolean shopinfo; ShopInfoSort shopinfosort; ArrayOfProductFilter filter; } [2] => string QueryNote [3] => string SortBy [4] => string ShopInfoSort [5] => struct ArrayOfProductFilter { ProductFilter ProductFilter; } [6] => struct ProductFilter { int type_id; int filter_id; string filter_options; } [7] => struct ProductSearchResponse { ProductSearchOutput ProductSearchResult; } [8] => struct ProductSearchOutput { int totalfound; int offset; int numresult; float searchtime; ArrayOfProduct products; } [9] => struct ArrayOfProduct { Product Product; } [10] => struct Product { int item_id; int cat_id; string title; string properties; int minprice; string image_url; string direct_link; ArrayOfShops shops; } [11] => struct ArrayOfShops { Shops Shops; } [12] => struct Shops { int shop_id; string shopname; string shoplogo; string levertijd; string price; int postage; string cpc_type; string producturl; } [13] => struct ProductItemSearch { ProductItemInput input; } [14] => struct ProductItemInput { string link_id; int item_id; int cat_id; boolean shopinfo; ShopInfoSort shopinfosort; boolean itemspecs; } [15] => struct ProductItemSearchResponse { ProductItemOutput ProductItemSearchResult; } [16] => struct ProductItemOutput { float searchtime; ProductData productdata; } [17] => struct ProductData { int item_id; int cat_id; string title; string properties; int minprice; string image_url; string direct_link; ArrayOfShops shops; ArrayOfSpecification specifications; } [18] => struct ArrayOfSpecification { Specification Specification; } [19] => struct Specification { int group_id; string group_name; ArrayOfItem items; } [20] => struct ArrayOfItem { Item Item; } [21] => struct Item { string title; string value; int detail_id; } [22] => struct ProductShopSearch { ProductShopSearchInput input; } [23] => struct ProductShopSearchInput { string query; string link_id; int shop_id; int cat_id; int offset; int numresults; ArrayOfProductFilter filter; } [24] => struct ProductShopSearchResponse { ProductShopSearchOutput ProductShopSearchResult; } [25] => struct ProductShopSearchOutput { int totalfound; int offset; int numresult; float searchtime; ArrayOfProductItem products; } [26] => struct ArrayOfProductItem { ProductItem ProductItem; } [27] => struct ProductItem { int item_id; int cat_id; string title; string properties; int price; int postage; string levertijd; string image_url; string direct_link; string producturl; } [28] => struct FilterOptions { int cat_id; } [29] => struct FilterOptionsResponse { ArrayOfFilterOption FilterOptionsResult; } [30] => struct ArrayOfFilterOption { FilterOption FilterOption; } [31] => struct FilterOption { int type_id; string filter_title; int filter_id; ArrayOfFilters filter_options; } [32] => struct ArrayOfFilters { Filters Filters; } [33] => struct Filters { string option_name; int option_id; int option_products; } )

  • epic007
  • Registratie: Februari 2004
  • Laatst online: 17-11 15:31
In de lijst met functies staat wel ProductItemSearch, maar je roept hem aan met productitemsearch. Misschien een geval van case sensitive?

  • Kenny_026
  • Registratie: Juli 2007
  • Niet online
(overleden)
epic007 schreef op woensdag 24 juli 2013 @ 09:34:
In de lijst met functies staat wel ProductItemSearch, maar je roept hem aan met productitemsearch. Misschien een geval van case sensitive?
Nee nog steeds die fout...

In de handleiding van de leverancier staat dit...
Gebruik productitemsearch om data op te halen voor 1 product. Roep de functie aan doormiddel van een array met daarin 1 key met de naam “input”. Deze key bevat een array met onderstaande array opties. Belangrijk: cat_id en item_id moeten minimaal mee gestuurd worden, de rest is optioneel.

  • Low-Tech
  • Registratie: December 2001
  • Laatst online: 22-11 12:17
Zoiets zoek je denk ik:
PHP:
1
2
$args = array('input' => array( 'cat_id' => 4, 'item_id' => 68899 ));
$product = $client->productitemsearch( $args );

Fractal Design Meshify S2, Asus ROG B550-F, AMD 3700x, 3080?, Corsair H115i Pro, G-Skill 3600-16 32GB Trident Z Neo


  • Kenny_026
  • Registratie: Juli 2007
  • Niet online
(overleden)
Low-Tech schreef op woensdag 24 juli 2013 @ 09:45:
Zoiets zoek je denk ik:
PHP:
1
2
$args = array('input' => array( 'cat_id' => 4, 'item_id' => 68899 ));
$product = $client->productitemsearch( $args );
Thanks, ik ben een stuk verder nu. Echter nog steeds onderstaande fout..
Catchable fatal error: Object of class stdClass could not be converted to string in /home/indexxx/public_html/gamesite/wsdl/index2.php on line 46
code ziet er als volgt uit...
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Product {
        public $cat_id;
        public $item_id;
        public $title;
        public $minprice;
        public $image_url;
        public $direct_link;
        public $shopinfosort;}
            
            
function ProductItemSearch($product)
  {
    $product = new Product();
    $product->cat_id = $cat_id;
    $product->item_id = $item_id;
    $product->title = $title;
    $product->minprice = $minprice;
    $product->shopinfosort = $shopinfosort;
    
    return $product;
  }     

$args = array('input' => array( 'cat_id' => 4, 'item_id' => 68899, 'shopinfosort'=> "PRICE" ));
$product = $client->productitemsearch( $args );   

echo ($product);


Nu zal het er mee te maken hebben dat ik dat shopinfosort niet goed in een variabele zet.

[ Voor 3% gewijzigd door Kenny_026 op 24-07-2013 12:09 ]


  • Kenny_026
  • Registratie: Juli 2007
  • Niet online
(overleden)
Ik heb het voor elkaar met onderstaande code
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Product {
        public $cat_id;
        public $item_id;
        public $title;
        public $minprice;
        public $image_url;
        public $direct_link;
        public $shopinfosort;}


function ProductItemSearch($product)
  {
    $product = new Product();
    $product->cat_id = $cat_id;
    $product->item_id = $item_id;
    $product->title = $title;
    $product->minprice = $minprice;
    $shopinfosort= new StdClass;
    
    return $product;
  }     


$args = array('input' => array( 'cat_id' => 4, 'item_id' => 68699, 'shopinfosort'=> "PRICE" ));
$product = $client->ProductItemSearch( $args );   

print_r ($product);


Thanks allemaal!

  • Kenny_026
  • Registratie: Juli 2007
  • Niet online
(overleden)
Ik loop toch nog tegen een uitdaging aan...

Het resultaat word nu allemaal netjes weergegeven.
stdClass Object ( [ProductItemSearchResult] => stdClass Object ( [searchtime] => 0.00406813621521 [productdata] => stdClass Object ( [item_id] => 71267 [cat_id] => 4 [title] => Last of Us - PlayStation 3 [properties] => Game ▪ PlayStation 3 ▪ PEGI: 18 ▪ 2013 [minprice] => 4999 [image_url] => http://hwimages2.beslist....RGE/000/000/071/71267.png [direct_link] => http://www.beslist.nl/cdd...f_Us_-_PlayStation_3.html ) ) )
Mijn code is nu dit... Bleek een boel bullshit in te staan...

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php 

//require_once('SoapClientAuth.php');
date_default_timezone_set('Europe/Amsterdam');
ini_set("soap.wsdl_cache_enabled", "0");

#- verbinden met WSDL 

$client = new SoapClient("http://www.site.nl/api/v2/wsdl/products.wsdl", 
        array('login'=> "",
              'password'=> ""));
            

$productitemsearch_args = array('input' => array( 'cat_id' => 4, 'item_id' => 71267 , 'shopinfosort'=> "PRICE" ));
$productitemsearch= $client->ProductItemSearch( $productitemsearch_args );   

print_r ($productitemsearch);

?>


[productdata] bestaat dus uit een aantal arrayvelden, en daarin staat shops welke ook weer uit arrayvelden bestaat. Ik krijg dit nu uitgelezen.

Ik heb het voor elkaar door een extra waarde toe te voegen.

[ Voor 39% gewijzigd door Kenny_026 op 24-07-2013 16:25 ]

Pagina: 1