How does VS2010 Configure Service Reference deal with localhost? - wcf

I go and setup a service reference to something like
http://localhost/myService/test.svc
However, it apparently does some magic and in the *.disco file (and elsewhere) it ends up with
http://mymachine.mydomain.com/myService/test.svc
I'm trying to understand why this happens.
Update: It seems they're trying to "help" but the IDE continues to give you the impression that you're connecting to localhost. In 99.9% of cases, it probably works out fine. In my case, I'm connecting to a service which checks its licenses against the domain name. Running against "localhost" is to be used for dev and test purposes.
The relevant portion of the *.config file ends up like this:
<system.serviceModel>
<client>
<endpoint address="http://mymachine.mydomain.com/myService/test.svc/Account"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IAccount"
contract="ServiceReference1.IAccount"
name="WSHttpBinding_IAccount">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>

Related

net.tcp Windows Service - Test Client Error Hell: System.ServiceModel.AddressAlreadyInUseException

I have a service I wrote and deployed in the service.msc list of services. I then wrote a test client to test some of the features. The basic 'first' attempt worked perfect. The issue is when I went back and added new operations I keep getting the following Error:
System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:8080. This could happen if there is another application already listening on this endpoint or if you have multiple service endpoints in your service host with the same IP endpoint but with incompatible binding configurations. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.ServiceModel.Channels.SocketConnectionListener.Listen()
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SocketConnectionListener.Listen()
at System.ServiceModel.Channels.ConnectionAcceptor.StartAccepting()
at System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen()
The process I have followed is listed below:
I stopped the service to free up the .exe file.
I used 'installutil /u ...' to uninstall my service.
I added the features needed to the service library.
I rebuilt the library, then the Windows Service.
I used 'installutil ...' to install service.
I used service.msc to start the service (which is Autostart).
I try to update the service reference to the TestClient and Boom - Error.
I did steps 1-7 again, but this time changing the /mex and default service addresses to use different ports (per: http://msdn.microsoft.com/en-us/library/aa702636.aspx
Did step 7 again and Boom - Error Again
I tweaked and piddled with the service several times over again, rewrote the client, etc. Nothing seems to work. Funny thing is it worked fine the first try, now there are issues. I have already ensured that my service is the only one on it's port using 'netstat -aon' and 'tasgmgr.exe'. These all look fine. The host runs, everything up to the test client is fine. Now the end points use different ports so the TCP Mex issue should be solved according to online documentation. Am I missing something here? I was able to generate a proxy using 'svcutil' and I ensured the App.Config data does not conflict.
Below is the App.Config data (as I am using configuration files):
HOST App.Config (service):
<service name="SomeServiceLib.SomeService">
<endpoint address="net.tcp://localhost:8080/SomeService" binding="netTcpBinding" contract="SomeServiceLib.ISomeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8081/SomeService/mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- NOTE: If net.tcp, must set each to false to avoid exception -->
<serviceMetadata httpGetEnabled="False" httpsGetEnabled="False"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
CLIENT App.Config:
<client>
<endpoint address="net.tcp://localhost:8080/SomeService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_SomeService"
contract="SomeService"
name="Svc_DefaultEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8081/SomeService/mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
name="Svc_MexEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_SomeService" />
</netTcpBinding>
</bindings>
...

How to configure WCF service endpoint for a third party client

I develop a WCF service (3.5) in VS 2010. Generally I am able to test it via the WCF Test Client and call the service from any browser. I'm on my Windows 7 development machine, so everything is default. The address is like http://localhost:54538/MyService.svc
However, when I try to call the service from a third party client (which in the end is my target), the client gets no response at all. The response is just empty. I also tried to call the service by PHP curl from a local Apache webserver - also an empty response.
So I think there might be a problem with the configuration. The services part is:
<services>
<service behaviorConfiguration="MyNamespace.Service1Behavior" name="MyNamespace.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyNamespace.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Do I have to add an endpoint or change anything else?
So the solution I found (based on #marc_s' comment) is adding another endpoint as webHttpBinding:
<endpoint address="rest" binding="webHttpBinding" contract="MyNamespace.IMyCometService" bindingConfiguration="UnsecuredWeb">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
Then calling the service from the third party software via http://localhost:54538/MyService.svc/rest

WCF Net.Pipe Endpoint

On our build server, we have a service that calls another service on the same box via net.pipe, but it is failing saying that there is no endpoint listening to net.pipe. IIS does have Net.pipe set for both the calling and called service.
<endpoint address="net.pipe://build.QQQQQ.com/QQQ/QQQ.svc"
binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IMembershipService"
contract="QQQ.IMembershipService" name="NetNamedPipeBinding_IMembershipService">
<identity>
<servicePrincipalName value="host/ABCDF.XX.net" />
</identity>
</endpoint>
Note: build.QQQ.com is actually ABCDF.XX.net. is that the problem, do they need to match even though they are the same.
IMO - they should much.
I'd try to remove last "/QQQ.svc" from address.

WCF Service for HTML5 and Silverlight

My WCF service has two endpoints(Normal and REST, one for Silverlight client and other for HTML5 client) and my Silverlight client application works perfectly without any issues. When I open my service in the IE, I am getting HTTP 400 bad request. It looks like REST part of my service has some issue. I have given both end points below. Appreciate any help!
Normal end point
<endpoint address="" binding="basicHttpBinding" contract="Test.Service1"
bindingConfiguration="BasicHttpBinding_Config"
behaviorConfiguration="MessageInspectorEndpointBehavior">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
WCF end point
<endpoint address="rest" binding="webHttpBinding" contract="Test.Service1"
behaviorConfiguration="web">
</endpoint>
The request should be made to .../WCF/Test/Service1.svc/rest, since this is the address for the REST endpoint you added in config.

WCF URL Question

I'm somewhat new to web development, so I'm unsure of the terminology to use here. I have a wcf web service that I've build for windows azure. I would like to have multiple endpoints that resolve to the same service, however I'm not entirely sure how to configure this.
This may help explain what I'm wanting a little better:
Currently, I have a service at https://myapp.cloudapp.net/service.svc
I would like to have the following url point to the same service in the application:
https://myapp.cloudapp.net/myapp/service.svc
I'm sure this is something easy to do, I just haven't been able to find a solution yet.
Edit:
I found this documentation on MSDN:
http://msdn.microsoft.com/en-us/library/ms734786.aspx
However, I can't seem to get it to work.
Here is is how my endpoint is defined in my web.config:
<services>
<service behaviorConfiguration="MetadataEnabled" name="myProject.myApp.myService">
<host>
<baseAddresses>
<add baseAddress="https://localhost/myService/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsBinding" name="wsBase" contract="myProj.myApp.IServ" />
<endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration="mexBinding" name="HttpMetadata" contract="IMetadataExchange" />
<endpoint address="myApp/" binding="wsHttpBinding" bindingConfiguration="wsBinding" name="WsPlain" contract="myProj.myApp.IServ" />
</service>
</services>
It's still not working, but hopefully it's getting close. Would love any suggestions!
I just found out the answer. I just needed to create a folder in the project "myApp", and make copy the .svc file (not the .svc.cs file) to that folder. This allowed the following to work:
myapp.cloudapp.net/service.svc
myapp.cloudapp.net/myapp/service.svc
This is trivial and probably you already do, but are you defining InputEndpoints in ServiceDefinition.csdef?
There's a WCF Routing Service that might be of use (or might be overkill).
See also Supporting Multiple IIS Site Bindings and Endpoint Addresses.