Search code examples
c#web-serviceswcfasmx

Service Reference Generates Incorrect Method Signature


We have an asmx web service project. When I add it to the project using the Add Service Reference option everything works fine. However, when my colleague does the same, he gets the wrong signature for the methods defined in the operation contract.

By wrong signature I mean the original methods receive entities as parameters which are generated in my colleague's project as DataSet parameters (The service reference structures are also different as shown in pictures. My colleague has more stuff). We are using VS 2013.

What's going on ?

enter image description here

My Service Reference

EDIT:

Service Contract

  [ServiceContract]
    public interface INetTransTntIntegration
    {
        [OperationContract]
        string CreateGlbTrns1LineCard(GlbTrns1LineCardEntity ent);

        [OperationContract]
        void CreateGlbTrns1LineCardTest();
    }

Generated Code (Colleague's incorrect code)

namespace TNT.ServiceReference {
using System.Data;


[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference.INetTransTntIntegration")]
public interface INetTransTntIntegration {

    // CODEGEN: Parameter 'CreateGlbTrns1LineCardResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCard", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardResponse")]
    [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
    TNT.ServiceReference.CreateGlbTrns1LineCardResponse CreateGlbTrns1LineCard(TNT.ServiceReference.CreateGlbTrns1LineCardRequest request);

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCard", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardResponse")]
    System.Threading.Tasks.Task<TNT.ServiceReference.CreateGlbTrns1LineCardResponse> CreateGlbTrns1LineCardAsync(TNT.ServiceReference.CreateGlbTrns1LineCardRequest request);

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTest", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTestResponse")]
    [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
    void CreateGlbTrns1LineCardTest();

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTest", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTestResponse")]
    System.Threading.Tasks.Task CreateGlbTrns1LineCardTestAsync();
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="CreateGlbTrns1LineCard", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class CreateGlbTrns1LineCardRequest {

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public System.Data.DataSet ent;

    public CreateGlbTrns1LineCardRequest() {
    }

    public CreateGlbTrns1LineCardRequest(System.Data.DataSet ent) {
        this.ent = ent;
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="CreateGlbTrns1LineCardResponse", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class CreateGlbTrns1LineCardResponse {

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public string CreateGlbTrns1LineCardResult;

    public CreateGlbTrns1LineCardResponse() {
    }

    public CreateGlbTrns1LineCardResponse(string CreateGlbTrns1LineCardResult) {
        this.CreateGlbTrns1LineCardResult = CreateGlbTrns1LineCardResult;
    }
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface INetTransTntIntegrationChannel : TNT.ServiceReference.INetTransTntIntegration, System.ServiceModel.IClientChannel {
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class NetTransTntIntegrationClient : System.ServiceModel.ClientBase<TNT.ServiceReference.INetTransTntIntegration>, TNT.ServiceReference.INetTransTntIntegration {

    public NetTransTntIntegrationClient() {
    }

    public NetTransTntIntegrationClient(string endpointConfigurationName) : 
            base(endpointConfigurationName) {
    }

    public NetTransTntIntegrationClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress) {
    }

    public NetTransTntIntegrationClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(endpointConfigurationName, remoteAddress) {
    }

    public NetTransTntIntegrationClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress) {
    }

    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    TNT.ServiceReference.CreateGlbTrns1LineCardResponse TNT.ServiceReference.INetTransTntIntegration.CreateGlbTrns1LineCard(TNT.ServiceReference.CreateGlbTrns1LineCardRequest request) {
        return base.Channel.CreateGlbTrns1LineCard(request);
    }

    public string CreateGlbTrns1LineCard(System.Data.DataSet ent) {
        TNT.ServiceReference.CreateGlbTrns1LineCardRequest inValue = new TNT.ServiceReference.CreateGlbTrns1LineCardRequest();
        inValue.ent = ent;
        TNT.ServiceReference.CreateGlbTrns1LineCardResponse retVal = ((TNT.ServiceReference.INetTransTntIntegration)(this)).CreateGlbTrns1LineCard(inValue);
        return retVal.CreateGlbTrns1LineCardResult;
    }

    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    System.Threading.Tasks.Task<TNT.ServiceReference.CreateGlbTrns1LineCardResponse> TNT.ServiceReference.INetTransTntIntegration.CreateGlbTrns1LineCardAsync(TNT.ServiceReference.CreateGlbTrns1LineCardRequest request) {
        return base.Channel.CreateGlbTrns1LineCardAsync(request);
    }

    public System.Threading.Tasks.Task<TNT.ServiceReference.CreateGlbTrns1LineCardResponse> CreateGlbTrns1LineCardAsync(System.Data.DataSet ent) {
        TNT.ServiceReference.CreateGlbTrns1LineCardRequest inValue = new TNT.ServiceReference.CreateGlbTrns1LineCardRequest();
        inValue.ent = ent;
        return ((TNT.ServiceReference.INetTransTntIntegration)(this)).CreateGlbTrns1LineCardAsync(inValue);
    }

    public void CreateGlbTrns1LineCardTest() {
        base.Channel.CreateGlbTrns1LineCardTest();
    }

    public System.Threading.Tasks.Task CreateGlbTrns1LineCardTestAsync() {
        return base.Channel.CreateGlbTrns1LineCardTestAsync();
    }
}

My correctly generated code

namespace TNT.NettransSvc {


    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="NettransSvc.INetTransTntIntegration")]
    public interface INetTransTntIntegration {

        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCard", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardResponse")]
        string CreateGlbTrns1LineCard(LLMTESTADAPTER.EntityClasses.GlbTrns1LineCardEntity ent);

        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCard", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardResponse")]
        System.Threading.Tasks.Task<string> CreateGlbTrns1LineCardAsync(LLMTESTADAPTER.EntityClasses.GlbTrns1LineCardEntity ent);

        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTest", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTestResponse")]
        void CreateGlbTrns1LineCardTest();

        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTest", ReplyAction="http://tempuri.org/INetTransTntIntegration/CreateGlbTrns1LineCardTestResponse")]
        System.Threading.Tasks.Task CreateGlbTrns1LineCardTestAsync();
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface INetTransTntIntegrationChannel : TNT.NettransSvc.INetTransTntIntegration, System.ServiceModel.IClientChannel {
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class NetTransTntIntegrationClient : System.ServiceModel.ClientBase<TNT.NettransSvc.INetTransTntIntegration>, TNT.NettransSvc.INetTransTntIntegration {

        public NetTransTntIntegrationClient() {
        }

        public NetTransTntIntegrationClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }

        public NetTransTntIntegrationClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }

        public NetTransTntIntegrationClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }

        public NetTransTntIntegrationClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }

        public string CreateGlbTrns1LineCard(LLMTESTADAPTER.EntityClasses.GlbTrns1LineCardEntity ent) {
            return base.Channel.CreateGlbTrns1LineCard(ent);
        }

        public System.Threading.Tasks.Task<string> CreateGlbTrns1LineCardAsync(LLMTESTADAPTER.EntityClasses.GlbTrns1LineCardEntity ent) {
            return base.Channel.CreateGlbTrns1LineCardAsync(ent);
        }

        public void CreateGlbTrns1LineCardTest() {
            base.Channel.CreateGlbTrns1LineCardTest();
        }

        public System.Threading.Tasks.Task CreateGlbTrns1LineCardTestAsync() {
            return base.Channel.CreateGlbTrns1LineCardTestAsync();
        }
    }
}

Solution

  • My colleague's visual studio weren't converting the entities automatically for some reason so I had to explicitly set the reuse option for those dlls (containing entity definitions/operations) in order for entities to be identified.

    In my case I did not have to check any of these but it was working fine.

    I would like to thank @HenkHolterman for his time.

    enter image description here