Adding webHttpBinding endpoint to an existing netTcpBinding - wcf

I have a working service which exposing netTcpBinding at the following way:
<service name="MetaData.Service.MetaDataServices" behaviorConfiguration="MetaDataServiceBehavior">
<endpoint address="net.tcp://localhost:5200/MetaDataService" binding="netTcpBinding" bindingConfiguration="MetaDataBinding" contract="MetaData.ServiceContract.IMetaDataService"/>
</service>
How can I add http endpoint? I tried the following:
<service name="MetaData.Service.MetaDataServices" behaviorConfiguration="MetaDataServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:5280/MetaDataService"/>
</baseAddresses>
</host>
<endpoint address="net.tcp://localhost:5200/MetaDataService" binding="netTcpBinding" bindingConfiguration="MetaDataBinding" contract="MetaData.ServiceContract.IMetaDataService"/>
<endpoint address="" binding="webHttpBinding" contract="MetaData.ServiceContract.IMetaDataService"/>
</service>
</services>
but got an exception:
HTTP could not register URL http://+:5280/MetaDataService/. Your
process does not have access rights to this namespace (see
http://go.microsoft.com/fwlink/?LinkId=70353 for details). class name:
RemoteProxy method name: Create

Unless you're running the self-hosted process as an administrator (which I'm guessing is not the case, and you have a good reason for that), you won't be able to start listening to HTTP requests in the machine. You'll need to use an administrator command prompt to grant access to your user account to do that, by following the instructions in the page linked in the error message (the link was broken, but it has just been fixed).
If you are running Windows 7/8/10/Vista/Server 2008, you can use the following command (from an administrator command prompt):
netsh http add urlacl url=http://+:5280/MetaDataService/ user=DOMAIN\user
Where DOMAIN\user is the user account you're running the process as. You can find it by using the command whoami in the command prompt.
Once you do that (only once per machine), then you should be able to run it with a non-admin account.

Related

The server has rejected the client credentials, duplex wcf service

I host a wcf service with tcp binding on a windows service. It works correctly on our LAN, however when the users wanna connect to the service from internet, they get the following error:
The server has rejected the client credentials
this is my service config:
service behaviorConfiguration="WcfServiceLibrary1.Service1Behavior"
name="LivePushServiceLib.SubscribeService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="WCF_Interface.ISubscribeService">
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://188.x.x.x:8524/SubscribeService.svc" />
</baseAddresses>
</host>
</service>
</services>
You are using default security with NetTcpBinding which is Windows. In your LAN I assume everyone is using Windows credentials quite happily. However, people from the Internet are unlikely to have credentials on your domain
If you want to use this across the Internet look at setting security to something like TransportWithMessageCredential and then use a credential type of username. This allows Internet based clients to authenticate with a user name which you can validate in a custom UsernamePasswordValidator

Wcf bindings difference while hosting on windows azure

I have wcf service application which i host on IIS and runs very well.
now i need to transfer the services to windows azure where i host them into web role.
i am not sure but i have heard that there are different bindings for windows azure
example:
azure has different bindings equivalent to basicHttp,WebHttp.
can i know what exactly i need to do to achieve the same.
here is my current service configuration
<service behaviorConfiguration="mybehavior" name="***">
<endpoint address="mobile" behaviorConfiguration="web" binding="webHttpBinding"
contract="*" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://127.0.0.1:81/Mobile.svc" />
</baseAddresses>
</host>
</service>
what change does this need
Thanks
You can achieve your goal with web.config transofmrations (and here). The issue with Azure is that there is no localhost, nor 127.0.0.1 there (well, there might be, but nothing is being routed to that local loop address). All you have to do is to change the baseAddress.
In order to change the baseAddress you may do any of the following:
use web.config transofmrations and in your web.Release.config put your azure domain name in the base address (http://yourapp.cloudapp.net/, or your custom domain if you are using one)
programatically bind the wcf service using the DIP of the role instance (check this and that questions for more information)

netsh does not work for AddressAccessDeniedException: HTTP could not register URL

When another developer tried to run the service through vs 2010, they received the error:
Please try changing the HTTP port to 88 or running as Administrator.
System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http://+:88/ColorService/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). ---> System.Net.HttpListenerException: Access is denied
After doing some searches and going the the link Microsoft specified, I had them run the following command:
netsh http add urlacl url=http://+:88/ColorService user=BUILTIN\Administrators
The error still came up, so I also had them run the command with their Domain\User
netsh http add urlacl url=http://+:88/ColorService user=DOMAIN\User
The above still didn't work, so I found a tool at the following link to give that a try and give access to NT Authority\Interactive, but that didn't work either.
I finally reverted back to giving each endpoint a base address of:
http:\\localhost:8732\Design_Time_Addresses\ColorService and it worked after this.
Why won't it work with the other base addresses?
I also did not have any dns Nodes within each endpoint, does this matter? What is this used for? I added it back as:
<Host>
<dns>localhost<dns/>
</Host>
I had this error. I had it configured in the app.config with endpoints like:
<host>
<baseAddresses>
<add baseAddress="http://ttintlonape01:6970/janus/data" />
</baseAddresses>
...but it was coming up with the http://+:80/janus/data which you got.
Turned out WCF puts in an endpoint automatically (not sure when) - adding <clear /> to the config fixed it. I.e.
<service behaviorConfiguration="ServiceBehavior" name="TT.Janus.Service.DataProvider">
<clear />
<endpoint address="net.tcp://ttintlonape01/janus/data" binding="netTcpBinding"
bindingConfiguration="NoSecurityBinding" contract="TT.Janus.Service.IDataProvider" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://ttintlonape01:6969/janus/data" />
</baseAddresses>
</host>

Unit Testing WCF ServiceHost fails within a TFS Integration Build

I have a problem related to creating an instance of a WCF ServiceHost withing a set of unit tests and a project that is build within an integration build in TFSBuild. The code used in the unit test is:
[TestMethod]
public void Service_Can_Be_Dynamically_Hosted()
{
ServiceHost host = new ServiceHost(typeof(DiscoveryService));
host.Open();
host.Close();
}
The configuration for the service, although it can be created through code directly, is located in an .config file containing the following details:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="TappingBoard.Core.Network.DiscoveryServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="TappingBoard.Core.Network.DiscoveryServiceBehavior"
name="TappingBoard.Core.Network.Services.DiscoveryService">
<endpoint address="" binding="wsHttpBinding" contract="TappingBoard.Core.Network.Services.IDiscoveryService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/TappingBoard/DiscoveryService/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
The unit test is working perfectly in the client machines with both administrator users and non-admin users executing the tests locally. In the case of the TFS Build Server, the user that is launching the Build is called TFSBuild and is member of Domain Users and a local Administrator in the TFS Build Server.
Executing the same unit test in the Build Server launches the following exception:
System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http://+:8001/TappingBoard/DiscoveryService/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). ---> System.Net.HttpListenerException: Access is denied
As the TFS Build Server is using port 80 to expose some reports and webs over IIS, I changed the port to be used by the WCF Service to 8001. It didn't worked before with port 80 either.
Is there any option to have this test run on the TFS Build Server? Should I configure anything extra on my build?
In terms of providing the most useful information, the systems used are:
Dev Machines: VS2010TS, Windows 7RTM
Server Machines: TFS2010, Windows Server 2008 R2 RTM
Thanks in advance for your time and support.
Bests,
Miguel.
had the same problem a while back.
the solution I use is to manually register the http namespace once. Paul Wheeler has an excellent tool for that: HttpNamespaceManager
so from your code:
register "http://localhost:8001/TappingBoard/DiscoveryService/" and give the user which runs the unit-tests full access.
hope this helps!
This sounds like an issue with UAC. Even if your TFSBuild account is a local administrator, the process will not have Administrator privileges unless explicitly configured to have it.
I've run into this issue many times on my local box (Vista x64), and it has always been related to lack of Administrator rights. I can't tell you why it works in non-admin mode on your dev boxes, but then again I don't know how Win7 works in this regard.
An alternative to running the process with Administrator privileges is to configure the port in advance using netsh.
The exception happens when the system tries to register the url.
The url is registered with WAS (Windows Activayion Services). Could there be a problem that WAS is not set up.
There may be a more helpfull message in the event log.

WCF address does not match what I specify in my web.config

In my web.config, I have specified
<services>
<service name="Querier.WCF.Querier"
behaviorConfiguration="QuerierServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://myserver:8000/SearcherService"/>
</baseAddresses>
</host>
<endpoint address="net.tcp://myserver:9000/SearcherService"
binding="netTcpBinding"
bindingConfiguration="Binding1"
contract="Querier.WCF.IQuerier" />
</service>
</services>
However, the site is not available at http://myserver:8000/SearcherService,
I for some reason have to go to:
http://myserver/SearcherService/SearcherService.svc
(notice the port is missing)
When I go there, it tells me to run
svcutil.exe http://myserver.mycompanyname.com/SearcherService/SearcherService.svc?wsdl
It added a domain name for some reason and when I try to access the service with WCF storm,
I put in http://mymachine/SearcherService/SearcherService.svc, it discovers all the function names fine, but when I try to run one, I get:
There was no endpoint listening at
net.tcp://myserver:9000/SearcherService
that could accept the message. This is
often caused by an incorrect address
or SOAP action. See InnerException, if
present, for more details.
Any ideas as to why my service URL doesn;t match what I specified in the web.config?
NOTE:
I have set nettcp on the app in IIS and enabled the binding on 9000:*
When you host a WCF service in IIS it is IIS and its configuration who decides the base address for your service and you can only specify relative addresses. The baseaddress only applies to self hosted services.