0
I am developing a system in PHP to generate Nfse that uses the Web Service of the city of São Paulo, but I am not able to integrate with the Web Service. Whenever I send an XML message to the Web Service, I receive a reply with the following information:
HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: application/soap+xml; charset=utf-8
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 21 Jun 2018 13:25:20 GMT
Content-Length: 0
To make the test request, I am using Soapui 5.2.1.
Example request "Query" giving error:
<?xml version="1.0" encoding="UTF-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ConsultaCNPJRequest xmlns="http://www.prefeitura.sp.gov.br/nfe">
<VersaoSchema>1</VersaoSchema>
<MensagemXML>
<PedidoConsultaCNPJ>
<Cabecalho Versao="1">
<CPFCNPJRemetente>
<CNPJ>CNPJ x</CNPJ>
</CPFCNPJRemetente>
</Cabecalho>
<CNPJContribuinte>
<CNPJ>CNPJ Y</CNPJ>
</CNPJContribuinte>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference>
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3c.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>HuMpzsiKXGJw7yduTCts0=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>F0Te8gclpt0pW0BNBPCxknBFXs+igy/VvSM6zvy1agZGcv7ZiYWjzdMNB4G4ANeBPtpWI0hDae0/ZNHzXvUSHUJ+V+PANNCsKj1IAKNn4Sbv1DV4gPj15p4SUzpE4Lee5LvD37fPxx5VALRcWKLQoPL+ViOG+4S5npVcXpurr8HUZvhVkA3ilvNJMGf701q0oCJ/ttil0wo8xl2MaBoqywaTLD1PN5AjS/koFo7A+/ozOSCzIdojXWTIk2NLugYATZ9Trrrckx7TJb3QkBvj6TQg9H6r64Qy9bLxZWIhETrou/lCIAqXqsNvi8wsBYAwcF+R18CsqDw==</SignatureValue>
<KeyInfo>
<X509Data>
</X509Certificate>
exemplo1
</X509Data>
</KeyInfo>
</Signature>
</PedidoConsultaCNPJ>
</MensagemXML>
</ConsultaCNPJRequest>
</soap12:Body>
</soap12:Envelope>
Does anyone have an example of a valid request? Or do you know why this error is occurring?
If you send XML in this format via Postman will not work, you have to convert to string. In this conversion, XML is escaped (escaped).
– Daniel Silva
Daniel, thank you for the information... I am doing this way, without line break and formatting by Postman and in Python Request too, however I keep getting Bad Request without any return on the error. Would you have some functional example for me to compare please? Obg! Hugs
– vitorsgobbi