wsdl with mixed complex type generates incorrect code #149

Closed
jcranky opened this Issue Mar 23, 2012 · 8 comments

Comments

Projects
None yet
2 participants
@jcranky

jcranky commented Mar 23, 2012

steps

When processing NfeStatusServico2.wsdl, which can be found in this zip file: https://www.fazenda.sp.gov.br/nfe/url_webservices/WSDL_26_02_10.zip, the generated code doesn't compile.

This is the exact command line I'm trying:

scalaxb -d status -p gen.nfe.statusservico --package-dir NfeStatusServico2.wsdl

problem

[ERROR] /home/jcranky/projects/doit-​projects/easy-nfe/easy-nfe-​server/src/main/java/gen/nfe/​statusservico/xmlprotocol.​scala:112: error: value any is not a member of gen.nfe.statusservico.​NfeStatusServicoNF2Result
[INFO]             Right(gen.nfe.statusservico.​NfeStatusServicoNF2Output(​scalaxb.fromXML[gen.nfe.​statusservico.​NfeStatusServicoNF2Result](​body.headOption getOrElse {body}).any,
@eed3si9n

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Mar 23, 2012

Owner

Thanks, I'll take a look at this later.

Owner

eed3si9n commented Mar 23, 2012

Thanks, I'll take a look at this later.

@eed3si9n eed3si9n closed this in bc318a5 Mar 24, 2012

@eed3si9n

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Mar 24, 2012

Owner

A new version of 0.6.9-SNAPSHOT is published with the fix. Run the following to clear the boot dir, and the new scalaxb should be downloaded automatically:

$ cs --clean-boot

I created a sample project for testing: https://github.com/eed3si9n/scalaxb-sample/tree/nfe/nfe

Owner

eed3si9n commented Mar 24, 2012

A new version of 0.6.9-SNAPSHOT is published with the fix. Run the following to clear the boot dir, and the new scalaxb should be downloaded automatically:

$ cs --clean-boot

I created a sample project for testing: https://github.com/eed3si9n/scalaxb-sample/tree/nfe/nfe

@jcranky

This comment has been minimized.

Show comment
Hide comment
@jcranky

jcranky Mar 24, 2012

Hi Eugene,

Thank you! And sorry to bother you so much with this stuff. I still feel a
bit noob when it comes to xml in scala.

Now the project compiles completely. But it isn't working as expected yet.
This might be my fault, but I'm not sure. This is the error I'm getting
when the response is received:

java.util.NoSuchElementException: next on empty iterator
at scala.collection.Iterator$$anon$3.next(Iterator.scala:28)
at scala.collection.Iterator$$anon$3.next(Iterator.scala:26)
at scala.collection.LinearSeqLike$$anon$1.next(LinearSeqLike.scala:56)
at scala.collection.IterableLike$class.head(IterableLike.scala:90)
at scala.xml.NodeSeq.head(NodeSeq.scala:43)
at gen.nfe.statusservico.XMLProtocol$NfeStatusServico2Soap12Bindings$NfeStatusServico2Soap12Binding$class.nfeStatusServicoNF2(xmlprotocol.scala:113)
at gen.nfe.statusservico.XMLProtocol$NfeStatusServico2Soap12Bindings$$anon$4.nfeStatusServicoNF2(xmlprotocol.scala:103)

And this is the response that should be parsed:

http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema">soap:Header352.00/soap:Headersoap:Body2SP_NFE_PL_006j252Rejeio:
Ambiente informado diverge do Ambiente de
recebimento352012-03-24T17:05:03/soap:Body/soap:Envelope

The line mentioned in the stack trace:

Right(gen.nfe.statusservico.NfeStatusServicoNF2Output(scalaxb.fromXML[gen.nfe.statusservico.NfeStatusServicoNF2Result](body.headOption
getOrElse {body}),
scalaxb.fromXMLgen.nfe.statusservico.NfeCabecMsg.head)))

Looks like it isn't finding the header? Namespace problems perhaps?

thanks again!

[]s,

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

jcranky commented Mar 24, 2012

Hi Eugene,

Thank you! And sorry to bother you so much with this stuff. I still feel a
bit noob when it comes to xml in scala.

Now the project compiles completely. But it isn't working as expected yet.
This might be my fault, but I'm not sure. This is the error I'm getting
when the response is received:

java.util.NoSuchElementException: next on empty iterator
at scala.collection.Iterator$$anon$3.next(Iterator.scala:28)
at scala.collection.Iterator$$anon$3.next(Iterator.scala:26)
at scala.collection.LinearSeqLike$$anon$1.next(LinearSeqLike.scala:56)
at scala.collection.IterableLike$class.head(IterableLike.scala:90)
at scala.xml.NodeSeq.head(NodeSeq.scala:43)
at gen.nfe.statusservico.XMLProtocol$NfeStatusServico2Soap12Bindings$NfeStatusServico2Soap12Binding$class.nfeStatusServicoNF2(xmlprotocol.scala:113)
at gen.nfe.statusservico.XMLProtocol$NfeStatusServico2Soap12Bindings$$anon$4.nfeStatusServicoNF2(xmlprotocol.scala:103)

And this is the response that should be parsed:

http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema">soap:Header352.00/soap:Headersoap:Body2SP_NFE_PL_006j252Rejeio:
Ambiente informado diverge do Ambiente de
recebimento352012-03-24T17:05:03/soap:Body/soap:Envelope

The line mentioned in the stack trace:

Right(gen.nfe.statusservico.NfeStatusServicoNF2Output(scalaxb.fromXML[gen.nfe.statusservico.NfeStatusServicoNF2Result](body.headOption
getOrElse {body}),
scalaxb.fromXMLgen.nfe.statusservico.NfeCabecMsg.head)))

Looks like it isn't finding the header? Namespace problems perhaps?

thanks again!

[]s,

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

@eed3si9n

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Mar 25, 2012

Owner

It's not you, it's scalaxb. There was a bug in header parsing, which I filed as #150 and fixed it now.
Run $ cs --clean-boot and you'll get a new snapshot.

I also updated https://github.com/eed3si9n/scalaxb-sample/tree/nfe/nfe using your sample response, which now outputs the following:

Right(NfeStatusServicoNF2Output(NfeStatusServicoNF2Result(List(DataRecord(
          ), DataRecord({http://www.portalfiscal.inf.br/nfe}retConsStatServ,<retConsStatServ versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
            <tpAmb>2</tpAmb>
            <verAplic>SP_NFE_PL_006j</verAplic>
            <cStat>252</cStat>
            <xMotivo>Rejeio: Ambiente informado diverge do Ambiente de recebimento</xMotivo>
            <cUF>35</cUF>
            <dhRecbto>2012-03-24T17:05:03</dhRecbto>
          </retConsStatServ>), DataRecord(
        ))),NfeCabecMsg(Some(35),Some(2.00),Map())))
Owner

eed3si9n commented Mar 25, 2012

It's not you, it's scalaxb. There was a bug in header parsing, which I filed as #150 and fixed it now.
Run $ cs --clean-boot and you'll get a new snapshot.

I also updated https://github.com/eed3si9n/scalaxb-sample/tree/nfe/nfe using your sample response, which now outputs the following:

Right(NfeStatusServicoNF2Output(NfeStatusServicoNF2Result(List(DataRecord(
          ), DataRecord({http://www.portalfiscal.inf.br/nfe}retConsStatServ,<retConsStatServ versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
            <tpAmb>2</tpAmb>
            <verAplic>SP_NFE_PL_006j</verAplic>
            <cStat>252</cStat>
            <xMotivo>Rejeio: Ambiente informado diverge do Ambiente de recebimento</xMotivo>
            <cUF>35</cUF>
            <dhRecbto>2012-03-24T17:05:03</dhRecbto>
          </retConsStatServ>), DataRecord(
        ))),NfeCabecMsg(Some(35),Some(2.00),Map())))
@jcranky

This comment has been minimized.

Show comment
Hide comment
@jcranky

jcranky Mar 25, 2012

thank you!

everything seems ok now, which leaves me with my own bugs XD

thank you again!

[]s,

2012/3/24 eugene yokota <
reply@reply.github.com

It's not you, it's scalaxb. There was a bug in header parsing, which I
filed as #150 and fixed it now.
Run $ cs --clean-boot and you'll get a new snapshot.

I also updated https://github.com/eed3si9n/scalaxb-sample/tree/nfe/nfeusing your sample response, which now outputs the following:

Right(NfeStatusServicoNF2Output(NfeStatusServicoNF2Result(List(DataRecord(
         ), DataRecord({
http://www.portalfiscal.inf.br/nfe}retConsStatServ,<retConsStatServ
versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns="
http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:soap="
http://www.w3.org/2003/05/soap-envelope">
            <tpAmb>2</tpAmb>
           <verAplic>SP_NFE_PL_006j</verAplic>
           <cStat>252</cStat>
            <xMotivo>Rejeio: Ambiente informado diverge do Ambiente de
recebimento</xMotivo>
            <cUF>35</cUF>
           <dhRecbto>2012-03-24T17:05:03</dhRecbto>
          </retConsStatServ>), DataRecord(
       ))),NfeCabecMsg(Some(35),Some(2.00),Map())))

Reply to this email directly or view it on GitHub:
#149 (comment)

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

jcranky commented Mar 25, 2012

thank you!

everything seems ok now, which leaves me with my own bugs XD

thank you again!

[]s,

2012/3/24 eugene yokota <
reply@reply.github.com

It's not you, it's scalaxb. There was a bug in header parsing, which I
filed as #150 and fixed it now.
Run $ cs --clean-boot and you'll get a new snapshot.

I also updated https://github.com/eed3si9n/scalaxb-sample/tree/nfe/nfeusing your sample response, which now outputs the following:

Right(NfeStatusServicoNF2Output(NfeStatusServicoNF2Result(List(DataRecord(
         ), DataRecord({
http://www.portalfiscal.inf.br/nfe}retConsStatServ,<retConsStatServ
versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns="
http://www.portalfiscal.inf.br/nfe/wsdl/NfeStatusServico2" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:soap="
http://www.w3.org/2003/05/soap-envelope">
            <tpAmb>2</tpAmb>
           <verAplic>SP_NFE_PL_006j</verAplic>
           <cStat>252</cStat>
            <xMotivo>Rejeio: Ambiente informado diverge do Ambiente de
recebimento</xMotivo>
            <cUF>35</cUF>
           <dhRecbto>2012-03-24T17:05:03</dhRecbto>
          </retConsStatServ>), DataRecord(
       ))),NfeCabecMsg(Some(35),Some(2.00),Map())))

Reply to this email directly or view it on GitHub:
#149 (comment)

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

@jcranky

This comment has been minimized.

Show comment
Hide comment
@jcranky

jcranky Mar 26, 2012

What is the proper way of reading the retConsStatServ in the DataRecord? Casting it for NodeSeq? Although casting feel a bit awkward...

EDIT: I mean casting the "mixed" value or something like that. Already tested here and seems to work. It just doesn't feel right XD

jcranky commented Mar 26, 2012

What is the proper way of reading the retConsStatServ in the DataRecord? Casting it for NodeSeq? Although casting feel a bit awkward...

EDIT: I mean casting the "mixed" value or something like that. Already tested here and seems to work. It just doesn't feel right XD

@eed3si9n

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Mar 26, 2012

Owner

That's what you have to do because nfeStatusServicoNF2Result doesn't have any data binding:

  <s:element name="nfeStatusServicoNF2Result">
    <s:complexType mixed="true">
      <s:sequence>
        <s:any />
      </s:sequence>
    </s:complexType>
  </s:element>

xs:any is a wildcard just allows anything in there.

Owner

eed3si9n commented Mar 26, 2012

That's what you have to do because nfeStatusServicoNF2Result doesn't have any data binding:

  <s:element name="nfeStatusServicoNF2Result">
    <s:complexType mixed="true">
      <s:sequence>
        <s:any />
      </s:sequence>
    </s:complexType>
  </s:element>

xs:any is a wildcard just allows anything in there.

@jcranky

This comment has been minimized.

Show comment
Hide comment
@jcranky

jcranky Mar 26, 2012

I guessed so... thanks =)

I'll have to live with this "ugliness" - and it ended up not being that much ugly after all XD

jcranky commented Mar 26, 2012

I guessed so... thanks =)

I'll have to live with this "ugliness" - and it ended up not being that much ugly after all XD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment