mixed field with wrong extra elements?

21 views
Skip to first unread message

Paulo "JCranky" Siqueira

unread,
Mar 26, 2012, 9:26:42 PM3/26/12
to sca...@googlegroups.com
Hi,

For a unit test in the system here, I'm using this sample body, simulating a soap response:

val sampleBody =
      <nfeStatusServicoNF2Result xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
        <retConsStatServ versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe">
          <tpAmb>2</tpAmb>
          <verAplic>SP_NFE_PL_006j</verAplic>
          <cStat>252</cStat>
          <xMotivo>Rejeição: Ambiente informado diverge do Ambiente de recebimento</xMotivo>
          <cUF>35</cUF>
          <dhRecbto>2012-03-26T17:19:13</dhRecbto>
        </retConsStatServ>
      </nfeStatusServicoNF2Result>

I mocked the SoapClient, and when soapClient.requestResponse is called, I simply return the body like above. But something seems to be going wrong when calling the service. When I do:

val result = statusServicoBindings.service.nfeStatusServicoNF2(dados, cabec)
val s = result.right.get.value.mixed.size

If I print the size when executing the system against the real service, the size is one, which is what I expect. When calling using the mocked body, the size is 3. The 2 extra elements are line breaks only. Now, if I declare the sampleBody in a single line, it works, with size 1.

How can I declare the test body without having to have to write it in a single line?

thanks!

[]s,

--
Paulo "JCranky" Siqueira
Visit my blog: http://www.jcranky.com/

eugene yokota

unread,
Mar 26, 2012, 10:02:14 PM3/26/12
to sca...@googlegroups.com
Hi,

On Mon, Mar 26, 2012 at 9:26 PM, Paulo "JCranky" Siqueira
<paulo.s...@gmail.com> wrote:
> How can I declare the test body without having to have to write it in a
> single line?

NfeStatusServicoNF2Result is a mixed, so it recognizes plain text and
XML elements.
All you have to do is avoid end line at the top level:


val sampleBody =
<nfeStatusServicoNF2Result
xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><retConsStatServ
versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe">
<tpAmb>2</tpAmb>
<verAplic>SP_NFE_PL_006j</verAplic>
<cStat>252</cStat>
<xMotivo>Rejeição: Ambiente informado diverge do Ambiente de
recebimento</xMotivo>
<cUF>35</cUF>
<dhRecbto>2012-03-26T17:19:13</dhRecbto>
</retConsStatServ></nfeStatusServicoNF2Result>

-eugene

Paulo "JCranky" Siqueira

unread,
Mar 26, 2012, 10:59:44 PM3/26/12
to sca...@googlegroups.com

Oh I see, the problem is that the line break inside de result tag is found before the ret tag then... And the same is valid for the closing tag. Makes sense :-)

Thanks!!

[]s,

Paulo "JCranky" Siqueira
http://jcranky.com

Reply all
Reply to author
Forward
0 new messages