I have developed a WCF service which calls two clients to send files to each client.
I have done this by calling a single client and transferring the file is working fine. When I implement with more than one client it is getting a concurrency issue. I have looked at
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
But it's not working. When I debug, both service are executing in parallel and having problems with file resources.
Here is my client endpoint:
<client>
<endpoint address="xedt027/LeapClient/FileTransfer.svc"; binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileTransfer" contract="ServiceReference1.IFileTransfer" name="BasicHttpBinding_IFileTransfer" />
<endpoint address="localhost:50152/FileTransfer.svc"; binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileTransfer1" contract="ServiceReference2.IFileTransfer" name="BasicHttpBinding_IFileTransfer1" />
</client>
Related
Is it possible for a WCF Service with two endpoints to provide a way, for the client, to generate his proxies from a specific endpoint ? I'm currently using the "Add Service Reference" feature from VS 2013 and it will obtain all classes defined by two contracts.
My two contracts define differents request/response. IServiceTCP provide admin-like methods and in IServiceHttp user-like methods.
Since I got a client who will only communicate in HTTP and he's not in the same network (making the endpoint in tcp useless), I would like to provide him a way to generate his proxies getting only classes needed from the http contract.
It seems I can provide an address to the endpoint that will be appended to the base address of the service. Since I'm hosted behind an IIS server, if I give the address "testhttp" to my endpoint, it would be resolved as "http://localhost/MyService/Service.svc/testhttp". I didn't found a way for a client to consume that address.
<service name="Namespace.Service" behaviorConfiguration="ServiceBehaviorA">
<endpoint binding="wsHttpBinding" bindingConfiguration="ServiceBindingHttp" contract="Namespace.IServiceHttp" />
<endpoint binding="netTcpBinding" bindingConfiguration="ServiceBindingTCP" contract="Namespace.IServiceTCP" />
</service>
I would like to avoid creating two services to achieve this purpose.
Thanks,
Not sure if this can be achieved without creating two services. If you're trying to create two endpoints, this is what you should try:
Give the two endpoints different service name:
<service name="Namespace.ServiceA" behaviorConfiguration="ServiceBehaviorA">
<endpoint binding="wsHttpBinding" bindingConfiguration="ServiceBindingHttp" contract="Namespace.IServiceHttp" />
</service>
<service name="Namespace.ServiceB" behaviorConfiguration="ServiceBehaviorA">
<endpoint binding="netTcpBinding" bindingConfiguration="ServiceBindingTCP" contract="Namespace.IServiceTCP" />
</service>
<serviceHostingEnvironment >
<serviceActivations>
<add relativeAddress="ServiceA.svc" service="Namespace.ServiceA" />
<add relativeAddress="ServiceB.svc" service="Namespace.ServiceB" />
</serviceActivations>/serviceHostingEnvironment>
Now the two endpoints should be accessible via
http://localhost/MyService/ServiceA.svc
http://localhost/MyService/ServiceB.svc
HTH.
IIf I have multiple WCF services set up in a project like so:
ServiceA.svc
IServiceA.cs
ServiceB.svc
IServiceB.cs
And my web config has the following:
<services>
<service name="Services.ServiceA">
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration=""
contract="Services.IServiceA" />
<endpoint address="upload" binding="basicHttpBinding" bindingConfiguration="ImageUploadServiceBinding"
name="" bindingName="ImageUploadServiceBinding" contract="Services.IServiceB" />
</service>
</services>
Is that wrong? I ask because I have seen multiple ways of setting up WCF services when you have 'multiple' services and everyone seems to do it a different way. If I have multiple svc files in my project (multiple services), is it OK to group them into one "service" in the web.config and then separate them via endpoints like I have done above?
This will be hosted in IIS, btw.
I don't see why this would be a problem technically. WCF is built for this. You should keep in mind the deployment issues you could face.
Now, since it is one service, you can't just replace service A without replacing service B. This is okay if there are tightly coupled and share the exact same dependencies. If not, split them for maintainability.
I am just starting to learn WCF. I have successfully set up a WCF service with host console app. The service maps to SQL Server with Entity Framework. I then have a WPF client app which consumes the service. This all works fine in Dev, both the service and client app running from my machine:
<endpoint address="http://localhost:8081/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IRegimesService" contract="RegimesService.IRegimesService"
name="BasicHttpBinding_IRegimesService" />
I have now transferred the service and host onto my new VM. The service host runs fine. I am now trying to configure the client app endpoint to connect to the service. I think the HTTP address is incorrect:
Service app.config:
<services>
<service name="diiRegimesService.RegimesService">
<endpoint address="" binding="basicHttpBinding" contract="diiRegimesService.IRegimesService"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8082" />
</baseAddresses>
</host>
</service>
</services>
Client app.config:
<client>
<endpoint address="http://emea-myserver01.emea.basketballinfo.com/localhost:8082/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IRegimesService" contract="RegimesService.IRegimesService"
name="BasicHttpBinding_IRegimesService" />
</client>
The server credentials for remote desktop are: emea-myserver01.emea.basketballinfo.com
I currently don't specify a username & password in my client app.config.
The service is running on the server. I'm getting an exception trying to add the service reference in the client app.
Add Service Reference- Adress: http://EMEA-myserver01.emea.basketballinfo.com
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://emea-myserver01.emea.basketballinfo.com/'.
You need to make sure the server is able to resolve the full domain name.
Also, the address url provided in the client configuration snippet <endpoint address="http://emea-myserver01.emea.basketballinfo.com/localhost:8082/ does not seem valid. Perhaps you want to use <endpoint address="http://emea-myserver01.emea.basketballinfo.com:8082/
After implemeting a WCF service, hosting it on the IIS Server, it returned with the below error.
EndpointNotFoundException was unhandled by user code There was no
endpoint listening at XXXXX that could accept the message. This is
often caused by an incorrect address or SOAP action. See
InnerException, if present, for more details.
That service is identically has the same implementation and configuration of 5 running services with no errors.
when I tried to figure out what is going on the IIS server, the below screenshot.
So it seems that this specific service has no detected Contract. although I'm using the same configuration as below.
<service name="XX.XX.Provisioning.EldaftarManagementService">
<endpoint address="" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" bindingNamespace="http://XX.XX.com/XX/" contract="XX.XX.Provisioning.Eldaftar.IEldaftarManagementService" />
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="ProvisioningBasicBinding" bindingNamespace="http://XX.XX.com/provisioning/" contract="XX.XX.Provisioning.Eldaftar.IEldaftarManagementService" />
</service>
<service name="XX.XX.Provisioning.Common.UserManagement.UserManagementService">
<endpoint address="" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" bindingNamespace="http://XX.XX.com/XX/" contract="XX.XX.Provisioning.Common.UserManagement.IUserManagementService" />
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="ProvisioningBasicBinding" bindingNamespace="http://XX.XX.com/provisioning/" contract="XX.XX.Provisioning.Common.UserManagement.IUserManagementService" />
</service>
Kindly noted that when accessing the service.svc url it replies normally and the wsdl is shown. So that means it's hosted fine on the IIS.
Do I miss something?
Update:
Client config.
<endpoint address="https://XXX/EldaftarManagementService.svc" behaviorConfiguration="ProvisioningClientBehaviour" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" contract="EldaftarManagementService.IEldaftarManagementService" />
<endpoint address="https://XXX/UserManagement.svc" behaviorConfiguration="ProvisioningClientBehaviour" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" contract="UserManagementService.IUserManagementService" />
i notice sometime after reconfigure my service reference, the client config getting wsdl with server name. then i get EndpointNotFoundException exception.
example :
service reference is : http://192.168.61.2:1111/Service1.svc
but in the config endpoint address it show : http://serverName:1111/Service1.svc
After i change the config endpoint address with the service reference address , then it resolved. Not sure why but now every time when i reconfigure the endpoint address, i will manually change the config endpoint address to make sure it get the same address.
How do I get all the wcf 4.0 service addresses from each project in the Visual Studio solution when the services section endpoints in the web configs don’t specify an address or baseaddress? I intend to write the list of service addresses out to an aspx page. Any help would be appreciated.
Here's an example of one of the service sections in the web config.
<services>
<service name="ABC.Enterprise.Flight.FlightService">
<endpoint address="" binding="basicHttpBinding" name="ICRMManagement" contract="ABC.Enterprise.Flight.IFlightService"/>
<endpoint address="MexBasic" binding="mexHttpBinding" name="MexBasic" contract="IMetadataExchange" />
</service>
You could use WCF Discovery to find endpoints at runtime...
http://msdn.microsoft.com/en-us/library/dd456791.aspx