views:

62

answers:

1

Hi,

I've got two applications.

One uses webreference to my webservice, and second use servicereference to my webservice.

There is metohod which I'm invoking:

[WebMethod]
public Car[] GetCars(string carCode)
{
 Cars[] cars= ModelToContract.ToCars(MyFacade.GetCars(carCode);
return cars;
}

Car has two pools:

string Code {get;set;}
CarType Type {get;set;}

public enum CarType
{
Van=0,
Pickup=1
}

I'm debuging this webMethod, and...

at the end webservice throw good collection of cars, which has one car: code="bmw",Type.Van

But... Application with webrefence receives the same collection and application with servicereference gets collection, where field code is null...

Invoking servicereference:

MyService myService=new MyService()
Cars[] cars= client.GetCars(carcode);

Invoking webservice:

MyService.MyServiceSoapClient client = new MyServiceS.MyServiceSoapClient();
            Cars[] cars= client.GetCars(carcode);
+1  A: 

Hum it's a serialization problem.

Your model should be like this :

[Serializable]
public class Car
{
    [XmlElement]
    string Code {get;set;}

    [XmlElement]
    CarType Type {get;set;}
}

You may ensure the return type too :

MyService myService=new MyService()
MyService.Car[] cars= myService.GetCars(carcode);

-

MyServiceS.MyServiceSoapClient client = new MyServiceS.MyServiceSoapClient();
MyServiceS.Car[] cars= client.GetCars(carcode);
JoeBilly
Yes, that now works for service references, but doesn't work for webreference :/
You may have to redefine the references if not already done to regenerate the model on the client-side.
JoeBilly
ok, now it works. Thanks man !