being new to wcf i often stuck to write endpoint address in config file. sometime i just could not understand what address i should write in endpoint at host end where service will be running. here is one sample endpoint entry....please have a look.
<endpoint address="net.tcp://localhost/ServiceModelSamples/Service1.svc"
binding="netTcpBinding"
contract="ServiceReference1.IService1">
</endpoint>
<endpoint address="net.tcp://localhost/ServiceModelSamples/service"
binding="netTcpBinding"
contract="ServiceReference1.IService1" />
i have couple of question on endpoint address
1) when i should write endpoint address like this way
net.tcp://localhost/ServiceModelSamples/Service1.svc
i guess when we will host our service in IIS then we need to write endpoint address like above one where we need to write our svc file name.
am i right?
2) just see the below address
address="net.tcp://localhost/ServiceModelSamples/Service1.svc"
what is ServiceModelSamples do i need to mention it?
3) suppose i develop wcf service with wcf service application template and host that service in win form apps then how our endpoint address would look like below one
address="net.tcp://localhost/ServiceModelSamples/service"
do i need to write ServiceModelSamples our project name folder or we can remove it from
address like address="net.tcp://localhost/service"
it is very important for me to know that do i need to write our project folder name like
ServiceModelSamples
4) when we host wcf service in win form apps then do i need to specify our svc file name with extension.
5) specifically guide me what address i need to write when we host our service in win form apps.
my all above question may sounds very stupid but i have really confusion about address in
endpoint. i have no there way to put question here. So please have a look at my 5 points and guide me. thanks
I think your confusion comes from the differences between IIS Hosting and custom hosting.
When you use IIS to host the service, the service behaves this way:
A base address is assigned to the service automatically depending on where the service is hosted in IIS. It uses the same address mapping that a web site uses.
The service layer needs to have .svc files to expose service instances through IIS. Those service files are just mapping files that help exposing on IIS.
So to fill the address to a service hosted in IIS from the client you need to:
Find out the address that has been assigned by IIS.
Complete that address with the Service.svc file name that you want to point to.
However when using custom hosting (through ServiceHost) the service address is totally goberned by the service configuration file:
The service can configure a base address to all its endpoint via the baseAddresses setting
All endpoints can have a full address or relative address. If relative address is used then the resulting endpoint address will be the baseAddress + endpoints relative address.
When custom hosting you have complete control over the service addresses, so you don't have any of the constraints that you must follow on IIS.
Related
I have a WCF 3.0 service which has been configured with BasicHttpBinding and has been deployed and hosted in IIS.
I can access my service using the below url:
http://mydomain.com/subfolder1/subfolder2/myservice.svc/basic
"basic" at the end of the address is the relative address of the end point and "/subfolder1/subfolder2" is where the myservice.svc file has been physically deployed to:
<endpoint address="basic" binding="basicHttpBinding"
contract="Company.MyService.Implementation.Contracts.IMyService">
</endpoint>
How to configure the settings so that I can access my service using the below url without specifiying the .svc path:
http://mydomain.com/myService/basic
Thanks,
In fact, it is not the responsability of your service. You should build "address-less" service and not specify one absolute in the config.
Your question is relevant to web hosting under IIS. There is a huge difference between the physical path (where you deploy) of your service and the virtual path (where client access it).
In your example, you simply need to create a new web application under http://mydomain.com/ and publish your service. subfolder1 seems to be a virtual directory of an existing web site. Just create the web app here, with IIS manager.
i need to use WCF Service with in my web application.
I ama new to wcf.
i created the service and add the service reference in my web application.
It shows the http:localhost in end point address.
endpoint address="http://localhost:52123/GeneralService1.svc"
i am confused to use the local host for access the wcf in web.
Is there any way to communicate with wcf / how to enable the connection.
Thanks in Advance
Pooja
A WCF endpoint has its ABC.
A - Address
B - Binding
C - Contract
<endpoint address="" binding="wsHttpBinding" contract="WcfService2.IService1">
You can change the address, by putting the Url of your deployment server, where the service would be hosted in production.
Read this for more details of WCF endpoint ABC
You can modify this address in the web.config file, to the url, while deployment.
I have created a simple WCF service by following a MSDN tutorial. I successfully created service and client. But I have a very basic question, that how can I use this service remotely. Foe example my service is hosted on a web server then how can I access and consume it from my PC. I know how to do this with web services but don't know with WCF service as Iam new to WCF. Any tutorial or code sample is appreciated.
Thanks
In your sample you must have specified the address of the service as endpoint.
You just need to modify the address in your app/web.config file and it will start talking to remote service.
See Specifying an Endpoint Address
Once you deploy the WCF service on some remote server all you have to do is to modify the endpoint address of the client to point to this remote address. This will depend on where you have configured the client endpoint. Usually it is done in the app.config/web.config:
<endpoint address="http://someremotedomain/myservice.svc" ...
I have created a working wcf service. I have come a cross a page regarding wcf services
which describes the process for eliminating default wcf service page.
It is here https://github.com/geersch/WcfServiceMessage
Except for the things the author of this page is describing, I have one question.
How has he managed to configure the IIS or Web.config to host page with the address: http://localhost:8732/HelloWorld/ ?
At home, the only address I see my service at is: http://localhost:8732/MyServiceName.svc
(with svc extension)
How has he done it that the endpoint address: "HellowWorld" is used?
Thanks!
The WCF service endpoint is not actually a file. The total url itself is what the server recognizes as something to service, so the HelloWorld piece is just as good as HelloWorld.svc.
This is a difference between IIS hosted service and Windows or Visual Studio service host (cassini). In iis, you do have to specify a file that ends with svc and make that extension known. In iis you can also set a svc file as the default file to open if a specific directory is opened. that way you can achieve the same behavior.
i having more than Three web services,
In that one is master site,and Others are client sites.
In My User Interface One Text box is Available ,In that text box i need to give Destination End Point address
from that Text box Value i need call the Client Service.
for Example:
Client1 end point Service Name:
http://localhost:1524/WebServiceService.svc"
Client2 end point Service Name:
By
Rajagopalk
http://localhost:8085/WebServiceService.svc"
if i give "localhost:1524" in Text box Client1 Service will call,
if i give "localhost:8085" in Text box Client2 Service will call,
Are you hosting your WCF services in IIS ? In that case, your service address is determined by the IIS configuration and the virtual directory where your service's *.svc file exists.
So to change something on the server, you need to check and modify the IIS configuration.
To change on the client side, there's a web.config (for ASP.NET webs) or an (applicationName).exe.config where your endpoint definition should be contained - change the endpoint address there:
<client>
<endpoint name="YourEndpointName"
address="http://localhost:8085/WebServiceService.svc"
binding="......." bindingConfiguration="............."
contract="..................." />
</client>
You need to specify the complete target web service address in the address= attribute of your <endpoint> configuration element.
You can define multiple endpoints for the same service, and pick which one to use when you instantiate the client proxy:
MyServiceProxy client = new MyServiceProxy("name of endpoint configuration");
and with this, you can switch between several definitions of endpoints easily.
UPDATE: If you want to programmatically set your client address from code, you need to do the following when creating your client proxy:
// create custom endpoint address in code - based on input in the textbox
EndpointAddress epa = new EndpointAddress(new Uri(textbox.Text));
// instantiate your cilent proxy using that custom endpoint address
// instead of what is defined in the config file
MyServiceProxy client = new MyServiceProxy("name of endpoint configuration", epa);