I am attempting to implement a simple chat service using WCF (WsDualHttpBinding) so i can make use of the Callbacks.
My WCF service is hosted under IIS (8.5 I believe) under Arvixe shared hosting.
When I test my client and my service on my PC everything works like a charm. When I publish my service on Arvixe host and attempt to open a connection from the client app running on my pc (using visual studio) I get: "The caller was not authenticated by the service".
The service is hosted here:
http://www.4greatsoft.com/WebService/ChatSVC.svc
I can also get the service description with:
http://www.4greatsoft.com/WebService/ChatSVC.svc?wsdl
The firewall on the client PC is off.
My service model configuration on the CLIENT (app.config) side is:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IChat" />
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://www.4greatsoft.com/WebService/ChatSVC.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IChat"
contract="IIS_ChatSVC.IChat" name="WSDualHttpBinding_IChat">
<identity>
<userPrincipalName value="PINE\4greatsoftcom_web" />
</identity>
</endpoint>
</client>
</system.serviceModel>
My service model configuration on the SERVER (web.config) side is:
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration" />
</protocolMapping>
<bindings>
<wsDualHttpBinding>
<binding name="wsDualHttpBindingConfiguration" transactionFlow="true" >
</binding>
</wsDualHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="ServiceAssembly.ChatService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration" contract="ServiceAssembly.IChat" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Those service model configuration will yield a "The caller was not authenticated by the service" error.
Following many suggestions on stackoverflow, I attempted to turn off security using the service model configuration bellow, but when doing so I get the following timeout error: "The open operation did not complete within the allotted timeout of 00:00:09.7659996."
My service model configuration (causing timeout) on the CLIENT (app.config) side is:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IChat" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:10"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="None">
<message clientCredentialType="None" negotiateServiceCredential="false" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://www.4greatsoft.com/WebService/ChatSVC.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IChat"
contract="IIS_ChatSVC.IChat" name="WSDualHttpBinding_IChat">
</endpoint>
</client>
</system.serviceModel>
My service model configuration (causing timeout) on the SERVER (web.config) side is:
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration" />
</protocolMapping>
<bindings>
<wsDualHttpBinding>
<binding name="wsDualHttpBindingConfiguration" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:10"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="ServiceAssembly.ChatService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration" contract="ServiceAssembly.IChat" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
IMPORTANT:
please note that the use of "WsDualHttpBinding" is mandatory in my use case as I am using the CallBack feature of WCF. So NO I can't use "HttpBasicBinding".
To be brutally honest, I must admit that I am a total noob as far as networking security is concerned and I am clueless as to how to fix this. I have been on a "trial and error" binge for over 3 days trying all kinds of permutation to my service model configuration with no success...
That said, I would ask any would-be helper to be precise in there suggestion and not assume that I am a expert in the subject matter...
I believe this post (WCF Client not able to negotiate security access with Service running in a different machine) comes close to explaining my problem but I still can't see what my solution must be.
At this point I am almost willing to contract a WCF/IIS expert to see this through if only I knew where to find one...
Thank you all for your attention.
Related
I'm developing a WCF Service and I'm a little confused about where its consuming its configurations.
I have an app.config file in my host application (console application) and in my WCF Service project (came with the template)
In run time I can see that configurations from both files are used.
How does it work? Why does the WCF library project (a dll project) contains an app.config file and what is it's purpose?
I can really use some clarifications about this ...
Update
this is the WCF configuration from my app.config in the host application
<system.serviceModel>
<!-- services -->
<services>
<service name="Services.CalcService">
<endpoint address="net.tcp://localhost:8412/MyCalcService"
binding="netTcpBinding"
bindingConfiguration="MyNetTcpBinding"
contract="Contracts.ICalc"/>
</service>
</services>
<!-- bindings -->
<bindings>
<netTcpBinding>
<binding name="MyNetTcpBinding"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Streamed"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
This is my WCF configuration from my WCF service library
<system.serviceModel>
<services>
<service name="Services.CalcService">
<endpoint address="" binding="basicHttpBinding" contract="Contracts.ICalc">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/Services/CalcService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
Thanks,
Omri.
How does it work?
Only the configuration file of the host application is used.
Why does the WCF library project (a dll project) contains an app.config file
If it is in a class library I guess it's the VS template that added it.
what is it's purpose?
It could be used by the WCF Service Host (WcfSvcHost.exe) when you run the WCF service library with F5 in Visual Studio.
When trying to call a function on the WCF Service i getting the error:
There was no endpoint listening at http://XXXXXXXXXXX.xxx/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.
My WCF Service Web.config
<system.serviceModel>
<services>
<service name="Service1" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint contract="IService1" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
WCF Client app.config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MetadataExchangeHttpBinding_IService1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://XXXXXXXXXXX.xxx/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="MetadataExchangeHttpBinding_IService1"
contract="API.IService1" name="MetadataExchangeHttpBinding_IService1" />
</client>
</system.serviceModel>
I have tried many many settings and configurations but dont getting this to work... do anyone find anything you think i missed?
Edit: I am hosting the service on a IIS and using a Winform client
You seem to have confused with service endpoint and mex endpoint. They are separate endpoints.
Change your config on server to this:
<endpoint contract="IService1" binding="wsHttpBinding" address="" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
Then recreate proxy.
I tried to find some solution on my own, but I failed. I have WCF web service hosted under virtual directory in IIS
http://host/soap/myservice.svc
Soap services are placed under REST services
http://host - REST services address
When I am trying to execute methods from the WCF service I get this error (on server side):
Failed to lookup a channel to receive an incoming message. Either the endpoint or the SOAP action was not found.
When I host the WCF service on the same IIS, but as an standalone application
http://host:81
everything works fine. But I need them to be under those REST services.
Here is client web.config generated by svcutil:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://host/soapservices/MyService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
contract="IMyService" name="WSHttpBinding_IMyService">
<identity>
<servicePrincipalName value="host/host" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Here is web.config of soap service:
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MyServiceName">
<host>
<baseAddresses>
<add baseAddress="http://host/SOAPServices/MyService/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="IMyService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
I created a WCF Service and its using SSL. I can compile and start the service. However, I cannot hit it in the web browser. All it says is "The connection to 192.168.1.12 was interrupted." I made sure my browser has it enabled and it works on other sites using SSL. I'm new to WCF services so any advice or tips for troubleshooting would be helpful.
I am not using IIS**
Below is my web config information:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSHttpBinding_IApplicationService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="6553600" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="Application.ServiceModel.ApplicationService" behaviorConfiguration="ApplicationServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://192.168.1.12:8000/ApplicationServiceModel/service" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="WSHttpBinding_IApplicationService" contract="Application.ServiceModel.IApplicationService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ApplicationServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
A self signed certificate is normally considered invalid, and only really used for test.
In wcf, you can use the following to ignore certificate errors (on the client).
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
However, it should only be used for test. In a production environment you want to get your certificate signed by a trusted cert authority.
I have a WCF service hosted within a Windows service. The client that is connecting to it is on the same machine so I would expect it to take long to connect and definitely not timeout. For some reason when I start the client and it tries to connect to the service it times out. This only happens occasionally, but enough where it is annoying since the entire app relies on a good connection tot he service. What could cause a client on the same machine as the service time out when connecting? Here are the app.config files from the host and the client.
Here is the client config:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:30"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService"
contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
And the service config:
<system.serviceModel>
<services>
<service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
<endpoint address="" binding="wsDualHttpBinding" contract="WCF.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Is there anything I can do to make the client connect better and make the the connection more stable in general? Change the binding? Anything?
Try to add one more endpoint with "netNamedPipeBinding" that was originally designed for local calls.