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.
Related
We have a service
RENEWAL (service run in cl-app1) using a service "UQPDF" (using https://abc/Html2Pdf.svc in server cl-web1)
when I try to publish RENEWAL with same content but a staging version of
it in cl-app2 using a staging service "UQPDF" (using https://abc-staging/Html2Pdf.svc in server cl-web2)
there is no error for production which is the one in cl-app1 and call cl-web1 pdf service,
and no problem running locally for staging RENEWAL.
the only problem is when I publish it in app2 using https://abc-staging/Html2Pdf.svc.
it throws the following exception
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Could not find default endpoint element that references contract 'EmailToPdf_Staging.IHtml2PdfService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
AppConfig of Renewal
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IHtml2PdfService" maxBufferPoolSize="20000000"
maxReceivedMessageSize="20000000" allowCookies="true">
<readerQuotas maxDepth="32" maxStringContentLength="200000000"
maxArrayLength="200000000" />
<security mode="Transport">
<transport clientCredentialType="None" />
<message clientCredentialType="None" negotiateServiceCredential="false"
establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://abc/Html2Pdf.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHtml2PdfService"
contract="EmailToPdf.IHtml2PdfService" name="WSHttpBinding_IHtml2PdfService" />
<endpoint address="https://abc-staging/Html2Pdf.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHtml2PdfService"
contract="EmailToPdf_Staging.IHtml2PdfService" name="WSHttpBinding_IHtml2PdfService" />
</client>
</system.serviceModel>
UQPDF Webconfig
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IHtml2PdfService" 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="6553600"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="65536000" maxArrayLength="65536000" maxBytesPerRead="4096"
maxNameTableCharCount="1638400" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="None" />
<message clientCredentialType="None"
negotiateServiceCredential="false"
establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Ubiquity.uSuite3.PdfServices.Html2PdfService" behaviorConfiguration="uqpdf.ServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHtml2PdfService"
contract="Ubiquity.uSuite3.PdfServices.IHtml2PdfService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="uqpdf.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I suspect that your client did not find your contract through your configuration file.You can refer to my configuration.
Here is my demo:
<client>
<endpoint address="http://localhost:8012/ServiceModelSamples/service"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="Client4.IService1" name="BasicHttpBinding_Client4" />
<endpoint address="http://localhost:8012/ServiceModelSamples/service"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="Client2.IService1" name="BasicHttpBinding_Client2" />
</client>
This is the configuration file of the endpoint,I suggest you do not set their names to the same.
ChannelFactory<Client4.IService1> Client4 = new ChannelFactory<Client4.IService1>("BasicHttpBinding_Client4");
Client4.IService1 chanel4 = Client4.CreateChannel();
ChannelFactory<Client2.IService1> Client2 = new ChannelFactory<Client2.IService1>("BasicHttpBinding_Client2");
Client2.IService1 chanel2 = Client2.CreateChannel();
We create different channels according to different endpoints to call services.
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.
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 hosted a .svc WCF in IIS 6.0. I added a reference to that web service in a winform application. However, when I call any method of my service I get a System.Net.WebException: The request failed with HTTP status 403: Forbidden.
I have the certificate installed in my personnal store.
Here's my server config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAwsService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://teclpo02.srr.fr:1098/AwsService/" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAwsService" contract="wsAws.IAwsService" name="BasicHttpBinding_IAwsService"/>
</client>
<services>
<service name="AuthWorkStation_Wcf_Web.AwsService" behaviorConfiguration="ServiceBehavior">
<endpoint name="" address="" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="AuthWorkStation_Wcf_Web.IAwsService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" revocationMode="NoCheck" />
</clientCertificate>
<serviceCertificate storeName="Root" findValue="CA_SRR_DISTRIB" x509FindType="FindBySubjectName" />
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
Do I have to edit my winform app.config file ? Do I have to write some line of code to tell where is the certificate ?
The problem is that you have transport security which requires SSL/Https. But your address is http.
Change your address to https
From the code you posted:
<client>
<endpoint address="http://teclpo02.srr.fr:1098/AwsService/" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAwsService" contract="wsAws.IAwsService" name="BasicHttpBinding_IAwsService"/>
</client>
<services>
You are also spesifying the port number that post could be blocked.
My WCF Service has an OperationContract that accepts, as a parameter, an array of objects. This can potentially be quite large. After looking for fixes for Bad Request: 400, I found the real reason: the maximum message size.
I know this question has been asked before in MANY places. I've tried what everyone says: "Increase the sizes in the client and server config files." I have. It still doesn't work.
My Service's web.config:
<system.serviceModel>
<services>
<service name="myService">
<endpoint name="myEndpoint" address=""
binding="basicHttpBinding"
bindingConfiguration="myBinding"
contract="Meisel.WCF.PDFDocs.IPDFDocsService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="myBinding"
closeTimeout="00:11:00"
openTimeout="00:11:00"
receiveTimeout="00:15:00"
sendTimeout="00:15:00"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647"
transferMode="Buffered"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
messageEncoding="Text"
textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
My Client's app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPDFDocsService"
closeTimeout="00:11:00"
openTimeout="00:11:00"
receiveTimeout="00:10:00"
sendTimeout="00:11:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8451/PDFDocsService.svc"
behaviorConfiguration="MoreItemsInObjectGraph"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IPDFDocsService"
contract="PDFDocsService.IPDFDocsService"
name="BasicHttpBinding_IPDFDocsService" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="MoreItemsInObjectGraph">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
What can I possibly be missing or doing wrong? It's as though the service is ignoring what I typed in the maxReceivedBufferSize.
Thanks in advance,
Kyle
UPDATE
Here are two other StackOverflow questions where they never received an answer, either:
https://stackoverflow.com/questions/2880623/maxreceivedmessagesize-adjusted-but-still-getting-the-quotaexceedexception-with
WCF MaxReceivedMessageSize property not taking
In the service config file, the "name" attribute is missing from the element
<behaviors>
<serviceBehaviors>
<behavior name="StackOverflow">
and there should be a reference to this name in the service element:
<system.serviceModel>
<services>
<service behaviorConfiguration="StackOverflow" name="myService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding"
In general, it's a good idea to validate, if not always edit, your WCF config files using the "WCF Service Configuration Editor", which is invoked from the Visual Studio "Tools" menu item.
Also there is no endpoint behavior defined for the service. I don't know if this matters.
I had the same problem with WCF Test and I had set corectly the config file. If isn't any problems from your config file, I suggest try to test the service with another program eg: SOAP UI, I think this error it's not from the service, it's from the WCF Test.