WebService со ссылкой не отображается, когда я пытаюсь отладить свой код - PullRequest
1 голос
/ 27 сентября 2011

Я пытаюсь использовать веб-службу WCF в моем приложении, но после добавления ссылки на службу и соответствующего оператора использования я не могу скомпилировать свой код, и 11 раз получаю следующую ошибку с 11 строкамицифры:

Error   7   The type name 'SignOnService' does not exist in the type 'FTXService.FTXService'    C:\Users\bdugan\documents\visual studio 2010\Projects\FTXService\FTXService\Service References\SignOnService\Reference.cs   130 20  FTXService

Я знаю, что сервис существует, так как я использовал его в PHP в прошлом, но я не могу понять, почему он не работает.Вот Reference.cs:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.237
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace FTXService.SignOnService {
using System.Runtime.Serialization;
using System;


[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="SimpleItem", Namespace="http://schemas.datacontract.org/2004/07/")]
[System.SerializableAttribute()]
public partial class SimpleItem : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {

    [System.NonSerializedAttribute()]
    private System.Runtime.Serialization.ExtensionDataObject extensionDataField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private bool AuthenticatedField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string[] ContractIDsField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string MessageStringField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string[] OwnerIDsField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private bool PasswordChangedField;

    [global::System.ComponentModel.BrowsableAttribute(false)]
    public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
        get {
            return this.extensionDataField;
        }
        set {
            this.extensionDataField = value;
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute()]
    public bool Authenticated {
        get {
            return this.AuthenticatedField;
        }
        set {
            if ((this.AuthenticatedField.Equals(value) != true)) {
                this.AuthenticatedField = value;
                this.RaisePropertyChanged("Authenticated");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute()]
    public string[] ContractIDs {
        get {
            return this.ContractIDsField;
        }
        set {
            if ((object.ReferenceEquals(this.ContractIDsField, value) != true)) {
                this.ContractIDsField = value;
                this.RaisePropertyChanged("ContractIDs");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute()]
    public string MessageString {
        get {
            return this.MessageStringField;
        }
        set {
            if ((object.ReferenceEquals(this.MessageStringField, value) != true)) {
                this.MessageStringField = value;
                this.RaisePropertyChanged("MessageString");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute()]
    public string[] OwnerIDs {
        get {
            return this.OwnerIDsField;
        }
        set {
            if ((object.ReferenceEquals(this.OwnerIDsField, value) != true)) {
                this.OwnerIDsField = value;
                this.RaisePropertyChanged("OwnerIDs");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute()]
    public bool PasswordChanged {
        get {
            return this.PasswordChangedField;
        }
        set {
            if ((this.PasswordChangedField.Equals(value) != true)) {
                this.PasswordChangedField = value;
                this.RaisePropertyChanged("PasswordChanged");
            }
        }
    }

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

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

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

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISignOn/Authentication_Complex", ReplyAction="http://tempuri.org/ISignOn/Authentication_ComplexResponse")]
    FTXService.SignOnService.SimpleItem Authentication_Complex(string UserName, string Password);

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISignOn/Authentication_Simple", ReplyAction="http://tempuri.org/ISignOn/Authentication_SimpleResponse")]
    FTXService.SignOnService.SimpleItem Authentication_Simple(string Parameter1, string Parameter2);

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISignOn/Authentication_ChangePassword", ReplyAction="http://tempuri.org/ISignOn/Authentication_ChangePasswordResponse")]
    FTXService.SignOnService.SimpleItem Authentication_ChangePassword(string Parameter1, string Parameter2, string Parameter3);

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISignOn/Authentication_Reset", ReplyAction="http://tempuri.org/ISignOn/Authentication_ResetResponse")]
    FTXService.SignOnService.SimpleItem Authentication_Reset(string Parameter1);
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface ISignOnChannel : FTXService.SignOnService.ISignOn, System.ServiceModel.IClientChannel {
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class SignOnClient : System.ServiceModel.ClientBase<FTXService.SignOnService.ISignOn>, FTXService.SignOnService.ISignOn {

    public SignOnClient() {
    }

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

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

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

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

    public FTXService.SignOnService.SimpleItem Authentication_Complex(string UserName, string Password) {
        return base.Channel.Authentication_Complex(UserName, Password);
    }

    public FTXService.SignOnService.SimpleItem Authentication_Simple(string Parameter1, string Parameter2) {
        return base.Channel.Authentication_Simple(Parameter1, Parameter2);
    }

    public FTXService.SignOnService.SimpleItem Authentication_ChangePassword(string Parameter1, string Parameter2, string Parameter3) {
        return base.Channel.Authentication_ChangePassword(Parameter1, Parameter2, Parameter3);
    }

    public FTXService.SignOnService.SimpleItem Authentication_Reset(string Parameter1) {
        return base.Channel.Authentication_Reset(Parameter1);
    }
}
}

Есть идеи?

Ответы [ 3 ]

1 голос
/ 28 сентября 2011

В службе существует класс FTXService, встроенный в пространство имен, также называемое FTXService. При создании клиентского прокси из этой службы, генератор службы Visual Studio не работает. Он генерирует код, который, по-видимому, ссылается на вновь возникающее пространство имен, используемое в servicerefence, а не на вызываемый метод класса обслуживания.

Чтобы решить эту проблему, переименуйте класс реализации вашей службы в (например) FTXServiceImpl и заново создайте клиентский прокси-сервер (удалите и добавьте ссылку на службу в клиентском проекте).

0 голосов
/ 27 сентября 2011

Согласно Reference.cs, который вы разместили, клиент службы называется SignOnClient, поэтому вам нужно что-то вроде:

var client = new SignOnClient();

Или для полной квалификации:

var client = new FTXService.SignOnService.SignOnClient();

Другими словами, тип SignOnService не существует в пространстве имен (это то, что говорит вам ошибка), но SignOnClient делает.

0 голосов
/ 27 сентября 2011

Когда вы используете диалоговое окно «Добавить ссылку на службу» в Visual Studio, обычно запрашивается указание пространства имен. По умолчанию это ServiceReference1. Он также генерирует строго типизированные прокси-клиентские классы, которые обычно заканчиваются. Таким образом, клиентский прокси может выглядеть примерно так:

using (var client = new ServiceReference1.SomeNamespace.SignOnServiceClient())
{
    ...
}

Просто щелкните правой кнопкой мыши на сгенерированном прокси-сервере службы и просмотрите исходный код, чтобы увидеть, какие классы точно были созданы.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...