System.ServiceModel.EndpointNotFoundException: There was no endpoint listening

0

I have a new WPF project in Visual Studio. I want to connect to this url: "http://www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL".

I have made a Service Reference.

When I run it, I get this error (I have translated the text to English):

System.ServiceModel.EndpointNotFoundException
  HResult=0x80131501
  Message=There was no endpoint listening at http://www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso, that can accept the message. This is often because of a wrong address or SOAP-action. Find more information at InnerException.
  Source=mscorlib
  StackTrace:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at ContactCountry.CountryConverter.CountryInfoServiceSoapType.CapitalCity(CapitalCityRequest request)
   at ContactCountry.CountryConverter.CountryInfoServiceSoapTypeClient.ContactCountry.CountryConverter.CountryInfoServiceSoapType.CapitalCity(CapitalCityRequest request) in K:\Dokumenter\Programmer\ContactCountry\ContactCountry\Connected Services\CountryConverter\Reference.cs:line 2235
   at ContactCountry.CountryConverter.CountryInfoServiceSoapTypeClient.CapitalCity(String sCountryISOCode) in K:\Dokumenter\Programmer\ContactCountry\ContactCountry\Connected Services\CountryConverter\Reference.cs:line 2242
   at ContactCountry.MainWindow..ctor() in K:\Dokumenter\Programmer\ContactCountry\ContactCountry\MainWindow.xaml.cs:line 29

Inner Exception 1:
WebException: The underlying connection was closed: Cannot connect to remote server.

Inner Exception 2:
SocketException: There was given an illegal argument

The url works fine with Widzler in Google Chrome.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ContactCountry
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            CountryConverter.CountryInfoServiceSoapTypeClient client = new CountryConverter.CountryInfoServiceSoapTypeClient("CountryInfoServiceSoap");

            myTextBox.Text = client.CapitalCity("US");
        }
    }
}

app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>

  <system.net>
    <defaultProxy enabled="false" useDefaultCredentials="false">
    </defaultProxy>
  </system.net>

  <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="CountryInfoServiceSoapBinding" />
            </basicHttpBinding>
            <customBinding>
                <binding name="CountryInfoServiceSoapBinding12">
                    <textMessageEncoding messageVersion="Soap12" />
                    <httpTransport />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"
                binding="basicHttpBinding" bindingConfiguration="CountryInfoServiceSoapBinding"
                contract="CountryConverter.CountryInfoServiceSoapType" name="CountryInfoServiceSoap" />
            <endpoint address="http://www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"
                binding="customBinding" bindingConfiguration="CountryInfoServiceSoapBinding12"
                contract="CountryConverter.CountryInfoServiceSoapType" name="CountryInfoServiceSoap12" />
        </client>
    </system.serviceModel>
</configuration>
c#
wcf
service-reference
asked on Stack Overflow Nov 19, 2019 by Morten • edited Nov 19, 2019 by Ufuk Hacıoğulları

2 Answers

1

I have found out that the problem is that my Visual Studio solution is on a network drive (that Windows knows as "K"). When I moved the solution to C drive, it works perfectly.

Thanks for your time!

answered on Stack Overflow Nov 27, 2019 by Morten
0

After I create a new console and test the URL you provided, it works well.
The code segments of calling the service are the same as what you have posted above, including the service endpoint in the Appconfig file.
Result.
enter image description here
Both endpoints work properly, I even test the endpoint with custom binding.

ServiceReference1.CountryInfoServiceSoapTypeClient client = new
ServiceReference1.CountryInfoServiceSoapTypeClient("CountryInfoServiceSoap12");
MyLabel.Content = client.CapitalCity("US");

Therefore, I suspect there is something wrong with your local network connectivity.
I suggest you close the local firewall, anti-virus software, local Hosts file, pinpoint the issue by using the Ping command, check whether we can access the URL in the browser in that machine.
Feel free to let me know if the problem still exists.  

answered on Stack Overflow Nov 20, 2019 by Abraham Qian

User contributions licensed under CC BY-SA 3.0