Jump to content

passing an array of complex types from php web service to c# client


dninja

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.