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>
Related
I've created my custom Certificate Authority (CA) using openssl. Then I've created certificated using the previous one and the request from IIS. So now I have chain of certificates. Then I've bound the second one to my WCF service and every thing is fine. Then on client I've installed my CA certificate in Trusted Root Certification Authority to make it able to recognize my custom certificate.
My WCF service currently run on simple http connection.
Server side:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SyncWcfServices.MainServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647">
<security mode="None">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="SyncWcfServices.MainService" behaviorConfiguration="SyncWcfServices.MainServiceBehavior">
<endpoint address="/syncService.svc" binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize" contract="SyncWcfServices.IMainService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Client side:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMainService" maxReceivedMessageSize="2147483647" sendTimeout="00:10:00">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/SyncService/SyncService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMainService"
contract="SyncServiceReference.IMainService" name="WSHttpBinding_IMainService" />
</client>
</system.serviceModel>
So, I need to change this settings to support SSL connection. I've read a lot of post how to do it but there always using 2-way certification check that mean server must check client certificate and client must check server certificate. But I only want client to check server certificate using CA that I installed. And server will check with ordinary credentials (username, password) as it was before. I think that I have to change the security mode to Transport in both sides and server mex endpoint to mexHttpsBinding but what should I do next? Please help to resolve it.
Thanks you all!
Finally I found the correct way! So server side:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SyncWcfServices.MainServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate
findValue = "*.mydomain.com"
storeLocation = "LocalMachine"
storeName = "My"
x509FindType = "FindBySubjectName"
/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="SyncWcfServices.MainService" behaviorConfiguration="SyncWcfServices.MainServiceBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize" contract="SyncWcfServices.IMainService"></endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8095/Design_Time_Addresses/SyncWcfServices/MainService/" />
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Client Side:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name = "ServiceCertificate">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode = "ChainTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost/SyncService/SyncService.svc"
binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize"
behaviorConfiguration = "ServiceCertificate"
contract="SyncServiceReference.IMainService" name="WSHttpBinding_IMainService">
</endpoint>
</client>
</system.serviceModel>
Hope it will help someone!
Also please look at "Programming WCF Services" (4th edition) book by Juval Lowy & Michael Montgomery. It's a great book!
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.
This service I can see the JSON data while calling methods through browser when hosted on our IIS server but after moving it to client's server.. I can't see the data from browser though I can see through WCF Test CLient only... where I'm going wrong.. Could you suggest what should be done.
<bindings>
<wsHttpBinding>
<binding name="LargeSettings" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600">
<readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="mobserviceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service name="clubconnect.mobservice" behaviorConfiguration="mobserviceBehavior">
<endpoint address="" binding="wsHttpBinding" contract="clubconnect.imobservice" bindingConfiguration="LargeSettings"/>
<endpoint address="ws" binding="webHttpBinding" contract="clubconnect.imobservice" behaviorConfiguration="WebBehavior">
<identity>
<dns value="http://domain"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
You need to add a base address in there:
<host>
<baseAddresses>
<add baseAddress="http://<URL to the .svc file>" />
</baseAddresses>
</host>
Then your relative address for your webHttpBinding endpoint "ws" will resolve to
http://<URL to the .svc file>/ws
I have SSL working for my SOAP endpoint.
But as soon as I enable my REST endpoint, it throws a fit:
Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].
My app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="IIncreasedBufferSize" maxBufferSize="1024000"
maxReceivedMessageSize="1024000">
<readerQuotas maxArrayLength="1024000" />
<security mode ="Transport">
<transport clientCredentialType= "None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WCFBehaviourSSL"
name="IWCF.IService">
<endpoint name="soap" address="soap" binding="basicHttpBinding" bindingConfiguration="IIncreasedBufferSize"
contract="IWCF.IServices">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint name="rest"
address="rest"
binding="webHttpBinding"
contract="IWCF.IServices"
behaviorConfiguration="REST" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WCFBehaviourSSL">
<serviceMetadata httpGetEnabled="False" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I found this question: REST WCF Service Over SSL
But rest assured, None of the answers provided are of use.
I have certificates, and it does work with SSL using the SOAP end point. (when rest endpoint is commented out).
I was missing a WebHTTPBinding, that uses Transport security:
<webHttpBinding>
<binding name ="REST SSL">
<security mode ="Transport">
<transport clientCredentialType= "None" />
</security>
</binding>
</webHttpBinding>
. . .
<endpoint name="rest"
address="rest"
binding="webHttpBinding"
contract="IWCF.IServices"
behaviorConfiguration="REST"
bindingConfiguration="REST SSL"/>
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"/>