Click here to Skip to main content
15,886,077 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Guys,

I'm getting an error in my WebClient solution, while accessing the wcf service (which is running perfectly)
My wcf service config file looks like:-
<pre><configuration>  
  <system.serviceModel>
    <services>
      <service name="HelloService.HelloService" behaviorConfiguration="mexBehavior">
        <endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService">          
        </endpoint>
        <endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService">          
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">          
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/HelloService"/>
            <add baseAddress="net.tcp://localhost:8090/HelloService"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexBehavior">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>


and in my webclients solution inside web.config file looks like:-
<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0" />
    </system.web>

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IHelloService" />
            </basicHttpBinding>
            <netTcpBinding>
                <binding name="NetTcpBinding_IHelloService" />
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8080/HelloService" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IHelloService" contract="HelloService.IHelloService"
                name="BasicHttpBinding_IHelloService" />
            <endpoint address="net.tcp://localhost:8090/HelloService" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IHelloService" contract="HelloService.IHelloService"
                name="NetTcpBinding_IHelloService">
                <identity>
                    <userPrincipalName value="Xyz-PC\Xyz" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>


I don't figure it out, where I'm doing wrong. But my wcf service is calling perfectly. And also I open the link "http://localhost:8080/HelloService" shows me the service. But unable to find out why the Client solution shows no endpoint listening error.

The way I'm calling the endpoint in my WebForm1.aspx.cs file inside client solution be looks like:-
protected void Button1_Click(object sender, EventArgs e)
{
HelloService.HelloServiceClient client = new HelloService.HelloServiceClient("BasicHttpBinding_IHelloService");
Label1.Text = client.GetMessage(TextBox1.Text);
}

Any help is greatly appreciable.
If any doubt, feel free to ask me

Thanks


What I have tried:

Create the service which is working fine as I'm testing on the console app.

Calling that service inside web client solution particularly ASP.NET empty web Application. throws me the error.

Google a lot but not figure out the particular reason
Posted
Comments
Richard Deeming 14-Jun-17 17:29pm    
Are the service and client running on the same computer?

Have you tried removing "HelloService" from the end of the base address in the service config?
binadi007 14-Jun-17 19:57pm    
Both are running on the same computer.
Yeah I removed the "HelloService" from the end of the base address but it didn't work as well
binadi007 14-Jun-17 22:28pm    
It showing me error like this:-

The remote server returned an error: (404) Not Found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (404) Not Found.

Source Error:


Line 48:
Line 49: public string GetMessage(string name) {
Line 50: return base.Channel.GetMessage(name);
Line 51: }
Line 52: }

Source File: d:\HelloWebClient\Service References\ServiceReference1\Reference.cs Line: 50

Stack Trace:


[WebException: The remote server returned an error: (404) Not Found.]
System.Net.HttpWebRequest.GetResponse() +6592536
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +55

[EndpointNotFoundException: There was no endpoint listening at http://localhost:8080/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10733331
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +336
HelloWebClient.ServiceReference1.IHelloService.GetMessage(String name) +0
HelloWebClient.ServiceReference1.HelloServiceClient.GetMessage(String name) in d:\HelloWebClient\Service References\ServiceReference1\Reference.cs:50
HelloWebClient.WebForm1.Button1_Click(Object sender, EventArgs e) in d:\HelloWebClient\WebForm1.aspx.cs:20
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9750842
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +196
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
Richard Deeming 15-Jun-17 6:58am    
Are you hosting the service in IIS?
binadi007 15-Jun-17 8:46am    
No

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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