Creating a new Class over a webService

G

Guest

C#

I am developing a basic app to run on a mobile device, to interact with our
central server using WebServices. I have created a class called PacketInfo
which has a couple of properties suchs as CreateDate RecieveDate and Message.
I created this classs in a new project called MAMI, built this in Release
mode to give me a MAMI.dll.

I have added a reference to this dll in my WebService code on the central
server, and I have a WebMethod which accepts a MAMI.PacketInfo object and
sets some values in it.

[WebMethod]
public void Check(MAMI.PacketInfo packet)
{
packet.Message = "I am Here";
}

On my mobile device app I have also added a reference to the MAMI.dll, and
in here I have a WebReference to my Webservice setup. I have this code on my
mobile device:

MAMI.PacketInfo packet = new MAMI.PacketInfo()

webService.Check(packet);
MessageBox.Show(packet.Message);

The build fails though on the Mobile side, as it says I cant convert
MAMI.PacketInfo to webMAM.wsMan.PacketInfo.

Can someone point me in the right direction. Should I be doing it this way?
The idea behind this was that everytime I send a message/call from the
mobile device to the central server I can send a load of information about
the message, such as success or error messages etc etc, so I thought I could
send an instance of my PacketInfo class with the call.

Thanks

Ste
 
C

Chris Dunaway

I had this same situation. What causes it is that when you reference
the web service, it create proxy classes with the same properties as
your classes.

What I did to get around it was to open the generated proxy classes,
remove the duplicate class definitions and import my classes. That way
the web service is looking for my classes and not its own generated
classes.

The drawback to this approach is that if you ever change the web
service and have to refresh the reference in VS, then new proxy classes
will be generated and you will have to do over again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top