I’m trying to call a web service method which returns an ID of a company
GetCompanyCommand companyRef = new GetCompany();
but I have a method in the web service that already exists and the constructor has a parameter
public GetCompanyCommand(Guid actCompanyId)
{
this.actCompanyId = actCompanyId;
}
The problem is when i go to update the Web Service reference i am presented with an error that says the method cannot be serialised because it does not contain a parameterless constructor.
Now is there a way for me to fix this without changing the existing constructor? Because many other methods already call it.
If your web service class has a constructor with parameter than it should have parameterless constructor. like
This is a limitation of
XmlSerializer. Note thatBinaryFormatterandDataContractSerializerdo not require this – they can create an uninitialized object out of the ether and initialize it during deserialization.During an object’s
de-serialization, the class responsible for de-serializing an object creates aninstanceof the serialized class and then proceeds to populate the serialized fields and properties only after acquiring an instance to populate.