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:
<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'>
<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!!
To me it looks the same/correct, what do you want to change/edit??
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 =/.
I really, really doubt that the issue is the header namespace prefix.
What does the error (soap fault) says?
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.
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?
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.
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"
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.
You can try to achieve this using HTTP!
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