I wanted to consume a WCF service with a silverlight application and a asp.net mvc application, and I'm having difficulties to configure the service to support both requests.
these are my endpoints for the WCF config file.
<service behaviorConfiguration="behaviorAction" name="Uniarchitecture.ProdutoService.ServiceImplementations.ProdutoService">
<endpoint binding="wsHttpBinding" bindingConfiguration="bindingAction" contract="Uniarchitecture.ProdutoService.ServiceContracts.IProdutoService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="" binding="basicHttpBinding" contract="Uniarchitecture.ProdutoService.ServiceContracts.IProdutoService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
I'm getting the following error:
A binding instance has already been associated to listen URI 'net.tcp://localhost:10377/ProdutoService'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config.
The problem is trying to use two endpoints with two bindings... You can use multiple endpoints on the same service here, but they need to use the same binding.
And since Silverlight only supports BasicHttpBinding you're kind of stuck with it.
<service behaviorConfiguration="behaviorAction" name="Uniarchitecture.ProdutoService.ServiceImplementations.ProdutoService">
<endpoint binding="**basic**HttpBinding" bindingConfiguration="bindingAction" contract="Uniarchitecture.ProdutoService.ServiceContracts.IProdutoService"/>
<endpoint address="" binding="basicHttpBinding" contract="Uniarchitecture.ProdutoService.ServiceContracts.IProdutoService"/>
</service>
In your config, the addresses of the two endpoints are the same. With HTTP bindings, you can have multiple endpoints for a service, but you need to specify different addresses for them. Change the address of the basicHttpBinding endpoint to fix this problem.
Related
Have above 5 WCF projects. In which 4 has to be hosted as windows service and 1 in IIS. All in the same machine.
For each of the 4 WCF projects, I require 4 Windows service projects to host separately. To minimize the number of projects to be maintained, I am thinking of one single windows service to install all the 4 WCF projects for easy maintainability. Anyway apart from OnStart and OnStop I call the wcf and no other logics are there.
The challenges I see are, each Windows service requires the same app config file as used in WCF projects. If I would do this dynamically by getting the service name from app settings, How will I load the app.config file of different wcf projects to host as windows service during run time.
Is this feasible ? If so how can i achieve this ?
Yes, it's possible, you just need to configure each one endpoint in your config file. How to do that:
Windows Service WCF hoster is ServiceHost class, so you need to create 4 hosts for every contract.
var serviceHost = new ServiceHost(typeof(CommunicationManagement));
serviceHost.Open()
Now you can configure every your service endpoint in services section:
<system.serviceModel>
<services>
<service name="Communication.Service.CommunicationManagement">
<endpoint
binding="netTcpBinding"
bindingConfiguration="myBinding"
contract="Communication.Service.ICommunicationManagement"
name="CommunicationManagement">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="MEX" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Communication/Service/CommunicationManagement" />
</baseAddresses>
</host>
</service>
<service bname="Communication.Service.Managers.PhoneAdatpersManager">
<endpoint
binding="netTcpBinding"
bindingConfiguration="myBinding"
contract="Communication.IPhoneAdministration"
name="PhoneAdministration">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="MEX" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Communication/Service/PhoneAdministration" />
</baseAddresses>
</host>
</service>
</services>
<system.serviceModel>
Above you can see PhoneAdatpersManager and CommunicationManagement services, they hosting in a single Windows Service and works together on 8000 port (but you can use different ports).
I have created a WCF multiservice with two interfaces, i'm trying to export two endpoints one for each service.
Here below you can see the two endpoints:
<service behaviorConfiguration="SAGBService_Behavior" name="SAGBService.SAGBService">
<endpoint address="basic" binding="webHttpBinding" bindingConfiguration=""
contract="SAGBService.ICalculeLactation" />
<endpoint address="basic1" binding="webHttpBinding" bindingConfiguration=""
contract="SAGBService.ISAGBService" />
</service>
when i try to call the service i have and error telling me that the endpoint is not found.
[EndpointNotFoundException]: There was no channel actively listening
at 'http://localhost:3197/SAGBService.svc/GetRapportTrimestiel/0/0/0/20150401/20150430'. This is
often caused by an incorrect address URI. Ensure that the address to
which the message is sent matches an address on which a service is
listening.
but when i remove the second endpoint, it works can access the functions on ICalculeLactation:
<service behaviorConfiguration="SAGBService_Behavior" name="SAGBService.SAGBService">
<endpoint address="" binding="webHttpBinding" bindingConfiguration=""
contract="SAGBService.ICalculeLactation" />
</service>
the problem is that i'm interested in the fuctions that are on
ISAGBService
I think the error says it: This is often caused by an incorrect address URI
Your endpoint has the address of "basic1", but the URL request does not include that address.
http://localhost:3197/SAGBService.svc/GetRapportTrimestiel/0/0/0/20150401/20150430
vs
http://localhost:3197/SAGBService.svc/basic1/GetRapportTrimestiel/0/0/0/20150401/20150430
I have an odd problem with some services. I am not the developer I am the sysadmin.
We have some SOAP services running in a development environment. Some SOAP services started to fail. Here is one example. These are both coming from the same web config.
<endpoint address="http://<URL>/<folder>/service.svc"
binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding"
contract="eConsentSvc.IeConsent"
name="WSHttpBinding_IeConsent" />
This one does not:
<endpoint address="http://<URL>/<folder>/service.svc/mex"
binding="wsHttpBinding"
bindingConfiguration="wsHttpBindingText"
contract="MetaDataSvc.IMetaData"
name="WSHttpBinding_IMetaData">
</endpoint>
This 2nd one throws a 404 error. The error generated is this:
There was no endpoint listening at http:////service.svc/mex that could accept the message.
The obvious difference is the "/mex." The developers insist that this has to be there so it has to be there. Why would it throw the 404 error with the MEX there?
If I remove the /mex then the service runs and generates the XML document it is supposed to create.
Please help. I am completely stumped.
In this endpoint one cannot specify binding="wsHttpBinding"
it has to one of the mex* bindings, for example: mexHttpBinding.
Another way would be to simply add another endpoint <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="http://<URL>/<folder>/service.svc/mex"
binding="wsHttpBinding"
bindingConfiguration="wsHttpBindingText"
contract="MetaDataSvc.IMetaData"
name="WSHttpBinding_IMetaData">
</endpoint>
I have a windows service on my laptop, which hosts a WCF service. I would like to use these service on my ASP.NET website, which is on external ASP.NET server.
Could you help me, how to do this?
Is it necessary a specific laptop configuration for that? What should I configure?
And binding, what type will adequate? .. Right now, I've got:
<service behaviorConfiguration="WcfServices.InfoBehavior" name="MyProgram.WcfServices.Info.Info">
<endpoint address="" binding="wsHttpBinding" contract="MyProgram.WcfServices.Info.IInfo">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Info/" />
</baseAddresses>
</host>
</service>
UPDATE:
Right now, my client app is still on my laptop (it is not publish yet).. This is my client code:
<client>
<endpoint address="http://localhost:8732/Info/" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IInfo" contract="ServiceInfo.IInfo"
name="WSHttpBinding_IInfo">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
I don't know, what binding use.. what port, what settings should be changed on my laptop?
Unless your laptop has its own fixed IP address exposed externally (most unlikely) I think you will find it hard to do this directly.
You might consider using Azure Service Bus to broker message exchanges: I believe this is one way to solve the problem of accessing a service hosted on a non-constant IP address or behind a firewall/NAT.
Or you could consider changing your design to turn things the other way around. That is, when it is connected and running, your laptop service connects to a service hosted on the ASP.NET box, over a duplex binding, with your current service contract as the callback contract.
If you have a WCF service running on your laptop hosted via ServiceHost you'll need to duplicate that configuration in your ASP.NET web.config file, as well as add a "service.svc" file which is referenced to the Interface of your service.
You should change localhost with real external facing IP address of your laptop and it could work if your router at home has no firewall. Change it in both client and server endpoint address.
I have a silverlight application which has a WCF in it. when I try to run the silverlight and call the WCF in fail in communication exception. I've understand that I have to add a client access policy file but I don't know where.
when the silverlight is running it runs this path:
SilverlightApplication1\SilverlightApplication1\Bin\Release\SilverlightApplication1TestPage.html
and this is from the web.config of WCF:
<services>
<service behaviorConfiguration="FileUpAndDownload.Web.MapServiceBehavior" name="FileUpAndDownload.Web.MapService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MapBinding" contract="FileUpAndDownload.Web.IMapService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
where do I have to place the clientaccesspolicy file?
Note: both silverlight and WCF are running on local.
thanks!
Place clientaccesspolicy.xml in root of your app. For Cassini it should be ..\bin\release\clientaccesspolicy.xml, for IIS place it in ..\inetpub\wwwroot\yourapp\clientaccesspolicy.xml. More on http://msdn.microsoft.com/en-us/library/cc197955%28v=vs.95%29.aspx
I'm more then sure that you do not need a ClientAccessPolicy if you are running everying on a local machine. But if you do - put it in your root folder. The problem is likely to be in a mismatch between your web and client configs, or just things in your web.config that you do not need that might be causing communication fails. Try to get rid of stff like Mex binding that you do not need and see if you can get it working with minimal configuration.
I saw another one of your question about the same from a week ago that had your client.config file in it. I can say that I was not able to get my own application to work untill i fixed mismatching contract names in the endpoint configurations. Try this:
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MapBinding" contract="FileUpAndDownload.Web.MapService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
Notice the I is gone in your contract, hope it helps =)