开发者

Referenced WebService not showing up when I attempt to debug my code

开发者 https://www.devze.com 2023-04-07 21:06 出处:网络
I am in the process of attempting to consume a WCF webservice in my application, but after adding the service reference and the appropriate using statement, I am unable to compile my code, and I get t

I am in the process of attempting to consume a WCF webservice in my application, but after adding the service reference and the appropriate using statement, I am unable to compile my code, and I get the following error 11 times with 11 line numbers:

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

I know the service exists since I have used it in PHP in the past, but I can't seem to figure out why it isn't working. Here is 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开发者_Go百科, 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);
    }
}
}

Any ideas?


There is a class in the service called FTXService, embedded in a namespace also called FTXService. When generating a client proxy out of that service, the service generator of Visual Studio messes up. It generates code that seems to reference to the re-occurring namespace used in the servicerefence instead of the service class method to be called.

To solve this, rename the class of your service implementation to (for example) FTXServiceImpl and regenerate your client proxy (remove and add your service reference in the client project).


When you use the Add Service Reference dialog in Visual Studio it usually asks you to specify a namespace. By default it is ServiceReference1. It also generates strongly typed proxy client classes that usually end up with. So the client proxy might look something like this:

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

Simply right click on the generated service proxy and browse the source code to see what classes exactly were created.


According to the Reference.cs you posted the service client is called SignOnClient so you'll want something like:

var client = new SignOnClient();

Or to fully-qualify it:

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

In other words the type SignOnService does not exist in the namespace (this is what the error is telling you) but SignOnClient does.

0

精彩评论

暂无评论...
验证码 换一张
取 消