WCF Service WindowsPhone - EndpointNotFoundException - wcf

I'm developing solution within WCF Service and Windows Phone client application. The problem is I cannot connect to service even that in emulator when I type address of service in Internet Explorer I get right result.
My config file:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyCustomService"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
enableHttpCookieContainer="true"
/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2395/MyCustomService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyCustomService"
contract="MyService.IMyCustomService" name="BasicHttpBinding_IMyCustomService" />
</client>
</system.serviceModel>
</configuration>
My service interface:
[ServiceContract]
[ServiceKnownType(typeof(CustomResponse))]
public interface IMyCustomService
{
[OperationContract]
CustomResponse GetData();
}
My Problem is that each time i try to call on client proxy GetDataAsync() method, the completed event is not fire up and I get "EndpointNotFoundException". I've tried all solution which I found and none of them helped me. I also try to make WPF test client and it works correctly but Windows Phone app does not.

I assume this is your client configuration, e.g. the phone. Your pointing to localhost, but since you´re in the emulator on the phone localhost resolves to the same, not your PC where the service is hosted.
address="http://localhost:2395/MyCustomService.svc"
Put your PC´s hostname in there and you should be fine

Hm, I have no idea how it started work but it did. I upload my service to internet hosting and delete all service reference from my phone client project and add them again with internet address and it works now. Thx for your help Dominik.

Related

why changing wcf endpoint address in code seems doesn't work?

We have some really legacy wcf code and we got a strange problem:
WCFChartService.ChartServiceClient service = new WCFChartService.ChartServiceClient();
using (new OperationContextScope(service.InnerChannel))
{
service.Endpoint.Address = new System.ServiceModel.EndpointAddress(
"http://mypreprodsite.net/MyChartService.svc");
service.UpdateChartTemplate(
xxxx);
}
In web.config, we have:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IChartService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myprodsite.net/MyChartService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IChartService"
contract="WCFChartService.IChartService" name="BasicHttpBinding_IChartService" />
</client>
</system.serviceModel>
Above code throws some error, so I debugged this, and turned out if in my web.config I have this everything will be fine
<endpoint address="http://mypreprodsite.net/MyChartService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IChartService"
contract="WCFChartService.IChartService" name="BasicHttpBinding_IChartService" />
The function change in wcf has only been deployed to preprod site, so looks like in my testing project, changing url directly in service.Endpoint.Address doesn't work as I expected.
As I moved away from old wcf code years ago (only randomly got assigned to look this one), can someone explain why? If I set service.Endpoint.Address="localhost:8049/MyChartService.svc" and my local machine does get called, so I am rather confused.
There are two ways to specify endpoint addresses for a service in WCF. You can specify an absolute address for each endpoint associated with the service or you can provide a base address for the ServiceHost of a service and then specify an address for each endpoint associated with this service that is defined relative to this base address.
Here is the reference: Specifying an Endpoint Address.

"No Endpoint Listening” in WCF Service Hosted in external Windows Service

I'm working on some code refactoring within an existing application.
The application is already hosted and it works fine.
I have WCF services hosted by an external Windows service.
Indeed, I'm working locally and I'm trying to test some code implementations in the Pre prod environment.
So, this is the proxy configuration within the basicHttpBinding code:
<bindings>
<basicHttpBinding>
<!--proxy configuration must be provided-->
<binding name="BindingTimeSheet" maxReceivedMessageSize="6000000" useDefaultWebProxy="false" proxyAddress="http://xxx.xxx.x.x:xxxx" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00">
<readerQuotas />
<security mode="Transport">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
</basicHttpBinding>
</bindings>
and this is project server endpoint configuration:
<client>
<endpoint address="https://xxxxxxxxxx.asmx" binding="basicHttpBinding" bindingConfiguration="BindingTimeSheet" contract="ProxyClientJeanDoe.JeanDoeSoap" name="JeanDoeSoap" />
</client>
I'm receiving this exceptions:
Inner Exception 1: EndpointNotFoundException: There was no listening
endpoint on https://xxxxxxx.asmx that could accept the message. This
is often due to an incorrect address or SOAP action. If present, see
the InnerException element for more information.
Inner Exception 2: WebException: Can not connect to remote server
Inner Exception 3: SocketException: A connection attempt failed
because the connected party did not respond properly after a certain
amount of time or an established connection failed because the login
host did not respond xxx.xxx.xx.x:xxxx
I have tested the WSDL services and they are working fine but the proxy address is not responding
I have already tried to set the anonymous authentication enabled and I'm working in a local machine where the Internet connection is using a proxy server and it's impossible to configure the firewall for Security reasons.
thanks for your understanding
Finally, The problem was related with the BypassProxyOnLocal flag.
It was enabled so the requests to local Internet resources was not using the proxy server.
This configuration placed into the Web.config works fine.
<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy usesystemdefault="True" proxyaddress="http://xxxxxxxxxxx:8080"
bypassonlocal="False"/>
</defaultProxy>
</system.net>
Thank you.

How do I set the proxy in webhttpbinding configuration to use fiddler

I'm trying to setup my Web service client to use fiddler proxy by setting it in the webhttpbinding configuration file as follows:
<bindings>
<webHttpBinding>
<binding name="RestBinding" proxyAddress="http://localhost:8888"
useDefaultWebProxy="false">
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2172/RestServiceImpl.svc"
binding="webHttpBinding" behaviorConfiguration="RestService"
bindingConfiguration="RestBinding"
contract="IWS.IRestServiceImpl" name="Rest"/>
</client>
This doesn't seem to work. I don't see anything logged in fiddler when calling the webservice from the client. I know the call is being made because I get a response back from the service.
I can't seem to figure out what I'm doing wrong.
Any help is appreciated!
Thanks!!
The .NET Framework does not send requests for "localhost" to any proxy, including Fiddler. To workaround this, try to use your machine name instead as the endpoint address (e.g. http://mymachine:2172/RestServiceImpl.svc).
Also, take a look on Using Fiddler with IIS7 Express

WP7 + WCF Service: There was no endpoint listening at (URL) that could accept the message

I'm trying to develop a Windows Phone application that uses a WCF Service. I'm doing it as decribed here:
http://www.c-sharpcorner.com/UploadFile/raj1979/5280/
(of course I use my own tables from the DB). The problem is:
I'm debugging the Class Library project containing the WCF service (to see if some of its methods are invoked properly)
after the method returns an entity I see the error: There was no endpoint listening at http://localhost:1708/Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The InnerException is The remote server returned an error: NotFound.
the ServiceReferences.ClientConfig in the Windows Phone application:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1708/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
I don't know how to solve it. Any ideas ? I tried many answers from that site but none worked
What about Silverlight-enabled WCF service on the server side? It it based on CustomBinding instead of basicHttpBinding.
You must change in ServiceReferences.ClientConfig in your Windows Phone Emulator endpoint address from localhost to
yourComputerName. Thats all:) It works

WCF Security - how to allow all callers to this url?

I have a WCF service self-hosted in a windows service environment that works fine over http; over https I am unable to get to one URL without seeing the windows login prompt when running the silverlight application (or just opening the page in IE). I am using the IPolicyRetriever interface to ensure that the ClientAccessPolicy.xml file is found for the Silverlight app. This is working correctly.
The service in question has two endpoints defined:
<service behaviorConfiguration="defaultBehavior" name="WCFServices.Scheduler">
<endpoint address="WCFServices/Scheduler/" binding="wsHttpBinding" bindingConfiguration="dBinding" contract="WCFServices.IScheduler" />
<endpoint address="" binding="webHttpBinding" contract="WCFServices.IPolicyRetriever" behaviorConfiguration="PolicyBehavior" bindingConfiguration="dBinding" />
<host>
<baseAddresses>
<add baseAddress="https://myservername.org/" />
</baseAddresses>
</host>
</service>
If I go to the https://myservername.org/ I see the test service frontend (with a link to the wsdl). This is exposing the root IPolicyRetriever instance that the Silverlight app uses to pull down the policy file. I can load this and other URLs that expose the WCF service without any login prompts. BUT if I go to https://myservername.org/WCFServices/Scheduler/ in IE 8 I am greeted with a windows login. If I reset the security settings on the service and client to use http, I am able to do go to the latter url without the login prompt, and the silverlight app functions as expected. I suspect it has something to do with this WCF service being the only one with two endpoints defined (this windows service hosts 5 other WCF services, all of which only have 1 endpoint defined). Am I missing some authorization rules? I don't understand how that can be because all the other services load without prompts.
I would appreciate any help. I need the full https://myservername.org/WCFServices/Scheduler/ to serve the WCF service without asking for a login. Thanks for taking the time to read this.
As far as security, I only have this as my binding:
<binding name="dBinding" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600">
<security mode="Transport">
</security>
</binding>
This issue was resolved by adding these lines to my security binding:
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"/>
</security>
...but that led to a host of other issues, all of which I've been able to handle thanks to WCF logging. If you run into a NOT FOUND (400) error when debugging your WCF service, don't believe it. Turn on server side debugging and pour through the generated log files -- you'll get to the bottom of it.
I should also note that I've found the second endpoint to return a bad request (400) when opening in a web browser, and this is BY DESIGN. The first endpoint will list all additional endpoints in its wsdl, and you can still use any of them in a proxy generating tool. Don't worry if you're getting a bad request error when trying to access them directly in a browser.