tags:

views:

15

answers:

1

I have written an ASP.NET web service.

It looks like this:

        WebServices.logic pLogic = new WebServices.logic();



        WebServices.manager[] pManager = new PowerManager[1];


        pManager[0] = new PowerManager();

        pManager[0].CustomerId = "sjsjshd";
      pManager[0].state = pLogic.getState("sasj");



        return pManager[0];

The pManager class looks like this:

public string _CustomerId;

    public int PowerStatus;

    public List<ArrayList> _Power;

    public string CustomerId
    {
        get
        {
            return _CustomerId;
        }

        set
        {


      _CustomerId = value;
        }
    }


    public List<ArrayList> Power
    {
        get
        {
            return _Power;
        }

        set
        {
            _Power = value;
        }
    }

When I run it, I get a repetition of the results, like so:

<p>
<_CustomerId>sjsjshd</_CustomerId>
<pStatus>0</PowerStatus>
−
<_p>
−
<ArrayOfAnyType>
<anyType xsi:type="xsd:int">1</anyType>
</ArrayOfAnyType>
<ArrayOfAnyType/>
</_p>
<CustomerId>sjsjshd</CustomerId>
−
<p>
−
<ArrayOfAnyType>
<anyType xsi:type="xsd:int">1</anyType>
</ArrayOfAnyType>
<ArrayOfAnyType/>
</p>
</pManager>

However, there is no duplicate values stored (Eg. I store client name in a collection, but only once - count of 1). There are no duplicates stored when I call getState(). This method returns a collection and it contains one value, but the results in XML has a repetition of this.

How comes the results appear to repeat themselves? When running the system, I only get one error.

Thanks

A: 

OK, looks like your XML serialization is giving you all the public members of your PowerManager class. Based on the naming convention of starting with an underscore, those members should be private, like this:

private string _CustomerId;

private List<ArrayList> _Power;

You also state "When running the system, I only get one error." What error are you getting?

Dennis Palmer
Sorry, error is a field. Don't worry about that but you answered my original question :)
dotnetdev