Closed jcranky closed 12 years ago
Thanks, I'll take a look at this later.
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
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:
<?xml version="1.0" encoding="utf-8"?>
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/
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())))
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: https://github.com/eed3si9n/scalaxb/issues/149#issuecomment-4678112
Paulo "JCranky" Siqueira Visit my blog: http://www.jcranky.com/
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
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.
I guessed so... thanks =)
I'll have to live with this "ugliness" - and it ended up not being that much ugly after all XD
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