WCF is deployed on IIS7 and access over the network AND Website(ASP.NET C#) is also deployed on same server. Over the network WCF communicate successfully but On localhost server WCF does not communicate with website.
my configuration for wcf is
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWITSService" closeTimeout="00:00:05"
openTimeout="00:00:05" receiveTimeout="00:10:00" sendTimeout="00:00:05"
bypassProxyOnLocal="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">
<transport clientCredentialType="Windows" proxyCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:4570/WITSWCFService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWITSService"
contract="WITS.IWITSService" name="BasicHttpBinding_IWITSService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
AND Website Configuration is given below
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWITSService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="524288">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<!--<webHttpBinding>
<binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</webHttpBinding>-->
</bindings>
<services>
<service name="WITSService.WITSService">
<clear />
<endpoint binding="basicHttpBinding" contract="WITSService.WITSService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Are running on localhost only or localhost:4570. If you are using port 4570 you'll need to open it up on a real server.
What does the WCF endpoint return if you hit the URL in the browser, that is usually very telling of the problem.
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.
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.
I have a WCF Service that has these configuration settings. When I call it from a client application I still hit the dreaded, "Maximum number of items that can be serialized or deserialized in an object graph is '65536'" What's wrong with my configuration below?
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="LargeBuffer" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="TestWcfService.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="LargeBuffer" name="ServiceEndPoint"
contract="TestWcfService.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Yes I increased it on the client side to match. And it still hits that limit. My concern is that when it pulls the service reference back, it still sees 65536 as the default size so it never recognizes the larger amount. Any thoughts?
Here's my client side code:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="ServiceEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<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://localhost:61423/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="ServiceEndPoint" contract="LucasImport.IService1"
name="ServiceEndPoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
I'm trying to consume a Service with an WCF Console Application. But the only thing I get as a Response is "The remote server returned an unexpected response: (400) Bad Request."
The Service is configured with the following options:
<services>
<service name="TryOut.BasicService" behaviorConfiguration="NicksBasicBehavior">
<host>
<baseAddresses>
<add baseAddress="http://192.168.10.67:8000/Service" />
</baseAddresses>
</host>
<endpoint address ="http://192.168.10.67:8000/Service"
name="NicksEndpoint"
binding="basicHttpBinding"
contract="TryOut.IBasicService"
bindingConfiguration="BasicBinding"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="NicksBasicBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<binding name="BasicBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
The configuration file of my Client is the following:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NicksEndpoint" 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="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.10.67:8000/Service" binding="basicHttpBinding"
bindingConfiguration="NicksEndpoint" contract="ServiceReference1.IBasicService"
name="NicksEndpoint" />
</client>
Now everything works fine when I'm starting the client on the same PC as the service. But if I'm try to running the Client on a machine which is not in the domain of the server PC then I get an error, although I provide the Login information's in the client code:
c.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Nick", "password", "mydomain");
Does anybody got an idea what I'm doing wrong and how can I fix it? Thanking you in anticipation!
According to this article on MSDN, it looks as if you need to specify your credentials differently:
WCFTestService.Service myService = new WCFTestService.Service();
myService.Credentials = System.Net.CredentialCache.DefaultCredentials;
MessageBox.Show(myService.GetData(123, true));
myService.Dispose();
Could you try to use this code and try to pass the Windows credentials into myService.Credentials ? Does that work?
Marc
have you tried specifing the userPrincipalName in the identity element on your clients endpoint?