Hey I have made an WCF service and would like to be able to connect to it with an dns I set?
as it is now I have to conncet to the baseaddress via the computers ip.
and the DHCP sometimes gives new ip and then the clients have to know the new ip and so on... you hopefully get it :)
so how can I make it connect via a name instead? and like have localhost in baseaddress
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="metaAndErrors"
name="VenatoWCF.WCFService">
<endpoint address="http://localhost:8732/End"
binding="basicHttpBinding"
contract="VenatoWCF.IService">
<identity>
<dns value="dendei"/>
</identity>
</endpoint>
<endpoint address="http://localhost:8732/mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
<identity>
<dns value="dendei"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/VenatoWCFconsole/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metaAndErrors">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
been trying something like this but no luck xD, i would like to connect from client side with "http://dendei:8732/VenatoWCFconsole/"
so even if my ip changes the clients dont have to make changes to connect to me
thank you for answers!
no matter what, something will have to supply the endpoint address (i.e. ip/port). If that value is set to change frequently, i would set a port forwarder in between your client and service.
http://en.wikipedia.org/wiki/Port_forwarding
As i understood you don't have a static ip address and try to overcame this by having a static DNS name, in my opinion this would not work because you should have a static ip address and than assign to it a static DNS name, then try to connect.
I think this is a scenario that should "just work". Your service base address in the service config should be able to use localhost as you illustrated. In your client-side config you should configure your endpoint address using the DNS name for the host where the service is running.
Check that the client machine can ping the service machine using the DNS name. If that resolves ok, there is no reason why WCF shouldn't connect. You should not have to change any config when the DHCP server decides to allocate a new IP address, so long as clients can still resolve the DNS name to the new IP address.
For example, in your client config...
<client>
<endpoint address="http://dendei:8732/VenatoWCFconsole/End"
binding="basicHttpBinding" bindingConfiguration="sameBindingConfigYouAlreadyUse"
contract="Whatever.YourContractNameIs" name="YourEndpointName" />
</client>
Update: I just spotted there's a problem in your service config above. In the service endpoint config you should specify address as just the additional part of the URI that will get appended to the base-address. So, instead of address="http://localhost:8732/End", you just need address="End".
Related
I've waste xx hours for finding solution, but without success :(
I have IIS Server behind NAT, there is a WCF Service Host installed (on IIS).
Localy and over LAN Communication client-WcfService working property, but when i try to add service reference (over internet) to my wcf service host - in visual studio, i have an issue as below:
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved:
I have redirected on my router port WAN to port Lan of my WCF Sercice. Its working property because when i connect over internet to http://[...] .svc file in browser i can see proper site.
my web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="mexBehavior" name="KSPDJOBService.KSPDJOBService">
<endpoint address="" binding="wsHttpBinding" contract="KSPDJOBService.IKSPDJOBService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/KSPDJOBService" />
</baseAddresses>
</host>
</service>
</services>
Any Ideas how to resolve my problem? i would be very thanksful for any tips.
Thanks.
Sorry for my english :)
I resolved this issue.
1st issue was: in port forwarding router has forwarding WAN port X to local port Y
2nd issue was: in svc/wsdl i had local url (thats why i had HTTP 400 error when trying to connect from internet)
SOLVED:
1st. So i've made forwarding WAN_port: Y to LAN_port: Y (the same ports)
2nd. I added in IIS Site - Binding hostname as WAN_domain_name.
Credits to : https://gavinmckay.wordpress.com/2009/03/24/howto-fix-wcf-host-name-on-iis
I have issue with hosing WCF service in console. Tried to search here but could not find solution of this issue even if it is similar to other issues here.
Hosting is very simple.
C# - Host
WCFSrv = new WCFService();
WCFSrvHost = new ServiceHost(typeof(WCFService));
udaWCFSrvHost.Open();
Config:
<system.serviceModel>
<services>
<service name="WCF_Service.WCFService">
<endpoint address="" binding="basicHttpBinding" contract="WCF_Service.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:23456/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicTimeouts" closeTimeout="00:00:30" openTimeout="00:00:30"
receiveTimeout="00:00:30" sendTimeout="00:00:30" />
</basicHttpBinding>
</bindings>
</system.serviceModel>
I can reach service through WcfTestClient from localhost and invoke methods offered by service.
I can reach service through WcfTestClient from same network, however cant invoke methods offered by service. Once I try to invoke method I receive error message:
There was no endpoint listening at http://localhost:23456/WCFService/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
...
Inner Exception:
No connection could be made because the target machine actively refused it 127.0.0.1:23456
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
I tried to check whether there is port 23456 open and app is listening on that port through netstat -an and port 23456 is open and listening.
When I tried to modify base address (instead of localhost:23456 I put there real IP of server in network e.g. 10.xx.xx.xx) I was able to invoke methods as well but this is just workaround for internal solution.
Server and port should be open to external network and accessbile through internet. I tried to reach service from internet and I am able to reach service from internet (proof that port is open) but facing to same issue => cant invoke methods due to issue written above.
Does anyone have experience with same issue and can help me please?
Answered in Comments, put here for completeness.
Check the client config points at your server correctly and not localhost.
I'm new to WCF, but I've go the same issue latelly. I've just made a config file o the client project, and a wrote there the address of the endpoint:
<system.serviceModel>
<services>
<service name="WCF_Service.WCFService">
<endpoint address="" binding="basicHttpBinding" contract="WCF_Service.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:23456/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
You can use this reference: http://dotnetmentors.com/how-to-host-wcf-service-in-iis-7.aspx
From my point o view is very in handy. If it not works, try to recreate the project.
Sounds like you are binding to the wrong IP address try this:
<host>
<baseAddresses>
<add baseAddress="http://0.0.0.0:23456/WCFService/" />
</baseAddresses>
</host>
Using 0.0.0.0 instead of localhost will bind your service to all IPs on that host machine.
Thanks to all for support.
Solution for my issue:
Dont use WcfTestClient to test service from external network, at least in my case I faced issues described in my question.
For beginners simple advice when you have service hosted out of IIS
Use config file to define WCF settings in your project (e.g WCF Service Library)
Dont forget to copy setting from your WCF service project to Host application into app.config
When test from external network, use simple client app with own app.config, where endpoint has to lead to target service.
M.
I have made a simple WCF service, and it´s working like a charm in my developer environment. But now I'm moving it to my test server (AZURE) and i can´t get the endpoint address correct. The IIS is up and running, and the service is working locally on the test server.
When I try to test the service in WCF Test client, I receive an error when I try to invoke that the endpoint is incorrect:
There was no endpoint listening at mypathattestserver/Service1.svc
that could accept the message. This is often caused by an incorrect
address or SOAP action. See InnerException, if present, for more
details.
This is my web.config:
<services>
<service behaviorConfiguration="Test.Service1Behavior" name="Test.tfn">
<endpoint address="" binding="basicHttpBinding" contract="Test.IService1">
<identity>
<dns value="http://mypathattestserver.cloudapp.net/service1.svc"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Test.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
I would suggest the following steps:
Check the service with another client. SoapUI is a very good web service client. If the service responds to SoapUI then the problem is on your client
If the server is fine and the problem is at your client, remove the reference looking at the specific server and add it again.
Finally, check your firewalls. If the system plays fine by having the client and the server on the same machine, the firewalls could be a problem when the server is located on another machine.
Hope I helped!
I have the following configuration file for WCF service. There is a host defined in the config. Still, when I print the service address from the client, it does not know about the host. The printed result is:
http://localhost:3187/Service1.svc/MyFolder
Why doesn’t it take into account the host name? What modification do we need to do for it?
Note: I am running from VS 2010 for running service and client website.
Service1Client myClientService = new Service1Client();
Response.Write(myClientService.Endpoint.Address);
Client Configuration (Autogenerated by Visual Studio)
<client>
<endpoint address="http://localhost:3187/Service1.svc/MyFolder"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="MyWCFReference.IService1" name="WSHttpBinding_IService1">
<identity>
<userPrincipalName value="U16990#ustr.com" />
</identity>
</endpoint>
</client>
The server side configuration is:
<services>
<!--MyService-->
<service name="MyWCFServiceApplication.MyService"
behaviorConfiguration="WeatherServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:80/ServiceModelSamples/FreeServiceWorld"/>
</baseAddresses>
</host>
<endpoint address="MyFolder"
binding="wsHttpBinding"
contract="MyWCFServiceApplication.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WeatherServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
When a WCF service is hosted in an ASP.NET process, through either IIS or the ASP.NET Development Server (a.k.a Cassini), the baseAddresses setting in the service's configuration file is ignored since the service will always be reachable through the URL of the SVC file.
The URL you're seeing on the client is therefore correct:
http://localhost:3187/Service1.svc/MyFolder
As you can see, the base address of the service becomes the URL of the SVC file on the web server.
You're talking about a WCF client - yet, the config you posted only contains config for a service (the server side) ... (the <services> section).
I can't see any client configuration in what you posted - there ought to be a <client> section in your config somewhere
I don't understand what the problem is here. My wsHttpBinding works fine. Here is my configuration. Any help most appreciated.
<?xml version="1.0"?>
<configuration>
.....
<system.serviceModel>
<services>
<service behaviorConfiguration="DataService.Service1Behavior"
name="ODHdotNET.DataService">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration="largeTransferwsHttpBinding"
contract="ODHdotNET.IDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="net.tcp://139.149.141.221:8001/DataService.svc"
binding="netTcpBinding"
contract="ODHdotNET.IDataService"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://139.149.141.221:8000/DataService.svc" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="largeTransferwsHttpBinding2"
maxReceivedMessageSize="5000000" maxBufferPoolSize="5000000">
<security mode ="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
<binding name="largeTransferwsHttpBinding"
maxReceivedMessageSize="5000000" maxBufferPoolSize="5000000" />
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="DataService.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
edit: I am self-hosting in a Windows Service; I am not using IIS.
do you mean that a WCF client throws this error ?
if so:
please run the follwing at the command prompt:
netstat -ona | find "8001"
if this returns data, please post it
You need to add TCP support to your IIS.
To enable TCP, MSMQ, or named pipes communication specifically, perform the additional step of configuring support for the associated protocol. For TCP communication, bind the default Web site to a net.tcp port by using the Appcmd command-line utility. Appcmd is an IIS utility that enables you to administer virtual sites, directories,applications, and application pools.
%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -
+bindings.[protocol='net.tcp',bindingInformation='808:*']
To support the other protocols, run additional commands that enable those protocols for the default Web site. At this point, you have configured the net.tcp protocol at the site level.
%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/OrderServiceHost"
/enabledProtocols:http,net.tcp
Please look at these for more detail: Extend Your WCF Services Beyond HTTP With WAS
Hosting WCF Services in Windows Activation Service
Make sure the port is open in windows firewall
Make sure your host is running when you invoke methods in client application.