0
I am developing a project in which I have to consume a Web Service in . NET that requires an object with some parameters of type Enum.
The call is made by Javascript as below:
function ConsultarPeriodo(){
var metodo = 'ConsultarPeriodo';
var url = baseURL.dadoscliente;
var param = {
canal : 'LOJA',
empresa : 'Teste',
loja : '0',
usuario : 'Teste'
};
return $soap.post(url, metodo, { req: param });
}
The attributes "channel" and "company" are of type Enum in the Web Service. NET that I am consuming, so I need to send the parameters so that the web service recognizes the Enum attributes.
Enum code:
public enum EmpresaType
{
/// <remarks/>
Loja1,
/// <remarks/>
Loja2,
/// <remarks/>
Loja3,
}
public enum CanalType
{
/// <remarks/>
LOJA,
/// <remarks/>
ECOMMERCE,
}
What my code would look like?
Thank you!
Only put the numeric value of Enum.
– Jéf Bueno
And in case the enums were not created with numerical values?
– Raphael Teodoro
Write the name of the value.
– Jéf Bueno
You have access to the Enum code to post here?
– Marcell Alves
All right, I made it available!
– Raphael Teodoro
Detail, the class that references enums is inside a web Referral of an external service that I added in my application, thinking that the problem is this. I did a test creating the same external Ws class in my application, but creating the attributes as XML attribute, and functioned. Since WS is external and I can’t change, I guess I’ll have to create an internal class to do the "from x to".
– Raphael Teodoro
Did you run a test by passing the numerical values of Enum? Ex: Function Query Eriododad(){ var method = 'Query Eriododad'; var url = baseURL.dadoscliente; var param = ' channel :0, company : 1, store : '899', user : 'Test#&Xa; }; Return $Soap.post(url, method, { req: param }); }
– Marcell Alves