Pessoal,
Tenho que fazer dois parsers, uma para requisição,
onde tenho que gerar um XML a partir de uma classe,
e outro de resposta, onde vou popular uma classe a partir de um XML.
XML para requisição
<?xml version="1.0" ?>
<?qbxml version="5.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerQueryRq requestID="0">
<ListID>8000000F-1203696248</ListID>
<OwnerID>0</OwnerID>
</CustomerQueryRq>
</QBXMLMsgsRq>
</QBXML>
Classe que representará o XML de requisição
public class CustomerQueryRq {
private String ListID;
private bit OwnerID;
//getters e setters
}
Resposta da requisição
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<CustomerQueryRs requestID="0" statusCode="0"
statusSeverity="Info" statusMessage="Status OK">
<CustomerRet>
<ListID>8000000F-1203696248</ListID>
<TimeCreated>2008-02-22T13:04:08-03:00</TimeCreated>
<TimeModified>2008-04-01T08:41:15-03:00</TimeModified>
<EditSequence>1207050075</EditSequence>
<Name>xxxxxxxxxxxSUL</Name>
<FullName>xxxxxxxxxxxxxxxxSUL</FullName>
<IsActive>true</IsActive>
<Sublevel>0</Sublevel>
<CompanyName>
xxxxxxxxxxxxxxxxxx
</CompanyName>
<BillAddress>
<Addr1>
xxxxxxxxxxxxxxxxxxxxxxx
SE
</Addr1>
<Addr2>xxxxxxxxxxxxxx</Addr2>
<Addr3>xxxxxxxxxxxxxxx</Addr3>
<City>SÃO PAULO</City>
<PostalCode>xxxxxxxxxxx-105</PostalCode>
</BillAddress>
<ShipAddress>
<Addr1>
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
SE
</Addr1>
<Addr2>Rxxxxxxxxxxxxxxxx</Addr2>
<Addr3>CAMPININHA</Addr3>
<City>SÃO PAULO</City>
<PostalCode>0xxxxxxxxxxxxxx105</PostalCode>
</ShipAddress>
<Phone>(11) 56xxxxxxxxxxxxxx000</Phone>
<Fax>(11) 56xxxxxxxxxxxxxxx</Fax>
<Email>teste@teste.com</Email>
<CustomerTypeRef>
<ListID>80000007-1203696245</ListID>
<FullName>Concessionária</FullName>
</CustomerTypeRef>
<TermsRef>
<ListID>80000009-1203696248</ListID>
<FullName>30 DD</FullName>
</TermsRef>
<Balance>213222222222277.82</Balance>
<TotalBalance>2222222222222221377.82</TotalBalance>
<SalesTaxCodeRef>
<ListID>80000002-1203696071</ListID>
<FullName>Non</FullName>
</SalesTaxCodeRef>
<JobStatus>None</JobStatus>
<DataExtRet>
<OwnerID>0</OwnerID>
<DataExtName>UF / ICMS</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>SP/18%</DataExtValue>
</DataExtRet>
<DataExtRet>
<OwnerID>0</OwnerID>
<DataExtName>CNPJ/CPF</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>022222222222222/0001-80</DataExtValue>
</DataExtRet>
<DataExtRet>
<OwnerID>0</OwnerID>
<DataExtName>IE/RG</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>2222222222222222</DataExtValue>
</DataExtRet>
<DataExtRet>
<OwnerID>0</OwnerID>
<DataExtName>Marca</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>GM</DataExtValue>
</DataExtRet>
<DataExtRet>
<OwnerID>0</OwnerID>
<DataExtName>CFOP</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>5102</DataExtValue>
</DataExtRet>
<DataExtRet>
<OwnerID>0</OwnerID>
<DataExtName>Código</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>F77001</DataExtValue>
</DataExtRet>
</CustomerRet>
</CustomerQueryRs>
</QBXMLMsgsRs>
</QBXML>
Classe que representará o XML de resposta
public class CustomerQueryRs{
//getters e setters
}
Qual é a melhor forma de fazer isso?
Pesquisei o framework http://xmlbeans.apache.org/,
e acredito que eu não consiga criar XMLs exatamente iguais aos que eu preciso,
com as tags QBXML e etc.
Pesquisei também um framwork http://qare.sourceforge.net/web/2001-12/products/quick/index.html,
que me pareceu interessante, mas achei fraca a documentação.
Existe algo fácil para isso? O que vocês sugerem?
Grato,
Pablo