Histórico da Página
TUTORIAL: USING POSTMAN TO TEST XML WEB SERVICES
1 - Após iniciar o postman, click em add request e edite a opção GET para POST.
2 - Defina a URL para requisição, por exemplo nas integrações EAI Mensagem Unica é utilizado a URL http://localhost:81/EAISERVICE.apw.
Alterar a porta conforme configuração realizada na tag [HTTPREST] Port=8996 do appserver.ini
2.1 Definição na aba Header de duas Keys SoapAction e Content-Type.
SOAPAction: "http://www.totvs.com/RECEIVEMESSAGE" Content-Type: text/xml
2 - Definição do XML a ser enviado:
O XML é Definido com:
- Envelope Soap que é sempre o mesmo na cor Violeta.
- CData que define o inicio e fim do XML na cor Verde.
- XML de Mensagem Unica na cor Azul.
XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tot="http://www.totvs.com/">
<soapenv:Header/>
<soapenv:Body>
<tot:RECEIVEMESSAGE>
<tot:INMSG><![CDATA[<?xml version="1.0" encoding="UTF-8"?><TOTVSMessage><MessageInformation version="1.000"><UUID>2e9320b3-d01e-4e45-9d99-bc052b9ae723</UUID><Type>BusinessMessage</Type><Transaction>WHOIS</Transaction> <StandardVersion>1.000</StandardVersion><SourceApplication>RM</SourceApplication><CompanyId>1</CompanyId><BranchId>1</BranchId><Product name="RM" version="12.1.25.0" /><GeneratedOn>2019-08-16T14:35:01</GeneratedOn> <DeliveryType>Sync</DeliveryType></MessageInformation><BusinessMessage><BusinessEvent><Entity>WHOIS</Entity><Event>upsert</Event></BusinessEvent><EnabledTransactions /></BusinessMessage></TOTVSMessage>]]></tot:INMSG>
</tot:RECEIVEMESSAGE>
</soapenv:Body>
</soapenv:Envelope>
EXEMPLOS:
- XML Exemplo de Envio de Projeto ao Protheus
Bloco de código | ||||||
---|---|---|---|---|---|---|
| ||||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tot="http://www.totvs.com/"> <soapenv:Header/> <soapenv:Body> <tot:RECEIVEMESSAGE> <tot:INMSG><![CDATA[<TOTVSMessage> <MessageInformation version="2.000"> <UUID>0e990017-d32e-439d-baf5-ec8cd4553f7e</UUID> <Type>BusinessMessage</Type> <Transaction>PROJECT</Transaction> <StandardVersion>1.000</StandardVersion> <SourceApplication>RM</SourceApplication> <CompanyId>1</CompanyId> <BranchId>1</BranchId> <Product name="RM" version="12.1.24.0" /> <GeneratedOn>2019-08-16T17:37:15</GeneratedOn> <DeliveryType>Sync</DeliveryType> </MessageInformation> <BusinessMessage> <BusinessEvent> <Entity>PROJECT</Entity> <Event>Upsert</Event> </BusinessEvent> <BusinessContent> <CompanyId>1</CompanyId> <BranchId>1</BranchId> <CompanyInternalId>1|1</CompanyInternalId> <ShortCode>69</ShortCode> <Code>160820</Code> <InternalId>311D73CF-3B34-4ED6-A811-E07F7920A431</InternalId> <Description>Teste</Description> <RegisterDate p2:nil="true" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" /> <BeginDate p2:nil="true" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" /> <FinalDate p2:nil="true" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" /> <StatusProject p2:nil="true" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" /> <WorkId p2:nil="true" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" /> </BusinessContent> </BusinessMessage> </TOTVSMessage>]]></tot:INMSG> </tot:RECEIVEMESSAGE> </soapenv:Body> </soapenv:Envelope> |
- Exemplo Requisição JSON:
Bloco de código | ||||||
---|---|---|---|---|---|---|
| ||||||
{
data: {
tasks: [
{
taskCostAssignments: [
{
itemNumber: "0001",
unitPrice: 10,
recno: 670,
itemInternalid: "T1||PRD44",
documentType: "NFE",
deductionValue: 0,
currencyInternalId: "T1|D MG 01|01",
increase: 0,
documentNumber: "000000000",
unitOfMeasureInternalid: "T1||XX",
customerVendorInternalId: "T1|D MG 01|999999|01|F",
companyInternalid: "T1|D MG 01",
decrease: 0,
totalPrice: 10,
apportionmentDate: "2019-04-11",
quantity: 1,
retentionValue: 0
}
],
taskInternalId: "T1|D MG 01|PRJ01|0001|001.01.01"
}
],
accountingClosingDate: "1800-01-01"
},
hasNext: false,
total: 1
} |
Criando Testes para validar XML:
Bloco de código | ||
---|---|---|
| ||
pm.test("Valida Status Retorno", function () {
pm.expect(pm.response.code).to.be.oneOf([200]);
});
pm.test("Valida Conteúdo do Body - De/Para", function () {
pm.expect(pm.response.text()).to.include("311D73CF-3B34-4ED6-A811-E07F7920A431");
}); |
Collections:
View file | ||||
---|---|---|---|---|
|
DBF da Tabela de Adapters.
View file name xx499011.dbf height 150