azamsharp
azamsharp

Reputation: 20076

WCF Error: The address property on ChannelFactory.Endpoint was null

I created a console application which is serving as a WCF client. The app.config consists of the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="WebHttpBinding_IWebContentService">
                    <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                        messageVersion="Soap12" writeEncoding="utf-8">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    </textMessageEncoding>
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:1252/SomeService.svc" binding="customBinding" bindingConfiguration="WebHttpBinding_IWebContentService"
                contract="WebContentClient.IWebContentService" name="WebHttpBinding_IWebContentService" />

        </client>


    </system.serviceModel>
</configuration>

When I run it I get the following error:

The address property on ChannelFactory.Endpoint was null 

The endpoint element has an address property but I am not sure what I am suppose to assign that property. I am running my web service on localhost.

UPDATE 1:

I added the address and I have updated the original code. But I get the error back saying that There was no endpoint listening to the address="http://localhost:1252/SomeService.svc". If I visit the wcf url I can see the web service.

Upvotes: 0

Views: 4843

Answers (2)

Cybermaxs
Cybermaxs

Reputation: 24558

The configuration of your custombinding is incorrect. You should specify a transport element like httptransport.

Here is an example of a valid configuration :

<customBinding>
    <binding name="myCustomHttpBinding">
        <textMessageEncoding />
        <httpTransport / >
    </binding >    
</customBinding >

Why are you using a custom binding ? depending on the service, there are many bindings (basicHttpBinding, webHttpBinding, ...) easier to use.

Note : I think your client code is incorrect too because of the exception.

Upvotes: 2

to StackOverflow
to StackOverflow

Reputation: 124726

You need to assign it to the address of the web service. If it's a WCF web service on localhost it will probably be of the form:

http://localhost[:port]/<path>/SomeService.svc

Upvotes: 0

Related Questions