passing an array of complex types from php web service to c#
Posted: Mon Apr 23, 2007 12:18 pm
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:
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.
Code: Select all
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 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.