Written by

Integrations Analyst / Web Developer at Shift
Question Igor Barboza · Apr 20, 2024

There's any way to edit a SOAP header?

Hello everyone, I need some help. 

I have to send some events for a government WebService that I already imported the WSDL and XSD's and It worked fine and I'm able to build the message and connect into the service, but It has been rejected with the message that the XML is wrong and the only diference between the Caché SOAP message to all the examples that the government gave us is the header:
   

This is how the Government is expecting the message:

<?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>
		<cteDadosMsg
			xmlns="http://www.portalfiscal.inf.br/cte/wsdl/CTeStatusServicoV4">
			-----------------Dynamic XML Body------------------
		</cteDadosMsg>
	</soap12:Body>
</soap12:Envelope>

 

And this is how It's generate in Cache:

  <  ?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope
           xmlns:SOAP-ENV='http://www.w3.org/2003/05/soap-envelope'
           xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
          xmlns:s='http://www.w3.org/2001/XMLSchema'&gt;
          <SOAP-ENV:Body>
                     <cteDadosMsg
                              xmlns="http://www.portalfiscal.inf.br/cte/wsdl/CTeRecepcaoEventoV4">
                              -----------------Dynamic XML Body------------------ 
                     </cteDadosMsg>
         </SOAP-ENV:Body>
</SOAP-ENV:Envelope>  

So, there's any way to edit It before invoke the webMethod or any configuration that made it during the process?

Thank you so much!!

Product version: Ensemble 2018.1

Comments

Enrico Parisi · Apr 20, 2024

To me it looks the same/correct, what do you want to change/edit??

0
Igor Barboza  Apr 20, 2024 to Enrico Parisi

Hello Enrico, so, I want to change the prefix of the Envelope, from SOAP-ENV to SOAP12 and xmlns:s to xmlns:xsd, that is the only stuff that is diferent in the request, in my mind it isn't suppose to be the reason of the rejection, but is my only difference =/.

0
Enrico Parisi  Apr 20, 2024 to Igor Barboza

I really, really doubt that the issue is the header namespace prefix.

What does the error (soap fault) says?

0
Igor Barboza  Apr 21, 2024 to Enrico Parisi

I agree with you Enrico, to me It isn't the reason of the error, but I would like to try this change before waiting for a long time te answer of the government support that is really slow over here hehehe.

So, there is not a SOAP fault, the system only send a message like "malformed XML" as we forgot some tag or something else, but me and another analyst did a double check and is perfect as the documentation says.
 

0
Enrico Parisi  Apr 21, 2024 to Igor Barboza

How are you calling the WS?

Are you using a Business Operation with EnsLib.SOAP.OutboundAdapter?

To understand how the header can be customized, can you provide a sample of your SOAP call?

0
Enrico Parisi  Apr 21, 2024 to Igor Barboza

In order to better understand the problem, you may use SoapUI to "manually" call the WS and try different options/messages to figure what's wrong with your call.

0
Igor Barboza  Apr 22, 2024 to Enrico Parisi

Hello, Enrico, thank you so much for your time, I'm calling the WS directly from the class generated in the SOAP Wizard, we use Caché 2018.1 over here and I did a double check today in the documentation and found a parameter that solve my problem with the prefix.
If for any reason you need to change it, just set this parameter into the class generated by the SOAP Wizard.
Parameter SOAPPREFIX = "AnythingYouNeed"

0
Igor Barboza  Apr 22, 2024 to Enrico Parisi

By the way, as ours beliefs It wasn't the problem with the message, even changing the prefix and delivery it as the manual and examples the system is rejecting the message, so we'll have to keep in touch with the support team of it.
One more time, thank you so much for your time.

0
Igor Barboza  Apr 22, 2024 to Charles Sylvain

Hi Charles, I was almost doing it  and making a directly HTTP call, but I'd found the parameter SOAPPREFIX that allow us to change it at the standard class generated by the SOAP Wizard.
If you need to do something like that, just set this parameter into the main class of the WS Client like this: Parameter SOAPPREFIX = "AnythingYouNeed"

Thank you

0