locked
Argument1: Cannot convert from 'HeritageCC.CreditCardRequest to 'HeritageCC.wsPost.CreditCardRequest' RRS feed

  • Question

  • User-621232634 posted

     I am getting the error above and I do not have an idea how to solve it. VS suggest to generate method PostSoapClient.DoPost but this has already been generated in wsPost class. I would appreciate any suggestion to solve this issue. I have attached the code that causing the error. I bolded the keyword that casues the error (creditCardRequest).  

    Here is the 'HeritageCC.CreditCardRequest

    namespace HeritageCC
    {
    public class CreditCardRequest
    {
    // Fields
    private string m_AccountNumber;
    private string m_Address;
    private string m_Amount;
    private string m_CardNumber;
    private string m_CardType;
    private string m_City;
    private string m_ClientCode;
    private string m_ClientNumber;
    private string m_CVV2;
    private string m_ExpiryMonth;
    private string m_ExpiryYear;
    private string m_FirstName;
    //private string m_propertyName;
    private string m_LastName;
    private string m_State;
    private string m_UserData;
    private string m_UserID;
    private string m_ZipCode;

    // Methods
    public CreditCardRequest()
    {
    this.m_ClientNumber = string.Empty;
    this.m_ClientCode = string.Empty;
    this.m_AccountNumber = string.Empty;
    this.m_CardType = string.Empty;
    this.m_CardNumber = string.Empty;
    this.m_ExpiryMonth = string.Empty;
    this.m_ExpiryYear = string.Empty;
    this.m_CVV2 = string.Empty;
    this.m_Amount = string.Empty;
    this.m_FirstName = string.Empty;
    //this.m_propertyName = string.Empty;
    this.m_LastName = string.Empty;
    this.m_Address = string.Empty;
    this.m_City = string.Empty;
    this.m_State = string.Empty;
    this.m_ZipCode = string.Empty;
    this.m_UserData = string.Empty;
    this.m_UserID = string.Empty;
    }

    public CreditCardRequest(string clientNumber, string clientCode, string accountNumber, string cardType, string cardNumber, string expiryMonth, string expiryYear, string cvv2, string amount, string firstName, string lastName, string address, string city, string state, string zipCode, string userData, string userId)
    {
    this.m_ClientNumber = string.Empty;
    this.m_ClientCode = string.Empty;
    this.m_AccountNumber = string.Empty;
    this.m_CardType = string.Empty;
    this.m_CardNumber = string.Empty;
    this.m_ExpiryMonth = string.Empty;
    this.m_ExpiryYear = string.Empty;
    this.m_CVV2 = string.Empty;
    this.m_Amount = string.Empty;
    this.m_FirstName = string.Empty;
    //this.m_propertyName = string.Empty;
    this.m_LastName = string.Empty;
    this.m_Address = string.Empty;
    this.m_City = string.Empty;
    this.m_State = string.Empty;
    this.m_ZipCode = string.Empty;
    this.m_UserData = string.Empty;
    this.m_UserID = string.Empty;
    this.m_ClientNumber = clientNumber;
    this.m_ClientCode = clientCode;
    this.m_AccountNumber = accountNumber;
    this.m_CardType = cardType;
    this.m_CardNumber = cardNumber;
    this.m_ExpiryMonth = expiryMonth;
    this.m_ExpiryYear = expiryYear;
    this.m_CVV2 = cvv2;
    this.m_Amount = amount;
    this.m_FirstName = firstName;
    this.m_LastName = lastName;
    this.m_Address = address;
    this.m_City = city;
    this.m_State = state;
    this.m_ZipCode = zipCode;
    this.m_UserData = userData;
    this.m_UserID = userId;
    }

    // Properties
    public string AccountNumber { get; set; }
    public string Address { get; set; }
    public string Amount { get; set; }
    public string CardNumber { get; set; }
    public string CardType { get; set; }
    public string City { get; set; }
    public string ClientCode { get; set; }
    public string ClientNumber { get; set; }
    public string CVV2 { get; set; }
    public string ExpiryMonth { get; set; }
    public string ExpiryYear { get; set; }
    public string FirstName { get; set; }
    public object this[string propertyName] {
    get {return propertyName; }
    set { base.GetType().GetProperty(propertyName).SetValue(this, value, null);}
    }
    public string LastName { get; set; }
    public string State { get; set; }
    public string UserData { get; set; }
    public string UserID { get; set; }
    public string ZipCode { get; set; }


    } //end request

    public class CreditCardResponse
    {
    // Fields
    private string m_AuthCode;
    private string m_GatewayRspCode;
    private string m_GatewayRspMsg;
    private string m_GatewayTxnId;
    private string m_HPICN;
    private string m_RspCode;

    // Methods
    public CreditCardResponse()
    {
    this.m_GatewayTxnId = string.Empty;
    this.m_GatewayRspCode = string.Empty;
    this.m_GatewayRspMsg = string.Empty;
    this.m_RspCode = string.Empty;
    this.m_AuthCode = string.Empty;
    this.m_HPICN = string.Empty;
    }

    public CreditCardResponse(string GatewayTransactionId, string GatewayResponseCode, string GatewayResponseMessage, string ResponCode, string AuthorizationCode, string HPICN)
    {
    this.m_GatewayTxnId = string.Empty;
    this.m_GatewayRspCode = string.Empty;
    this.m_GatewayRspMsg = string.Empty;
    this.m_RspCode = string.Empty;
    this.m_AuthCode = string.Empty;
    this.m_HPICN = string.Empty;
    this.m_GatewayTxnId = GatewayTransactionId;
    this.m_GatewayRspCode = GatewayResponseCode;
    this.m_GatewayRspMsg = GatewayResponseMessage;
    this.m_RspCode = ResponCode;
    this.m_AuthCode = AuthorizationCode;
    this.m_HPICN = HPICN;
    }

    // Properties
    public string AuthCode { get; set; }
    public string GatewayRspCode { get; set; }
    public string GatewayRspMsg { get; set; }
    public string GatewayTxnId { get; set; }
    public string HPICN { get; set; }
    public object this[string propertyName] {
    get { return propertyName; }
    set { base.GetType().GetProperty(propertyName).SetValue(this, value, null); }
    }
    public string RspCode { get; set; }


    } //end response

    public class Test : Page
    {
    // Fields
    protected Button btnPost;
    public IConfigurationSource configurationSource = null;
    protected HtmlForm form1;
    public LogWriter logWriter = null;
    public LogWriterFactory logWriterFactory = null;
    protected HtmlGenericControl spanResults;
    protected TextBox tbAccountNumber;
    protected TextBox tbAddress;
    protected TextBox tbAmount;
    protected TextBox tbCardNumber;
    protected TextBox tbCardType;
    protected TextBox tbCity;
    protected TextBox tbClientCode;
    protected TextBox tbClientNumber;
    protected TextBox tbCVV2;
    protected TextBox tbExpiryMonth;
    protected TextBox tbExpiryYear;
    protected TextBox tbFirstName;
    protected TextBox tbLastName;
    protected TextBox tbState;
    protected TextBox tbUserData;
    protected TextBox tbUserID;
    protected TextBox tbZipCode;

    // Methods
    protected void btnPost_Click(object sender, EventArgs e)
    {
    CreditCardRequest creditCardRequest = new CreditCardRequest
    {
    ClientNumber = this.tbClientNumber.Text,
    ClientCode = this.tbClientCode.Text,
    AccountNumber = this.tbAccountNumber.Text,
    CardType = this.tbCardType.Text,
    CardNumber = this.tbCardNumber.Text,
    ExpiryMonth = this.tbExpiryMonth.Text,
    ExpiryYear = this.tbExpiryYear.Text,
    CVV2 = this.tbCVV2.Text,
    Amount = this.tbAmount.Text,
    FirstName = this.tbFirstName.Text,
    LastName = this.tbLastName.Text,
    Address = this.tbAddress.Text,
    City = this.tbCity.Text,
    State = this.tbState.Text,
    ZipCode = this.tbZipCode.Text,
    UserData = this.tbUserData.Text,
    UserID = this.tbUserID.Text
    };
    PostSoapClient client = new PostSoapClient();
    client.Open();

    CreditCardResponse response = client.DoPost(creditCardRequest);

    string str = ((((("GatewayTransactionId: " + response.GatewayTxnId) + "\tGatewayResponseCode: " + response.GatewayRspCode) + "\tGatewayResponseMessage: " + response.GatewayRspMsg) + "\tResponseCode: " + response.RspCode) + "\tAuthorizationCode: " + response.AuthCode) + "\tHPICN: " + response.HPICN;
    this.spanResults.InnerHtml = str;
    }

    And here is the HeritageCC.wsPost.CreditCardRequest

    namespace HeritageCC.wsPost
    {
    [Serializable, DebuggerStepThrough, DataContract(Name = "CreditCardRequest", Namespace = "http://"), GeneratedCode("System.Runtime.Serialization", "4.0.0.0")]
    public class CreditCardRequest : IExtensibleDataObject, INotifyPropertyChanged
    {
    // Fields
    [OptionalField]
    private string AccountNumberField;
    [OptionalField]
    private string AddressField;
    [OptionalField]
    private string AmountField;
    [OptionalField]
    private string CardNumberField;
    [OptionalField]
    private string CardTypeField;
    [OptionalField]
    private string CityField;
    [OptionalField]
    private string ClientCodeField;
    [OptionalField]
    private string ClientNumberField;
    [OptionalField]
    private string CVV2Field;
    [OptionalField]
    private string ExpiryMonthField;
    [OptionalField]
    private string ExpiryYearField;
    [NonSerialized]
    private ExtensionDataObject extensionDataField;
    [OptionalField]
    private string FirstNameField;
    [OptionalField]
    private string LastNameField;
    [OptionalField]
    private string StateField;
    [OptionalField]
    private string UserDataField;
    [OptionalField]
    private string UserIDField;
    [OptionalField]
    private string ZipCodeField;

    // Events
    public event PropertyChangedEventHandler PropertyChanged;

    // Methods
    protected void RaisePropertyChanged(string propertyName)
    {
    PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
    if (propertyChanged != null)
    {
    propertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
    }

    // Properties
    [DataMember(EmitDefaultValue = false, Order = 2)]
    public string AccountNumber { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 11)]
    public string Address { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 8)]
    public string Amount { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 4)]
    public string CardNumber { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 3)]
    public string CardType { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 12)]
    public string City { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 1)]
    public string ClientCode { get; set; }
    [DataMember(EmitDefaultValue = false)]
    public string ClientNumber { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 7)]
    public string CVV2 { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 5)]
    public string ExpiryMonth { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 6)]
    public string ExpiryYear { get; set; }
    [Browsable(false)]
    public ExtensionDataObject ExtensionData { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 9)]
    public string FirstName { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 10)]
    public string LastName { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 13)]
    public string State { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 15)]
    public string UserData { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 0x10)]
    public string UserID { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 14)]
    public string ZipCode { get; set; }
    }

    [Serializable, GeneratedCode("System.Runtime.Serialization", "4.0.0.0"), DataContract(Name = "CreditCardResponse", Namespace = "http://"), DebuggerStepThrough]
    public class CreditCardResponse : IExtensibleDataObject, INotifyPropertyChanged
    {
    // Fields
    [OptionalField]
    private string AuthCodeField;
    [NonSerialized]
    private ExtensionDataObject extensionDataField;
    [OptionalField]
    private string GatewayRspCodeField;
    [OptionalField]
    private string GatewayRspMsgField;
    [OptionalField]
    private string GatewayTxnIdField;
    [OptionalField]
    private string HPICNField;
    [OptionalField]
    private string RspCodeField;

    // Events
    public event PropertyChangedEventHandler PropertyChanged;

    // Methods
    protected void RaisePropertyChanged(string propertyName)
    {
    PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
    if (propertyChanged != null)
    {
    propertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
    }

    // Properties
    [DataMember(EmitDefaultValue = false, Order = 4)]
    public string AuthCode { get; set; }
    [Browsable(false)]
    public ExtensionDataObject ExtensionData { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 1)]
    public string GatewayRspCode { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 2)]
    public string GatewayRspMsg { get; set; }
    [DataMember(EmitDefaultValue = false)]
    public string GatewayTxnId { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 5)]
    public string HPICN { get; set; }
    [DataMember(EmitDefaultValue = false, Order = 3)]
    public string RspCode { get; set; }
    }

    [GeneratedCode("System.ServiceModel", "4.0.0.0"), EditorBrowsable(EditorBrowsableState.Advanced), MessageContract(IsWrapped = false), DebuggerStepThrough]
    public class DoPostRequest
    {
    // Fields
    [MessageBodyMember(Name = "DoPost", Namespace = "http://", Order = 0)]
    public DoPostRequestBody Body;

    // Methods
    public DoPostRequest()
    {
    }

    public DoPostRequest(DoPostRequestBody Body)
    {
    this.Body = Body;
    }
    }

    [GeneratedCode("System.ServiceModel", "4.0.0.0"), DataContract(Namespace = "http://"), DebuggerStepThrough, EditorBrowsable(EditorBrowsableState.Advanced)]
    public class DoPostRequestBody
    {
    // Fields
    [DataMember(EmitDefaultValue = false, Order = 0)]
    public CreditCardRequest creditCardRequest;

    // Methods
    public DoPostRequestBody()
    {
    }

    public DoPostRequestBody(CreditCardRequest creditCardRequest)
    {
    this.creditCardRequest = creditCardRequest;
    }
    }

    [MessageContract(IsWrapped = false), DebuggerStepThrough, GeneratedCode("System.ServiceModel", "4.0.0.0"), EditorBrowsable(EditorBrowsableState.Advanced)]
    public class DoPostResponse
    {
    // Fields
    [MessageBodyMember(Name = "DoPostResponse", Namespace = "http://", Order = 0)]
    public DoPostResponseBody Body;

    // Methods
    public DoPostResponse()
    {
    }

    public DoPostResponse(DoPostResponseBody Body)
    {
    this.Body = Body;
    }
    }


    [DataContract(Namespace = "http://"), DebuggerStepThrough, GeneratedCode("System.ServiceModel", "4.0.0.0"), EditorBrowsable(EditorBrowsableState.Advanced)]
    public class DoPostResponseBody
    {
    // Fields
    [DataMember(EmitDefaultValue = false, Order = 0)]
    public CreditCardResponse DoPostResult;

    // Methods
    public DoPostResponseBody()
    {
    }

    public DoPostResponseBody(CreditCardResponse DoPostResult)
    {
    this.DoPostResult = DoPostResult;
    }
    }


    [ServiceContract(Namespace = "http://", ConfigurationName = "wsPost.PostSoap"), GeneratedCode("System.ServiceModel", "4.0.0.0")]
    public interface PostSoap
    {
    // Methods
    [OperationContract(Action = "http://something/DoPost", ReplyAction = "*")]
    DoPostResponse DoPost(DoPostRequest request);
    }

    [GeneratedCode("System.ServiceModel", "4.0.0.0")]
    public interface PostSoapChannel : PostSoap, IClientChannel, IContextChannel, System.Runtime.Remoting.Channels.IChannel, ICommunicationObject, IExtensibleObject<IContextChannel>, IDisposable
    {
    }


    [GeneratedCode("System.ServiceModel", "4.0.0.0"), DebuggerStepThrough]
    public class PostSoapClient : ClientBase<PostSoap>, PostSoap
    {
    // Methods
    public PostSoapClient()
    {
    }

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

    public PostSoapClient(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress)
    {
    }

    public PostSoapClient(string endpointConfigurationName, EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress)
    {
    }

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

    public CreditCardResponse DoPost(CreditCardRequest creditCardRequest)
    {
    DoPostRequest request = new DoPostRequest
    {
    Body = new DoPostRequestBody()
    };
    request.Body.creditCardRequest = creditCardRequest;
    return ((PostSoap)this).DoPost(request).Body.DoPostResult;
    }

    [EditorBrowsable(EditorBrowsableState.Advanced)]
    DoPostResponse PostSoap.DoPost(DoPostRequest request) =>
    base.Channel.DoPost(request);
    }

    } // end namespace

    Thank you very much for any help you guys provide. I really appreciate it

    Friday, April 26, 2019 3:02 PM

Answers

  • User-621232634 posted

    I simply removed the identical object in the HeritageCC.wsPost.CreditCardRequest and I got rid of the errors. 

    Thank you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 26, 2019 6:20 PM

All replies

  • User475983607 posted

    The error message is very clear and it telling exactly what's happening.  You created a web reference in Visual Studio.  The web reference has every you need to communicate with the service.  You created an identical object, HeritageCC.wsPost.CreditCardRequest, and tried to pass the object to the code generated method which is expecting HeritageCC.CreditCardRequest.

    The solution is populating the HeritageCC.CreditCardRequest object and pass it to the proxy method.

    Friday, April 26, 2019 4:33 PM
  • User-621232634 posted

    Hi Mgebhard,

      Thank you very much for your respond. Would you please if you do not mind write codes steps to fix it. I would really appreciate it.

    Thank you

    Friday, April 26, 2019 5:10 PM
  • User-621232634 posted

    I simply removed the identical object in the HeritageCC.wsPost.CreditCardRequest and I got rid of the errors. 

    Thank you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 26, 2019 6:20 PM