2
I’m consuming a web service SOAP which does not provide any information on Headers
, nor of autenticação
.
I added the same in my project by the tool Add Connected Service in Visual Studio.
Looking around the site, I found this topic: Add SOAP Header to SOAP C#
Who helped me create a Header
and successfully add to my client
:
var endpoint = new EndpointAddressBuilder(client.Endpoint.Address);
endpoint.Headers.Add(AddressHeader.CreateAddressHeader("cnpj", string.Empty, "xxxxxxxx"));
endpoint.Headers.Add(AddressHeader.CreateAddressHeader("chave", string.Empty, "xxxxxxxx"));
client.Endpoint.Address = endpoint.ToEndpointAddress();
However, the Header
expected by web service is different from the common:
<soapenv:Header>
<Autenticar>
<cnpj>xxxxxxx</cnpj>
<chave>xxxxxxx</chave>
</Autenticar>
</soapenv:Header>
Has an object <Autenticar>
within the Header
.
I’ve tried that topic too Adding SOAP implicit headers to WSDL, however, without success.
How can I add that <Autenticar>
inside my Header
?
No words, thank you very much!!!
– perozzo
You’re welcome @Perozzo.
– Bruno Warmling