0
I’d like some support. I’m in serious trouble with a client. I have a C# application that fetches data from a system and sends it to a SOAP service. It turns out that this SOAP service requires a header:
<soapenv:Header>
<wsAutenticacao>
<login>us1</login>
<senha>b81476fc88f1a2a4</senha>
<codigoEmpresa>1</codigoEmpresa>
</wsAutenticacao>
</soapenv:Header>
When mapping through Visual Studio, I can’t find where to insert header data. The solution was not initiated by me and I need to continue in the same pattern.
Services are mapped in the app.config as Properties.Settings and not as Binding:
<setting name="wsSGOSituacaoProjeto_SituacaoProjetoWSImplService"
serializeAs="String">
<value>http://ser:8080/erp/ws/situacaoProjeto</value>
</setting>
The call in the reference contains nothing about the header:
public ProjetoWSImplService() {
this.Url = global::Integracao.SGO.Properties.Settings.Default.Projeto_ProjetoWSImplService;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}
/// <remarks/>
public event consultarProjetoCompletedEventHandler consultarProjetoCompleted;
/// <remarks/>
public event inserirCompletedEventHandler inserirCompleted;
/// <remarks/>
public event consultarCompletedEventHandler consultarCompleted;
/// <remarks/>
public event alterarCompletedEventHandler alterarCompleted;
The part of the code that is error due to missing header is as follows:
if (WebServiceSGO == null)
{
Iniciar("http://ser:8080/erp/ws/projeto?wsdl");
//WebServiceSGO = new Integracao.SGO.wsSGOProjeto.ProjetoWSImplService();
}
WebClient client = new WebClient();
var ret = WebServiceSGO.consultar(Param.Empresa, Param.EmpresaEspecificada, Param.UnidadeAdministrativa, Param.Datainicio, Param.DatainicioEspecificada, Param.Projeto, Param.AnoProjeto, Param.AnoProjetoEspecificado, Param.TipoProjeto, Param.Cliente, Param.ClienteEspecificado);
return ToXML(ret);
Return: "Login Failure!"
where you get the login/password/password data?
– Ricardo Pontual
It was provided to me by the company that built the service. It’s statistical information. <soapenv:Header> <wsAutenticacao><login>Erp</login><password>b814720948b6bf65e0b5a6fc88f1a2a4</password><codigoEmpresa>1</codigoEmpresa></wsAutenticacao> </soapenv:Header>
– Alexandre Fourakis
wanted to say if it is in a configuration file for example? but in your case I think it will not help, I will put an answer with an example
– Ricardo Pontual