Pass object to WebService

4

I'm starting development using WebService + Windows Form and I made some silly methods passing parameters, however, I came up with the idea of passing an object as a parameter where the Web Service would return me a string either concatenating each data, so that's fine . The problem is, how can I pass an Object that is in the Windows Form Solution to the WebService?

Would both have to have the same basic class?

I did something like this in Windows Form:

 private void button1_Click(object sender, EventArgs e)
    {
        Funcionario.FuncionarioSoapClient func = new Funcionario.FuncionarioSoapClient();
        Cliente c = new Cliente();
        c.Nome = "JR";
        c.Idade = 20;
        func.Concatena(c);

    }

But I get the error: Can not convert from 'WebService ...' to 'WebSerivce ...'

Overall, how do I do this? to pass a windows form object to the webservice?

    
asked by anonymous 01.05.2016 / 18:02

1 answer

1

Can not pass an object to webservice .

You have to convert the object to string and send the string to the webservice and webservice to convert the string to an object again.

I usually use Json to transform the object into a string.

    
02.05.2016 / 00:36