I have a custom tcp binding I want to test on a service, specifically to disable the security:
<bindings>
<netTcpBinding>
<binding name="customTcpBinding" maxReceivedMessageSize="20480000" transferMode="Streamed" >
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
However, upon using the tcp binding's name in the config I recieve this error:
Severity Code Description Project File Line
Warning The 'binding' attribute is invalid - The value 'customTcpBinding' is invalid according to its datatype 'serviceBindingType' - The Enumeration constraint failed. Server C:\Users\Totally Not Beau\documents\visual studio 2015\Projects\WCF Proj\WCF Proj\App.config 24
Endpoint config:
<endpoint
address=""
binding="customTcpBinding"
bindingConfiguration=""
contract="Server.IMyService">
</endpoint>
Whole file if it helps:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="customTcpBinding" maxReceivedMessageSize="20480000" transferMode="Streamed" >
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="Server.MyService">
<endpoint address="" binding="customTcpBinding" bindingConfiguration=""
contract="Server.IMyService">
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://192.168.2.7:8732/MyService/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Any advice would be greatly appreciated!
I think what you want is
<endpoint
address=""
binding="netTcpBinding"
bindingConfiguration="customTcpBinding"
contract="Server.IMyService">
</endpoint>
You may have to specify an actual address too, I'm not positive.
Related
I've been looking online but I can't find a defined procedure or an example on how to configure a basicHTTP self-hosted WCF service to compress messages that servers sends to clients.
I would like to use GZIP or similar technology.
this is my application app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<services>
<service name="Application.ApplicationServicesProxy" behaviorConfiguration="ApplicationSvcsBehave">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9001/ApplicationSvcs"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:9001/ApplicationSvcs" binding="basicHttpBinding" contract="Application.IApplicationServices"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ApplicationSvcsBehave">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
This is how I create the service:
var host = new ServiceHost(typeof(ApplicationServicesProxy));
host.Open();
Services are defined in IApplicationServices that is inherited by ApplicationServicesProxy
[ServiceContract]
interface IApplicationServices
{
[OperationContract]
string[] MethodOne();
}
public class AppicationServicesProxy : IApplicationServices
{
public string[] MethodOne()
{
// return a string value;
}
}
And this is how I connect the client to the service
var ApplicationSvcs = new ApplicationSvcs.ApplicationServicesClient("BasicHttpBinding_IApplicationServices");
I am currently using .NET 4.8
I solved doing like this, message size went down fromm 300 Kb/s to 11 Kb/s so it really works and CPU is not very interested in that:
<system.serviceModel>
<services>
<service name="Application.ApplicationServicesProxy" behaviorConfiguration="ApplicationSvcsBehave">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9001/ApplicationSvcs"/>
</baseAddresses>
</host>
<endpoint address="" binding="customBinding" bindingConfiguration="BinaryCompressionBinding" contract="Application.IApplicationServices"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ApplicationSvcsBehave">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="BinaryCompressionBinding">
<binaryMessageEncoding compressionFormat ="GZip"/>
<httpTransport decompressionEnabled="true"/>
</binding>
</customBinding>
</bindings>
</system.serviceModel>
and on client side
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IApplicationServices" >
<binaryMessageEncoding compressionFormat="GZip"/>
<httpTransport maxReceivedMessageSize="20000000"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:9001/ApplicationSvcs" binding="customBinding"
bindingConfiguration="CustomBinding_IApplicationServices" contract="ApplicationSvcs.IApplicationServices"
name="CustomBinding_IApplicationServices" />
</client>
</system.serviceModel>
SOAP messages can be very heavy but in my application I could not use REST so I hope that can be of any help.
I have create iis server on remonte machine (Windows Server 2008 R2). This is my web.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Binding" closeTimeout="00:05:00" sendTimeout="00:10:00" />
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="DictionaryServiceBehaviors">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DictionaryServiceBehaviors" name="BandD.Serwis.SerwisISS.Service.DictionariesService">
<endpoint address=""
binding="wsHttpBinding"
contract="BandD.Serwis.SerwisISS.Interface.IDictionariesService"
bindingConfiguration="Binding"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.199.89:7833/BandD.Serwis.SerwisISS.Service/DictionariesService/"/>
</baseAddresses>
</host>
</service>
</services>
That is app.config for client application:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDictionariesService" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://xxx.xxx.199.89:7833/Service/DictionariesService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDictionariesService"
contract="DictionariesService.IDictionariesService" name="WSHttpBinding_IDictionariesService">
</endpoint>
</client>
I have add IIS server role to my remote machine, i set physical path to locate publised file from server application (publised from VS). All of authentication i set to Disabled, only Anonymous Authentication is Enabled.
When i try connect to WSDL with SoapUi i go error:
Error getting response; java.net.UnknowsHostException: winserver2008
When i want connect to server with client app i must write username and password (administrator password don't work).
What i must do to can connect to server without authentication. What i should change on server(Windows server) or app.config to can connect correctly.
Probably i have bed web/app.config
Ok i found solution:
On MS Server i change for now website connect as (in bassic setting) to administrator. This is only for now and i change it later.
Second i change web.config on server:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Binding" closeTimeout="00:05:00" sendTimeout="00:10:00">
<security mode="None" />
<reliableSession enabled="true" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="DictionaryServiceBehaviors">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DictionaryServiceBehaviors" name="BandD.Serwis.SerwisISS.Service.DictionariesService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="Binding"
contract="BandD.Serwis.SerwisISS.Interface.IDictionariesService" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="mex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://http://xxx.xxx.199.89:7833/Service/DictionariesService" />
</baseAddresses>
<timeouts closeTimeout="00:01:00" openTimeout="00:10:00" />
</host>
</service>
</services>
At last i change client app config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDictionariesService">
<reliableSession enabled="true" />
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://xxx.xxx.199.89:7833/Service/DictionariesService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDictionariesService"
contract="DictionariesService.IDictionariesService" name="WSHttpBinding_IDictionariesService" />
</client>
</system.serviceModel>
I´m trying to implement a Wcf Duplex Service in my Windows Store Application. In my .NET WPF Application everything works fine. I use a NetTcpBinding.
Here is my Service Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="myNetTcpBinding" receiveTimeout="00:30:00">
<reliableSession enabled="true" inactivityTimeout="24.20:31:23"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="CnS.Base.Services.MessageHub.MessageHubService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="myNetTcpBinding" contract="CnS.Base.Services.MessageHub.IMessageHubService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress = "net.tcp://localhost:8655/MessageHubService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="False" httpsGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
If i call a Method from the WCF Service i get a ActionNotSupportedException.I figured out that if i set
<reliableSession enabled=false"/>
It works fine. But my Problem is now that the Wcf connection is closed to my Windows Store App and i can´t Push Messages to this client.
Does anyone know a workaround for this Problem?
I new to wcf however i'm attempting to use net.tcp binding wcf service to transmit an xml file to the client.
I can get up to creating the xml file and upon attempting to connect to my wcf service fails.
I followed this guide http://msdn.microsoft.com/en-us/library/ff647180.aspx up to creating the windows test app, i'm using a web project for this.
I have added the service reference to project and below is the code i'm attempting to execute:
public string SendXMLDocument(XmlDocument xDoc)
{
var message = Message.CreateMessage(MessageVersion.Soap11, "Request_for_action", new XmlNodeReader(xDoc));
var factory = new ChannelFactory<IActionServiceLibrary>("IMMS.ActionsServiceLibrary.IActionServiceLibrary");
var channel = factory.CreateChannel();
var response = channel.Request(message);
channel.Close();
return response.ToString(); //this should come back okay..
}
my library appconfig looks like:
<?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>
<client>
<endpoint address="net.tcp://localhost:8080/ActionService/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IActionServiceLibrary" contract="IMMS.ActionsServiceLibrary.IActionServiceLibrary"
name="IMMS.ActionsServiceLibrary.IActionServiceLibrary">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="IMMS.ActionsServiceLibrary.ActionServiceLibrary">
<endpoint address="net.tcp://localhost:8080/ActionService/" binding="netTcpBinding" bindingConfiguration=""
contract="IMMS.ActionsServiceLibrary.IActionServiceLibrary">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8080/ActionService/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="Action_Service" sendTimeout="00:01:00" transactionFlow="false"
listenBacklog="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" portSharingEnabled="false">
<reliableSession enabled="false" />
<security mode="None">
<transport clientCredentialType="None" protectionLevel="None" />
<message clientCredentialType="None" />
</security>
</binding>
<binding name="NetTcpBinding_IActionServiceLibrary" />
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
the app config for the service:
<?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>
<client>
<endpoint address="net.tcp://localhost:8080/ActionService/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IActionServiceLibrary" contract="IMMS.ActionsServiceLibrary.IActionServiceLibrary"
name="IMMS.ActionsServiceLibrary.IActionServiceLibrary">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="IMMS.ActionsServiceLibrary.ActionServiceLibrary">
<endpoint address="net.tcp://localhost:8080/ActionService/" binding="netTcpBinding" bindingConfiguration=""
contract="IMMS.ActionsServiceLibrary.IActionServiceLibrary">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8080/ActionService/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="Action_Service" sendTimeout="00:01:00" transactionFlow="false"
listenBacklog="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" portSharingEnabled="false">
<reliableSession enabled="false" />
<security mode="None">
<transport clientCredentialType="None" protectionLevel="None" />
<message clientCredentialType="None" />
</security>
</binding>
<binding name="NetTcpBinding_IActionServiceLibrary" />
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
i get a name mismatch on the channel creation.
any help to point me in the right direction for transmitting a xml file through wcf would be great.
I found out that my config file was messed up after fixing the errors it works now.
I am using VSTS 2008 + C# + .Net 3.0. I am using self-hosted WCF. When executing the following statement, there is the following binding not found error. I have posted my whole app.config file, any ideas what is wrong?
ServiceHost host = new ServiceHost(typeof(MyWCFService));
Error message,
Configuration binding extension 'system.serviceModel/bindings/MyBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
Full app.config,
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyBinding"
closeTimeout="00:00:10"
openTimeout="00:00:20"
receiveTimeout="00:00:30"
sendTimeout="00:00:40"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="WeakWildcard"
maxReceivedMessageSize="100000000"
messageEncoding="Mtom"
proxyAddress="http://foo/bar"
textEncoding="utf-16"
useDefaultWebProxy="false">
<reliableSession ordered="false"
inactivityTimeout="00:02:00"
enabled="true" />
<security mode="Transport">
<transport clientCredentialType="Digest"
proxyCredentialType="None"
realm="someRealm" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyWCFService"
behaviorConfiguration="mexServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9090/MyService"/>
</baseAddresses>
</host>
<endpoint address="" binding="MyBinding" contract="IMyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
thanks in advance,
George
You've misunderstood how to configure bindings - your binding in the endpoint needs to be a known protocol;
<endpoint address="" binding="wsHttpBinding" contract="IMyService"/>
Once you have that you can then specify the binding configuration you have defined within the settings for that protocol using the bindingConfiguration element thus
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="MyBinding" contract="IMyService"/>