简体   繁体   中英

unable to add service reference in wcf application

the problem : when adding service reference -> chosing the address http://localhost:8000 -> pressing GO

There was an error downloading 'http://localhost:8000'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8000
Metadata contains a reference that cannot be resolved: 'http://localhost:8000/'.
There was no endpoint listening at http://localhost:8000/ that could accept the message.
This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8000
If the service is defined in the current solution, try building the solution and adding the service reference again.

The service contract :

[ServiceContract(Namespace="http://www.thatindigogirl/2011/12")]
public interface IHelloIndigo
{
    [OperationContract]
    void DoWork();
}    

The service :

public class HelloIndigo : IHelloIndigo
{
    public void DoWork()
    {
        throw new NotImplementedException();
    }
}

The host's app.config :

 <system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="serviceBehavior">
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="serviceBehavior" name="HelloIndigo">
          <host>
            <baseAddresses>
              <add baseAddress="http://localhost:8000" />
            </baseAddresses>
          </host>
          <endpoint address="HelloIndigoService" binding="basicHttpBinding"
                 name="basicHttp" contract="Host.IHelloIndigo" />
            <endpoint binding="mexHttpBinding"  name="mex"
                contract="IMetadataExchange" />                
        </service>
    </services>
</system.serviceModel>
  • This solution was rebuilt from an vs2008 to vs2010 I changed the framework to 4.0 in both projects client and host .
  • The configurations were made by the wcf configuration wizard.

Any idea why the client project can't locate the host end point to retrieve the metadata ?

Thanks in advance.

I had the same issue while revising an existing web odata service and then attempting to establish a new service reference to the revised service in a Silverlight project. By temporarily commenting out the authentication and authorization sections in the web.config file I was able to connect to and download the metadata from the data service to my Silverlight project. Rick Moulton

This is probably that the service is not running.

It could also be that port 8000 is blocked.

Edit:

Based on your comment that the discover does not work within the same solution: This means that something is wrong with the project type.

Thry to create a new WCF project, add the services you need, then copy over your existing code.

I was trying to do the same thing you were, adding a service reference only to run into a connection error because the current service wasn't running.

In order to pull this trick off, you need to open two Visual Studio Instances and use one to first Open the "Add Service Reference" Menu. With the menu open, in your other Visual Studio, debug your application so that your service is running.

While the service is running enter the address in the "Add Service Reference" menu and it WILL find your URL listening service. Only then can you select the interface or class you wish to reference.

After that's done you can stop the debugging and the changes will take effect. You may get a warning that your project was modified outside the editor just click OK and you'll be good.

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