Send data type array in Webservice made in NuSOAP

1

Talk galley, blaze?

I'm developing a webservice php in soap, I'm using the nuSOAP library, the simple type tests were successful but now I need to test with complex types like bad arrays I can not make work, the error in the transmission, already includes a command for

Error description generated:

SOAP-ENV:Client: error in msg parsing:
XML error parsing SOAP payload on line 1: Space required

The structure I send and I need to receive is this:

array (size=1)
  'itens' => 
    array (size=3)
      'suco' => 
        array (size=2)
          0 => int 1
          1 => string '1.90' (length=4)
      'coca cola' => 
        array (size=2)
          0 => int 1
          1 => string '4.99' (length=4)
      'miojo' => 
        array (size=2)
          0 => int 5
          1 => string '3.99' (length=4)

In the server.php file include this command to enable complex type:

$servidor->wsdl->addComplexType(
    'onItens',
    'complexType',
    'struct',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
        'itens' => 'SOAP-ENC:arrayType',
        'wsdl:arrayType' => 'xsd:string[]'
    )
);

$servidor->register(
    'WS.onLancamentos',
    array('itens'=>'tns:onItens'),
    array('retorno'=>'xsd:string'),
    $namespace,
    $namespace.'#lancamentos',
    'rpc',
    'encoded',
    'Lancamento dos itens comprados na PEGGOU'
);  

Obs : When the main array 'items' gets only one element, then the number of items is undefined, so I need to configure it to work with more elements.

    
asked by anonymous 01.07.2016 / 16:59

1 answer

1

EUREKA! Problem solved.

After many tests and debugging I discovered the reason for the problem.

The problem was simply one of the array elements.

The 'coca cola' key was making all this mistake, the space between the words was what caused the error.

The solution was simply to replace the space with an underline.

Thankfully this problem happened now because it happens in production and it would be tense. Phew!

It's the registration if someone has a problem similar to the one I had.

    
01.07.2016 / 21:55