I am trying to publish my duplex wcf service on a server with no success, I am able to publish it on local IIS, but when I publish it to server its address become net.tcp://win-rhkt30stjd7/Broadcastor/BroadcasterService.svc. As you would agree such address is not useful at all while creating the service reference on client. I tried to publish it as WCF application project, and service library project but both is giving the same result. Probably something is missing from my Web.config file but I don't know what it is. Please help me out here. Below is my Web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" />
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<services>
<service name="BroadcastorServiceApp.BroadcastorService">
<endpoint binding="netTcpBinding" contract="BroadcastorServiceApp.IBroadcastorService">
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding>
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
I dont see any address part in your NET TCP endpoint
1 : Add a base address as below :
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8088" />
</baseAddresses>
</host>
2 : add an address parameter to your net tcp endpoint as :
<endpoint address = "tcpEndPoint"
binding="netTcpBinding"
contract="BroadcastorServiceApp.IBroadcastorService"></endpoint>
3 : Alse give a behavior name as :
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
And add it to the service like :
<service name="BroadcastorServiceApp.BroadcastorService" behaviorConfiguration="ServiceBehavior">
<endpoint binding="netTcpBinding" contract="BroadcastorServiceApp.IBroadcastorService"></endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
Related
I setup a WCF application to be hosted by a Windows service. I got this to work correctly and I can navigate to it by going to http://127.0.0.1:1214. Here is the configuration:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="NetworkPrintClient.PrintWebService" behaviorConfiguration="PrintServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://127.0.0.1:1214/"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="NetworkPrintClient.IPrintWebService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PrintServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Now I'd like to make this accessible at https://127.0.0.1:1214. After reading several articles about doing this, I end up with the config below. But, I can't browse to the application anymore. I just get a "This site can't be reached" error in Chrome.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="NetworkPrintClient.PrintWebService" behaviorConfiguration="PrintServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://127.0.0.1:1214/"/>
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding" contract="NetworkPrintClient.IPrintWebService" behaviorConfiguration="HttpBehavior" bindingConfiguration="PrintServiceHttpsBinding"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PrintServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="HttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="PrintServiceHttpsBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<protocolMapping>
<add binding="webHttpBinding" scheme="https"/>
</protocolMapping>
</system.serviceModel>
</configuration>
The article I used to get this far is here. I did the part at the bottom about making the certificate and mapping it to my IP and port. I also tried to get this to work with "localhost" and my actual IP address. Can anyone see what I'm doing wrong?
You must to create a certificate selfhosted to localhost, you can use this command line in powersheel
New-SelfSignedCertificate -DnsName "localhost", "localhost" -CertStoreLocation "cert:\LocalMachine\My" when you execute is gonna generate the thumbprint of certificate keep to associate to the port something like this "B80BE75765AA5739EAC63AAF67C32E5A3625FF19"
in window type "certificates" and click manage computer certificates and copy the certificate from personal\certificates to trusted root certification authorities\certificates
associate the certificate hash (thumbprint to the port) - netsh http add sslcert ipport=0.0.0.0:{0} certhash={1} appid={2} certstore=MY 0 - port - 1 - (the thumbprint generated by the certificate) 2 - {555b2e5f-4877-459b-bff2-60bb25898455} (GUID)
I've been fiddling for two days now, trying to get my TCP endpoint working in my Wcf application.
I've hosted my Wcf app in IIS8 (NOT IIS Express), configured the website to enable net.tcp protocol listening on port 808.
But no matter what I do, I can't reach the TCP endpoint. The HTTP endpoint is working as intended.
Here's my Web.config:
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DefaultHttpBinding" />
</basicHttpBinding>
<netTcpBinding>
<binding name="DefaultTCPBinding" portSharingEnabled="true">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="SimplBehavior" name="SimplWCF.WcfService">
<endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>
<endpoint address="local" binding="netTcpBinding" contract="SimplWCF.IWcfService" bindingConfiguration="DefaultTCPBinding" name="localTcpBinding"/>
<!-- Used for connecting the service to CMS-->
<endpoint address="mexhttp" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="public" binding="basicHttpBinding" contract="SimplWCF.IWcfService" bindingConfiguration="DefaultHttpBinding" name="publicHttpBinding"/>
<!-- Used for connecting the webpages to the service-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:50356/SimplWCF/" />
<add baseAddress="net.tcp://localhost:808/SimplWCF/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SimplBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="basicHttpBinding" scheme="http"/>
<add binding="netTcpBinding" scheme="net.tcp"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
I know that the HTTP endpoint doesn't work properly with httpGetEnabled="false", but right now I just need my TCP endpoint to work.
When I try to add a service reference in another project in Visual Studio (in the namespace as my WCF) I write the URL like this:
net.tcp://localhost:808/SimplWCF/WcfService.svc
But I'm not 100% sure this is the correct way of doing it.
Hope somebody can help me.
I finally got it working now!
I removed the relative address in the TCP endpoint, so that my config now looks like this: `
<services>
<service behaviorConfiguration="SimplBehavior" name="SimplWCF.WcfService">
<endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>
<endpoint address="" binding="netTcpBinding" contract="SimplWCF.IWcfService" bindingConfiguration="DefaultTCPBinding" name="localTcpBinding"/>
<!-- Used for connecting the service to CMS-->
<endpoint address="mexhttp" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="public" binding="basicHttpBinding" contract="SimplWCF.IWcfService" bindingConfiguration="DefaultHttpBinding" name="publicHttpBinding"/>
<!-- Used for connecting the webpages to the service-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:50356/SimplWCF/" />
<add baseAddress="net.tcp://localhost:808/SimplWCF/"/>
</baseAddresses>
</host>
</service>
</services>
Thank you for your time!
I have a WCF service which works great when small data has to be transferred over the wire. When I increase the data to a bigger size, I get following error:
The remote server returned an unexpected response: (400) Bad Request.
I know that this question has been asked many times be other user. But, I have tried all of those approaches to fix this issue. Nothing is working for me. Can you please have a look at my config contents and let me know if I am missing something. Following is my services' config file.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="RecieveValidationResultHubServiceLibrary.ReceiveValidationResultHubService">
<endpoint address="" binding="basicHttpBinding" contract="RecieveValidationResultHubServiceLibrary.IReceiveValidationResultHubService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8735/Design_Time_Addresses/RecieveValidationResultHubServiceLibrary/ReceiveValidationResultHubService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Following is service reference config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="MaxParallelThreads" value="300"/>
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IReceiveValidationResultHubService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8735/Design_Time_Addresses/RecieveValidationResultHubServiceLibrary/ReceiveValidationResultHubService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReceiveValidationResultHubService"
contract="ReceiveValidationServiceReference.IReceiveValidationResultHubService"
name="BasicHttpBinding_IReceiveValidationResultHubService" />
</client>
<services>
<service name="StartValidationClientServiceLibrary.StartValidationClientService">
<endpoint address="" binding="basicHttpBinding" contract="StartValidationClientServiceLibrary.IStartValidationClientService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8734/Design_Time_Addresses/StartValidationClientServiceLibrary/StartValidationClientService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
If error is about max reader quota, kindly make the change in web.config under your binding. See if it works.
<binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
Hosting in IIS,web.config
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true">
</compilation>
<authentication mode="Forms"/>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AllenBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="jqueryWCF.WCFservice" behaviorConfiguration="mexBehavior">
<host>
<baseAddresses>
<add baseAddress="http://127.0.0.1:9999/Service"/>
</baseAddresses>
</host>
<endpoint address="" behaviorConfiguration="AllenBehavior" binding="webHttpBinding" contract="jqueryWCF.WCFservice" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
1 web page access success by JQuery ajax
2 Metadata is also released, the URL access success;
*But why the console app add service reference will appear "object reference not set to an instance of an object"????*
Looks like something wrong with metadata of your WCF service.
Check operations contracts definition.
Do not you have conflicting contract names?
Try to use ServiceModel Metadata Utility Tool (Svcutil.exe) to generated client code from WSDL instead of Visual Studio tool
I am trying to run my service with the WCF Test Client using netTcpBinding (service runs fine with basicHTTP). I am getting the following error
Error: Cannot obtain Metadata from net.tcp://chatmesh/mex If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: net.tcp://chatmesh/mex Metadata contains a reference that cannot be resolved: 'net.tcp://chatmesh/mex'. No DNS entries exist for host chatmesh. No such host is known
I don't see anything blatantly wrong that would cause the problem. Below is my app.config. Does anyone have any suggetions for me?
<?xml version="1.0" encoding="utf-8" ?>
<!--SERVICE App.config file-->
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NewBinding0">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="MachineLibrary.Machine1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="NewBinding0"
name="" contract="MachineLibrary.IMachine1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://Chatmesh" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>