Webservice - XML com tags repetidas no SOAP com PHP

Enviada por Ederson G. da Silva 
Ederson G. da Silva
Webservice - XML com tags repetidas no SOAP com PHP
12 de September de 2013 às 01:26PM
Olá.

Estou realizando a integração de nosso sistema via webservice com um fornecedor nosso, estou utilizando PHP com SOAP.

Conforme regras de cadastro deste fornecedor, ele me exige 3 referencias pessoais, o problema é que tenho que gerar 3 arrays com o mesmo nome de chave dentro de outro array, deveria ficar desta forma:

[Referencias] => Array
(
[sgrRefPessoais] => Array
(
[cdRefPes] => 1
[strNome] => fulano
[numTpRelacionamento] => 1
[numEndCidade] => 4264
[strEndRua] =>
[strEndNumero] =>
[strEndComplemento] =>
[strEndBairro] =>
[strEndCEP] =>
[strFone1] => 34047000
[strFone2] =>
)

[sgrRefPessoais] => Array
(
[cdRefPes] => 2
[strNome] => ciclano
[numTpRelacionamento] => 9
[numEndCidade] => 4264
[strEndRua] =>
[strEndNumero] =>
[strEndComplemento] =>
[strEndBairro] =>
[strEndCEP] =>
[strFone1] => 33681813
[strFone2] =>
)

[sgrRefPessoais] => Array
(
[cdRefPes] => 3
[strNome] => beltrano
[numTpRelacionamento] => 11
[numEndCidade] => 4264
[strEndRua] =>
[strEndNumero] =>
[strEndComplemento] =>
[strEndBairro] =>
[strEndCEP] =>
[strFone1] => 88126076
[strFone2] =>
)

)

Estou escrevo isto no PHP da seguinte forma:

'Referencias' => array(
'sgrRefPessoais' => array(
'cdRefPes' => 1,
'strNome' => $this->strNome,
'numTpRelacionamento' => $this->numTpRelacionamento,
'numEndCidade' => $this->refnumEndCidade,
'strEndRua' => $this->refstrEndRua,
'strEndNumero' => $this->refstrEndNumero,
'strEndComplemento' => $this->refstrEndComplemento,
'strEndBairro' => $this->refstrEndBairro,
'strEndCEP' => $this->refstrEndCEP,
'strFone1' => $this->refstrFone1,
'strFone2' => $this->refstrFone2
),
'sgrRefPessoais'=> array(
'cdRefPes' => 2,
'strNome' => $this->strNome2,
'numTpRelacionamento' => $this->numTpRelacionamento2,
'numEndCidade' => $this->refnumEndCidade2,
'strEndRua' => $this->refstrEndRua2,
'strEndNumero' => $this->refstrEndNumero2,
'strEndComplemento' => $this->refstrEndComplemento2,
'strEndBairro' => $this->refstrEndBairro2,
'strEndCEP' => $this->refstrEndCEP2,
'strFone1' => $this->refstrFone12,
'strFone2' => $this->refstrFone22
),
'sgrRefPessoais' => array(
'cdRefPes' => 3,
'strNome' => $this->strNome3,
'numTpRelacionamento' => $this->numTpRelacionamento3,
'numEndCidade' => $this->refnumEndCidade3,
'strEndRua' => $this->refstrEndRua3,
'strEndNumero' => $this->refstrEndNumero3,
'strEndComplemento' => $this->refstrEndComplemento3,
'strEndBairro' => $this->refstrEndBairro3,
'strEndCEP' => $this->refstrEndCEP3,
'strFone1' => $this->refstrFone13,
'strFone2' => $this->refstrFone23
)
)
Quando realizo o envio, o php mostra somente o último trecho, onde tem o 'cdRefPes' => 3, creio que seja porque as chaves têm o mesmo nome.

Alguém conhece alguma solução para este tipo de caso?

Obrigado!
Você precisa estar logado no PHPBrasil.com para poder enviar mensagens para os nossos fóruns.

Faça o login aqui.