tags:

views:

30

answers:

3

I built up a WCF service, it works good in IE addr, but once i add it to wcftestclient and invoke a method, an error was prompted and shown as :

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.

Error Details:

The Address property on ChannelFactory.Endpoint was null.  The ChannelFactory's Endpoint must have a valid Address specified.
   at System.ServiceModel.ChannelFactory.CreateEndpointAddress(ServiceEndpoint endpoint)
   at System.ServiceModel.ChannelFactory`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannelInternal()
   at System.ServiceModel.ClientBase`1.get_Channel()
   at MyDownloadSvcClient.DeleteMyFolder(Int32 UserId, Int32 FolderId)

The config file is: (updated at 10/9)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="MyDownloadSvcClient">
                <endpoint binding="basicHttpBinding" />
            </service>
        </services>
        <bindings />
        <client>
            <endpoint address="http://localhost/MyDownloadSvc.svc"
                binding="basicHttpBinding" bindingConfiguration="" contract="IMyDownloadSvc"
                name="Test" />
        </client>
    </system.serviceModel>
</configuration>

Is there anything wrong?

Thanks in advance, Elaine

A: 

Why are you using custom binding? You have not defined a protocol or based your binding on an existing binding. Just use plain basicHttpBinding.

   <client> 
            <endpoint binding="basicHttpBinding"  contract="IMyDownloadSvc" name="WebHttpBinding_IMyDownloadSvc" address="http://....." /> 
        </client> 

You need to put the address as well.

Aliostad
there are two nodes within system.serviceModel, but wcftestclient only retrieved this section, this one was actually generated when I added the wcf service reference in visual studio 2008. I even cannot update it, I updated web.config, and 'Refresh', but the default.config is still the same.
Elaine
Put your service binding up here and I will give you the binding for client.
Aliostad
I changed the config to `<?xml version="1.0" encoding="utf-8"?><configuration> <system.serviceModel> <bindings /> <client> <endpoint binding="basicHttpBinding" bindingConfiguration="" contract="IMyDownloadSvc" name="WebHttpBinding_IMyDownloadSvc"> <identity> <dns value="localhost" /> </identity> </endpoint> </client> </system.serviceModel></configuration>` still the same
Elaine
@Elaine: please **do not** post config and code into comments - it's **really hard** to read.... update your original question by editing it to provide more detail - thank you
marc_s
Look at my update
Aliostad
@marc_s, I updated my post - config section. please check it, thx.
Elaine
@Aliostad, how about my update? I tried ever that, but failed.
Elaine
A: 

Your service works from IE and your binding name on client after creating service reference starts with WebHttpBinding_. So you are using REST service, aren't you? Such service cannot be added as service reference and such service is not supported in WcfTestClient.

Ladislav Mrnka
@mrmka, thx, how about now? what serivce that wcftestclient supports?
Elaine
Test client supports only limited feature set of SOAP services. Check Features supported: http://msdn.microsoft.com/en-us/library/bb552364.aspx
Ladislav Mrnka
+1  A: 

Yes, there's definitely something wrong. A service endpoint WCF must always supply the ABC - Address, Binding, Contract. You only define the binding in your config - and that's exactly what the error message says - your address is null.

So your config fragment should look something like:

<system.serviceModel>
    <services>
        <service name="MyDownloadSvcClient">
            <endpoint 
                address="http://localhost:8888/YourService"
                binding="basicHttpBinding"
                contract="IYourServiceContract" />
        </service>
    </services>

The Address defines where the service endpoint lives, at what address it's available to the outside world. If you have no address, then the service cannot talk to the outside where. It's there WHERE of your service. If you host your service in IIS, using a *.svc file, you might be leaving this address empty, since the service address is determined by the server and virtual directory where the *.svc file lives - but you still need to supply an address="" entry to your service <service>/<endpoint> tag!

The Binding defines how the service interacts - what protocol, what security settings etc. - it's the HOW of your service.

And the Contract in the end defines (through a service contract, typically an interface in your service definition) what service methods (functions) are available to a caller. You must supply a contract, otherwise the caller has no way of knowing what methods he can call on your service. It's the WHAT of the service.

marc_s