Domanda

I'm currently experiencing some very strange issues with one of my SOAP WCF Services. The problem is that the ServiceReference-Tool in Visual studio alters arguments of some of my methods.

For example:

If this is my Interface definition (excerpt):

namespace ****.PrimeTime.PrimeTime
{
    [ServiceContract]
    public interface IPrimeTimeWS
    {
        [...]
        [OperationContract]
        ****.PrimeTime.BusinessObjects.CostDataset ReadCost(****.PrimeTime.BusinessObjects.SearchCostDataset searchDataset, ****.Framework.SharedComponents.Paging pagingInfo);
        [OperationContract]
        ****.PrimeTime.BusinessObjects.CostDataset WriteCost(****.PrimeTime.BusinessObjects.CostDataset data, bool modifyRowState);
    }
}

And this is my Service definition(excerpt):

namespace ****.PrimeTime.PrimeTime
{
    public class PrimeTimeWS : IPrimeTimeWS
    {
        [...]
        public ****.PrimeTime.BusinessObjects.CostDataset WriteCost(****.PrimeTime.BusinessObjects.CostDataset data, bool modifyRowState)
        {
            [...]
        }
        public ****.PrimeTime.BusinessObjects.CostDataset ReadCost(****.PrimeTime.BusinessObjects.SearchCostDataset searchDataset, ****.Framework.SharedComponents.Paging pagingInfo)
        {
            [...]
        }
    }
}

, the wsdl file is correct (WriteCost has two parameters, CostDataset and bool).

But when I add a Service Reference in my client, it looks like this:

WriteCost in Service Reference The ReadCost-method works as expected, the problem is that in all(!) my Write methods any other dataset gets replaced by the TimeDataDataset. This doesn't happen in any other method than write methods, regardless which datasets are used.

I've been on this problem for nearly a day now but could not achieve any improvement.

I already tried:

  • deleting and recreating the Service Reference
  • cleaning and rebuilding the service and the client
  • adding a Service Reference to an empty project -> same thing happens
  • the CostDataset doesn't look any different than the TimeDataDataset or any other dataset (structurally)
  • if I manually alter the Reference.cs so that the parameters are correct, that will work but just as long as I don't update the Service Reference, that overwrites my changes.

Any ideas? If you need more source code, I can provide it, I just didn't want to put all that code in here as that would be a little bit too much...

È stato utile?

Soluzione 2

I just solved the issue "accidentially" with a little help from a typo.

The cause of the problem is that you can't reuse a parameter name in the OperationContract.

This code:

 [OperationContract]
        ****.PrimeTime.BusinessObjects.ProjectDataset WriteProject(****.PrimeTime.BusinessObjects.ProjectDataset data, bool modifyRowState);
        [OperationContract]
        ****.PrimeTime.BusinessObjects.CompanyDataset WriteCompany(****.PrimeTime.BusinessObjects.CompanyDataset data, bool modifyRowState);

won't work because the "data" parameter is re-used with a different type. To make it work, I re-named all the parameters in the Interface so that their name is prefixed with the method name like this:

 [OperationContract]
        ****.PrimeTime.BusinessObjects.ProjectDataset WriteProject(****.PrimeTime.BusinessObjects.ProjectDataset WriteProject_data, bool WriteProject_modifyRowState);
        [OperationContract]
        ****.PrimeTime.BusinessObjects.CompanyDataset WriteCompany(****.PrimeTime.BusinessObjects.CompanyDataset WriteCompany_data, bool WriteCompany_modifyRowState);

Solved.

Altri suggerimenti

Normally when something like this happens the dll that is being used is not the one that you think is being used.

For example:

  • Is the WSDL being read from an IIS site? Check the config of the web site for which directory it is pointing to?
  • Is there a copy in the GAC that is being used instead of the version in the bin directory?
  • Is there an error in the code that stops the dll from being built, so the old one is being used?

When this happens I open the dll in JustDecompile to make sure what is in it.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top