Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ALL,
I am getting the following error and I am not sure what I am doing wrong. Does anybody see anything obvious? Below are my project's Web.config and my reference link in code behind.


My error is:

The Address property on ChannelFactory.Endpoint was null.  The ChannelFactory's Endpoint must have a valid Address specified.


My web.config:

<system.serviceModel>
    <services>
      <service behaviorConfiguration="WcfService3._5.Service1Behavior"
        name="WcfService3._5.Service1">
        <endpoint address="" binding="basicHttpBinding" contract="WcfService3._5.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="WcfService3._5.LoginBehavior"
        name="WcfService3._5.Login">
        <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="WcfService3._5.ILogin">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:63460/Login"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="WcfService3._5.Service1Behavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="WcfService3._5.LoginBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>


My code behind is :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string res;

string strXmlRequest = string.Empty;
strXmlRequest = "<root><loginapi><username>wsadmin<password>pass<sessionid>b5uwdafp4u5wkxmq0ksmqa55";
// convert string to stream
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(strXmlRequest);

MemoryStream stream = new MemoryStream(byteArray);

api5.LoginClient ap = new api5.LoginClient();

res = ap.POSTLogin(stream);
}

}

Please drop me a solution for this.

thanks in advance.

What I have tried:

The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified
Posted
Updated 31-Jan-17 0:07am

1 solution

You have not populated address field for endpoint, You just populated base address. Check below URL you will understand what I am referring to.

what is the use of base address in WCF service - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900