简体   繁体   中英

Get unexpected arguments when calling function from WCF services using LINQ 2

I have created a WCF web service using LINQ and was trying to call the PatientRegistration function. However, when I called the function there are a few arguments added in which I have no idea where they are come from. Can anyone help me to solve this?

Function in WCF Service:

public Boolean PatientRegistration(
    String HealthInsuranceNO,
    String FirstName,
    String LastName,
    int PhoneNumber,
    String Address,
    String Email)
{
    DataClasses1DataContext dc = new DataClasses1DataContext();

    if (HealthInsuranceNO != ""
        && FirstName != ""
        && LastName != ""
        && Address != ""
        && PhoneNumber != 0)
    {
        Patient p = new Patient();
        {
            p.HealthInsuranceNO = HealthInsuranceNO;
            p.FirstName = FirstName;
            p.LastName = LastName;
            p.PhoneNumber = PhoneNumber;
            p.Address = Address;
            p.Email = Email;
        };

        dc.Patients.InsertOnSubmit(p);

        dc.SubmitChanges();
        return true;
    }
    else
    {
        return false;
    }
}

And also:

[OperationContract]
Boolean PatientRegistration(
    String HealthInsuranceNO,
    String FirstName,
    String LastName,
    int PhoneNumber,
    String Address,
    String Email);

I got three more arguments that the system expect me to fill in and they are

bool PhoneNumberspecified,
out bool PatientmentRegistrationResult,
out bool PatientmentRegistrationResultSpecified

It seems you are creating the proxy on the client using "Add Web Reference". You should use "Add Service Reference" for generating the right proxy.

The difference is the serializer they use. Adding a web reference uses XmlSerializer and adding Service reference uses a DataContractSerializer . It's the XmlSerializer which adds those paramters, one represents the data itself, and one specifies whether or not the data is actually present.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM