PHP SOAP Request is missing XML Nodes



i need some help with a SOAP request. I need to send a XML through a SOAP WebService. It's working kind of ok. BUT!!! It's a shopping cart, when it only has one produt, it works like a charm, but when there's more than one. The SOAP request ignores the all the other and only send one. Here is the XML i'm trying to send.



<?xml version="1.0" encoding="utf-8"?>
<WSFAT1PP>
<PREPV>
<CNPJ>1</CNPJ>
<CODORC>0000000025</CODORC>
<ITEM>
<FORMITEM>
<CODPROIT>235060</CODPROIT>
<QUANT>1</QUANT>
</FORMITEM>
<FORMITEM>
<CODPROIT>339746</CODPROIT>
<QUANT>1</QUANT>
</FORMITEM>
</ITEM>
<OBS></OBS>
</PREPV>
</WSFAT1PP>


And here is what's actually being sent:



<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:ns1="http://xxx.xxx.xxx.xxx:xxxx/">
<SOAP-ENV:Body>
<ns1:WSFAT1PP>
<ns1:PREPV>
<ns1:CNPJ>1</ns1:CNPJ>
<ns1:CODORC>0000000025</ns1:CODORC>
<ns1:ITEM>
<ns1:FORMITEM>
<ns1:CODPROIT>235060</ns1:CODPROIT>
<ns1:QUANT>1</ns1:QUANT>
</ns1:FORMITEM>
</ns1:ITEM>
<ns1:OBS></ns1:OBS>
</ns1:PREPV>
</ns1:WSFAT1PP>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The second produt is gone, and I have no idea why.


The code is the following



$xml = new SimpleXmlElement($xml);
$client = new SoapClient($url, array('trace' => 1));
try{
$result = $client->WSFAT1PP($xml->asXML());
...

No comments:

Post a Comment