dninja Posted April 23, 2007 Share Posted April 23, 2007 I have a php web service with a complex type defined. I can pass a single element of this type from server to client and I can also pass an array of this type in but I can't pass an array back out again. A snippit of the code is: function ArrayTester() { $this->__dispatch_map['singleInSingleOut'] = array( "in" => array ("inp" => "{urn:ArrayTest}Test"), "out" => array ("outp" => "{urn:ArrayTest}Test") ); $this->__dispatch_map['arrayInSingleOut'] = array( "in" => array ("inp" => "{urn:ArrayTest}ArrayOfTests"), "out" => array ("outp" => "{urn:ArrayTest}Test") ); $this->__dispatch_map['singleInArrayOut'] = array( "in" => array ("inp" => "{urn:ArrayTest}Test"), "out" => array ("outp" => "{urn:ArrayTest}Test") ); $this->__dispatch_map['arrayInArrayOut'] = array( "in" => array ("inp" => "{urn:ArrayTest}ArrayOfTests"), "out" => array ("outp" => "{urn:ArrayTest}ArrayOfTests") ); $this->__typedef['ArrayOfTests'] = array(array('item'=>'{urn:ArrayTest}Test')); $this->__typedef['Test'] = array( "item" => 'string', "item2" => "string", "number" => "int", ); function arrayInArrayOut($inp) { $p = new Test(); $p->set_item ("item1"); $o = new Test(); $o->set_item ("item2"); $out = array ($o, $p); $h = fopen ("/tmp/web.log", "a+"); fwrite ($h, print_r ($inp, true)); fwrite ($h, print_r ($out, true)); fclose ($h); return (array()); } function singleInArrayOut ($inp) { $p = new Test(); $p->set_item ("item1"); $o = new Test(); $o->set_item ("item2"); $out = array ($o, $p); $h = fopen ("/tmp/web.log", "a+"); fwrite ($h, print_r ($inp, true)); fwrite ($h, print_r ($out, true)); fclose ($h); return $out; } function singleInSingleOut ($inp) { $out = new Test(); $out->set_item ("item1"); $h = fopen ("/tmp/web.log", "a+"); fwrite ($h, print_r ($inp, true)); fwrite ($h, print_r ($out, true)); fclose ($h); return $out; } function arrayInSingleOut ($inp) { $out = new Test(); $out->set_item ("item1"); $h = fopen ("/tmp/web.log", "a+"); fwrite ($h, print_r ($inp, true)); fwrite ($h, print_r ($out, true)); fclose ($h); return $out; } The ...SingleOut functions work ok but the ...ArrayOut functions fail. Visual studio puts an <undefined value> into the variable. The namespaces seem to be ok or c# would completely fail. Checking the log shows that everything seems to be of the right types. On the arrayInArrayOut function, I've tried returning the input as the output (i.e. no alterations) and that failed. I've see some things define sequences rather than arrays, as long as I get multiple of these types out I don't care how I do it. Can anyone help or point me at some example code that does this? There are loads of simple type examples but very few complex type ones. Link to comment https://forums.phpfreaks.com/topic/48311-passing-an-array-of-complex-types-from-php-web-service-to-c-client/ Share on other sites More sharing options...
per1os Posted April 23, 2007 Share Posted April 23, 2007 I am not sure if C# and PHP's serialize functions are similar or not. I would try to serialize the array than pass it back and forth to maintain structure www.php.net/serialize www.php.net/unserialize Link to comment https://forums.phpfreaks.com/topic/48311-passing-an-array-of-complex-types-from-php-web-service-to-c-client/#findComment-236183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.