https with WCF error: "Could not find base address that matches scheme https" - wcf

I go to https://mywebsite/MyApp/Myservice.svc and get the following error:
(The link works if I use http:// )
"The service '/MyApp/MyService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].."
EDIT: So if I change address="" to address="https:// ..." then I get this error instead:
"Error: The protocol 'https' is not supported..... The ChannelDispatcher at 'https://.../Annotation.svc' with contract(s) '"Annotation"' is unable to open its IChannelListener."
Here's what my Web.Config looks like:
<services>
<service behaviorConfiguration="AnnotationWCF.AnnotationBehavior"
name="AnnotationWCF.Annotation">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Annotation"
contract="AnnotationWCF.Annotation" />
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="SecureTransport"
contract="AnnotationWCF.Annotation" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Annotation" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
<binding name="SecureTransport" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>

I had this exact same problem. Except my solution was to add an "s" to the binding value.
Old:
binding="mexHttpBinding"
New:
binding="mexHttpsBinding"
web.config snippet:
<services>
<service behaviorConfiguration="ServiceBehavior" name="LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService">
<endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding"
contract="LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>

It turned out that my problem was that I was using a load balancer to handle the SSL, which then sent it over http to the actual server, which then complained.
Description of a fix is here: http://blog.hackedbrain.com/2006/09/26/how-to-ssl-passthrough-with-wcf-or-transportwithmessagecredential-over-plain-http/
Edit: I fixed my problem, which was slightly different, after talking to microsoft support.
My silverlight app had its endpoint address in code going over https to the load balancer. The load balancer then changed the endpoint address to http and to point to the actual server that it was going to. So on each server's web config I added a listenUri for the endpoint that was http instead of https
<endpoint address="" listenUri="http://[LOAD_BALANCER_ADDRESS]" ... />

Make sure SSL is enabled for your server!
I got this error when trying to use a HTTPS configuration file on my local box which doesn't have that certificate. I was trying to do local testing - by converting some of the bindings from HTTPS to HTTP. I thought it would be easier to do this than try to install a self signed certificate for local testing.
Turned out I was getting this error becasue I didn't have SSL enabled on my local IIS even though I wasn't intending on actually using it.
There was something in the configuration for HTTPS. Creating a self signed cert in IIS7 allowed HTTP to then work :-)

I think you are trying to configure your service in a similar way to the following config. There is more information here: Specify a Service with Two Endpoints Using Different Binding Values. Also, other than for development, it's probably not a good idea to have both HTTP & HTTPS endpoints to the same service. It kinda defeats the purpose of HTTPS. Hope this helps!
<service type="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
<endpoint
address="http://computer:8080/Hello"
contract="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
binding="basicHttpBinding"
bindingConfiguration="shortTimeout"
</endpoint>
<endpoint
address="http://computer:8080/Hello"
contract="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
binding="basicHttpBinding"
bindingConfiguration="Secure"
</endpoint>
</service>
<bindings>
<basicHttpBinding
name="shortTimeout"
timeout="00:00:00:01"
/>
<basicHttpBinding
name="Secure">
<Security mode="Transport" />
</basicHttpBinding>
</bindings>

In my case i am setting security mode to "TransportCredentialOnly" instead of "Transport" in binding. Changing it resolved the issue
<bindings>
<webHttpBinding>
<binding name="webHttpSecure">
<security mode="Transport">
<transport clientCredentialType="Windows" ></transport>
</security>
</binding>
</webHttpBinding>
</bindings>

I was using webHttpBinding and forgot to dicate the security mode of "Transport" on the binding configuration which caused the error:
<webHttpBinding>
<binding name="MyWCFServiceEndpoint">
<security mode="Transport" />
</binding>
</webHttpBinding>
Adding this in configuration fixed the problem.

Look at your base address and your endpoint address (can't see it in your sample code). most likely you missed a column or some other typo e.g. https// instead of https://

Related

Changing protocol from net.tcp to http, Wcf, gives me the error "No corresponding start element is open"

I am required to update the endpoints from net.tcp to http and all of them work fine except for one.
Configuration on the client web config side is as follow.
<endpoint address="http://myseriesservices/Quote.svc" behaviorConfiguration="DynamicTransportBehavior" binding="wsHttpBinding" bindingConfiguration="httpConfiguration" contract="EbqQuoteServiceReference.IQuote" name="Quote" />
<!--<endpoint address="net.tcp://myseriesservices/Quote.svc" behaviorConfiguration="DynamicTransportBehavior" binding="netTcpBinding" bindingConfiguration="Quote" contract="EbqQuoteServiceReference.IQuote" name="Quote" />-->
and wsHttpBinding
<wsHttpBinding>
<binding name="httpConfiguration" maxReceivedMessageSize="10485760" openTimeout="00:01:00" receiveTimeout="00:05:00" sendTimeout="00:05:00">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
and this is the configuration on the server side.
<service behaviorConfiguration="MexBehavior" name="OM.Mec.BF.Ebq.Quote">
<endpoint address="" bindingConfiguration="BasicHttpBinding_Large" name="BasicHttpBinding_Large" binding="wsHttpBinding" contract="OM.Mec.SC.Ebq.IQuote" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<!--<endpoint address="" bindingConfiguration="NetTcp_StreamingResponse" name="Quote" binding="netTcpBinding" contract="OM.Mec.SC.Ebq.IQuote" />
<endpoint address="Mex" binding="mexTcpBinding" bindingConfiguration="" name="QuoteService.MexBinding" contract="IMetadataExchange" />-->
<host>
<baseAddresses>
<add baseAddress="http://myseriesservices/Quote.svc" />
<!--<add baseAddress="net.tcp://myseriesservices/Quote.svc" />-->
</baseAddresses>
</host>
</service>
and BasicHttpBinding_Large
<binding name="BasicHttpBinding_Large" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" 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>
What could the reason be for getting this error?
I debugged on the backend and a call is made to the DB successfully but at the point of returning the data to the client it fails. net.tcp if fine, it only fails with http
There can be one of these reasons for this error
I think your call is failing due to the size of the object which you return from your service.
A second reason could be the serialization settings of your service as Net TCP (BinarySerializer) and HTTP (DatacontractSerializer) bindings use different serialization by default.
Solution for big size response would break your response in chunks and send it over HTTP. You can refer this link https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/chunking-channel
Which way did you use to host the service? If IIS is, we should not add the base address in the configuration since we should add the base address in the IIS site binding module.
Besides, it seems that the binding configuration is not coherent between the server and the client.
I suggest you call the service on the client side by using Adding service reference to generate the client proxy class, like below.
It could maintain the consistency of the binding configuration between the client and the server.
Feel free to let me know if the problem still exist.

Deploying a WCF service that uses netTcpBinding (not IIS hosted)

I'm developing a client-server app using WCF over the netTcpBinding.
My solution has 2 projects, the client one and the server one.
So far I've learnt that in order to get the WCF service working I have to do some configuration on the app.config file. This I did and things are working fine.
But now I have a problem finding out what to do when I deploy the service to a server, in order for the client to connect. My problem is that I don't know what I have to modify in the app.config (or any other location) when I deploy the service in to a location other than "localhost".
Here is my server app's app.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MMServidor3.ServidorCliente">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="MMServidor3.iServicioMM">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:4005/MMServidor3/" />
<add baseAddress="net.tcp://localhost:4006/MMServidor3/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The "mex" endpoint and the http protocol base address are there in order for the client to get the metadata (I couldn't get it otherwise).
So, since I don't know beforehand what the IP address is where I'm going to deploy the server, I'd like the endpoint be read from a config or ini file (I would rather not have to compile for each endpoint).
Also, what do I have to modify on the client side? Here is the relevant section of the client app.config:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_iServicioMM" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" 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" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:4006/MMServidor3/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_iServicioMM" contract="MMServicioServidor.iServicioMM"
name="NetTcpBinding_iServicioMM">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Any advice would be appreciated!
Config files are specific to an environment. Typically, you'll change (if needed) the localhost bit in service addresses to an IP address or name.
For clients it's the same. A production-client should be configured in its production environment to use the URL of the production service. Of course you can't configure the client until you know where the service will be located*.
Unfortunately you'll have to specify the URL for each client endpoint individually, for more info have a look at this related question. One alternative you could work out, is implementing your own setting for a client side "BaseAddress", and use that to programmatically specify endpoint addresses.
* If you're after some more extreme flexibility in locating services and clients, you could look into WCF Discovery mechanisms.
** As another side note, if you're looking to automate creating config files for different environments I can recommend using (for example) SlowCheetah.

TCP error code 10013 Cross Domain Policy Error with netTcpBinding Service and Silverlight Client

Was wondeirng if anybody could get me out of my cross domain policy hell.
I have a duplex WCF service which uses netTcpBining, and the client is a Silverlight 4 app. When I self host the service, then it works perfectly and my Silverlight clients can consume the service with no problems. However when I host it in IIS 7, that's when the trouble starts. When I host it in IIS I'm able to see the service at:
http://localhost/Conference/VideoConferenceService.svc
And when I add a reference to the service which is hosted in IIS, and try to call it, I get a:
CommunicationException: Could not connect to
net.tcp://localhost/Conference/VideoConferenceService.svc. The
connection attempt lasted for a time span of 00:00:03.3071892. TCP
error code 10013: An attempt was made to access a socket in a way
forbidden by its access permissions.. This could be due to attempting
to access a service in a cross-domain way while the service is not
configured for cross-domain access. You may need to contact the owner
of the service to expose a sockets cross-domain policy over HTTP and
host the service in the allowed sockets port range 4502-4534.
Or if seeing the actual error helps inspire those who have seen it before, here is what it throws at me in Reference.cs:
I have checked out almost every solution suggested regarding solving the cross-domain policy error, and I've put my clientaccesspolicy.xml in my default website root in IIS, and also in wwwroot. I've also turned off all my firewalls. I'm able to see the policy at http://localhost/clientaccesspolicy.xml
and also at http://127.0.0.1/clientaccesspolicy.xml but I still get this error.
Here is my web.config for the service hosted in IIS 7:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<gcServer enabled="true" />
</runtime>
<system.web>
<compilation debug="false" />
</system.web>
<system.serviceModel>
<services>
<service name="VideoServer.VideoConferenceService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IVideoConferenceService" contract="VideoServer.IVideoConferenceService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:4502/VideoServer/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IVideoConferenceService" portSharingEnabled="true" transactionFlow="false" transferMode="Buffered" listenBacklog="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="24.20:31:23.6470000" openTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000" sendTimeout="24.20:31:23.6470000">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession enabled="false" />
<security mode="None">
<message clientCredentialType="None" />
<transport protectionLevel="None" clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="False" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
And here is the Silverlight client's ServiceReferences.ClientConfig file:
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="NetTcpBinding_IVideoConferenceService">
<binaryMessageEncoding />
<tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost/Conference/VideoConferenceService.svc"
binding="customBinding" bindingConfiguration="NetTcpBinding_IVideoConferenceService"
contract="ServiceReference1.IVideoConferenceService" name="NetTcpBinding_IVideoConferenceService" />
</client>
</system.serviceModel>
</configuration>
Has anybody got any suggestions? This annoying error has taken days of my time thus far.
Any help would be greatly appreciated.
EDIT
When I check the files being retrieved in my web sessions using fiddler, it shows that my browser is retrieving the client access policy file, so I think the error lies somewhere else and WCF is just throwing this error at me? I've also set IE9 to clear its cache everytime its close. Take a look below.
Well I just managed to get it working. Couple of points worth mentioning are that:
1. If you look at the erroneous ServiceReferences.ClientConfig that I posted above (generated by visual studio when I gave the service address as: http://localhost/Conference/VideoConferenceService.svc ) you can see that the netTcp port which is 4502, was not generated as part of the endpoint, this is what what causing the TCP error 10016 (EndpointNotFoundException) as well as TCP error 10013. The correct ServiceReferences.ClientConfig is actually:
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="NetTcpBinding_IVideoConferenceService">
<binaryMessageEncoding />
<tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:4502/Conference/VideoConferenceService.svc"
binding="customBinding" bindingConfiguration="NetTcpBinding_IVideoConferenceService"
contract="ServiceReference1.IVideoConferenceService" name="NetTcpBinding_IVideoConferenceService" />
</client>
</system.serviceModel>
</configuration>
2. When I was hosting my service in IIS 7, I was giving the port range 808:* as the netTcp ports, whereas I should have given 4502:* as the port range, like below:
Also from what I gathered, the website hosting the service should be on port 80, as Silverlight will look in localhost:80/ClientAccessPolicy.xml for the client access policy file.
And just for the record, for those who stumble across this same problem, this web.config managed to work in IIS:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="false" />
</system.web>
<system.serviceModel>
<services>
<service name="VideoServer.VideoConferenceService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IVideoConferenceService" contract="VideoServer.IVideoConferenceService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IVideoConferenceService" portSharingEnabled="false" transactionFlow="false" transferMode="Buffered" listenBacklog="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="24.20:31:23.6470000" openTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000" sendTimeout="24.20:31:23.6470000">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession enabled="false" />
<security mode="None">
<message clientCredentialType="None" />
<transport protectionLevel="None" clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
Also worth noting that you don't need to put any ports or base addresses in the web.config for IIS. It will create the service endpoint using the port 4502, I tried changing it to 4503, 4522 etc. and interestingly it didn't work with those ports, only with 4502.
We had a similar problem as specified in the original post. Just to help anyone who has not been able to resolve the issue with the solutions provided above, we found that the Windows firewall on the machine hosting the service was blocking the port we were trying to connect with net.tcp through. Once we allowed the traffic through the port on that software firewall our service started working as expected.
It may be worth checking any hardware firewall you might have in place as well to allow the ranges 4502-4530 I believe for net.tcp

How can I bypass Operation Contract limitation of a WCF Service when calling "Update Service Reference" in VS 2008

I am having trouble with a single Wcf Service that we have in an application. It has about 150 [OperactionContract] within it. I can now no longer Update Service Reference within Visual Studio 2008.
I receive all kinds of strange errors, varying from "Socket Forcibly Closed" to "Invalid Type" and other strange messages when I try to call an update. If I comment out 10-20 operations it works fine.
I have read all kinds of posts here, on MSDN, and many blogs. They all point to binding configurations that need to be changed, either on the main binding or on the MetadataExchange binding.
My problem is that I have tried all of this and have yet to get it to work reliably.
I am self hosting the service in an application, and that same application is also the client. They share the same configuration file (currently) because we are in the process of breaking the application into 2 pieces via the Wcf service layer.
Here is an excerpt showing my bindings I have defined:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IRhinoServices"
closeTimeout="00:05:00"
openTimeout="00:05:00"
receiveTimeout="00:15:00"
sendTimeout="00:05:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="100"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxConnections="100"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
</security>
</binding>
</netTcpBinding>
<customBinding>
<binding name="customMex">
<textMessageEncoding>
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<tcpTransport transferMode="Buffered"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8523/RhinoServices"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IRhinoServices"
contract="RhinoServicesReference.IRhinoServices"
name="NetTcpBinding_IRhinoServices">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service behaviorConfiguration="CounterSketchServer.RhinoServicesBehavior"
name="CounterSketchServer.RhinoServices">
<endpoint address=""
binding="netTcpBinding"
contract="CounterSketchServer.IRhinoServices">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="customBinding"
contract="IMetadataExchange"
name=""
bindingConfiguration="customMex"
listenUriMode="Explicit" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/RhinoServices" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CounterSketchServer.RhinoServicesBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I need to be able to generate the proxy class by clicking on Update Service Reference, which has worked well this past 2 weeks, till I hit this mysterious limit.
Most of the examples I have seen to resolve this talk about http bindings for mex, but I would like to stick with just netTcp if possible since I am self hosting.
Can anyone please help me?
Thank you.
* UPDATE *
I have tried #Aliostad suggestion, and it appeared to work well at first. Until I tried some of our Wcf calls which update UI elements. These happened to work when using NetTCP bindings with the Proxy Class generated by Visual Studios (Add Service Reference) tool. But when using the Channel Factory it does not work.
I have tried looking at the SyncrhonizationContext in Juval's WCF book, but nothing I did seemed to work.
I have tried using both Named Pipes and NetTCP as the binding for the Channel I create using the ChannelFactory, and they do seem to behave very differently from eachother related to long running Wcf operations, but neither work to update UI elements.
My services are actually running in a plugin for the Rhino 3D CAD engine, and ceratin calls (Render, etc.) trigger UI in Rhino to update. I assume this is causing a thread boundary issue. The exception I receive is:
attempted to read or write protected memory
If anyone has any suggestions to use the ChannelFactory method effectively in this scenario or to fix my problem with too many Operations in a given Wcf class to generate the Service Proxy I would appreciate your help.
Thank You!
First of all, I believe the only solution is to remove the reference, and add it back again.
Alternatively, if you own both the Client and the Service - which I seem to get from reading your question that you do - may I strongly suggest that you share you service interfaces with your clients - instead of using a service reference?
This is definitely the preferred approach when you own both client and the server (and will save you from all the troubles you are having) and I believe it is also preferred if you do not own the client, you just share the entities/dtos and the interfaces.
This requires you to:
Create a class library project for you entities/dtos. Share it with the client.
Create a class library project for you service interfaces. Share it with the client.
Create a class library project for you service implementation. Stays only on the server.
The client uses ChannelFactory<T> to create factory and then create a proxy by calling CreateChannel()
I have got the Update Service Reference working again from both SvcUtil.exe and from Visual Studio 2008.
To do so I added the following section to the config files for both devenv.exe.config and SvcUtil.exe.config:
<!-- CUSTOM MetaDataExchaning Binding to all for LARGE WCF Services -->
<client>
<endpoint name="net.tcp" binding="netTcpBinding" bindingConfiguration="GenericBinding"
contract="IMetadataExchange" />
<endpoint name="http" binding="wsHttpBinding" bindingConfiguration="SecureBinding" contract="IMetadataExchange" />
</client>
<bindings>
<netTcpBinding>
<binding name="GenericBinding" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None"/>
</binding>
</netTcpBinding>
<wsHttpBinding>
<binding name="SecureBinding" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Message">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
Then in my application Server plugin, I am still programmatically creating the ServiceHost so to enable meta data exchange I added another endpoint:
// DATA ENDPOINT
NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport, true);
Uri baseAddress = new Uri("net.tcp://localhost:8555/RhinoServices");
_rhinoServicesHost = new ServiceHost(typeof(RhinoServices), baseAddress);
_rhinoServicesHost.AddServiceEndpoint(typeof(IRhinoServices), binding, baseAddress);
// META ENDPOINT
BindingElement bindingElement = new TcpTransportBindingElement();
CustomBinding customBinding = new CustomBinding(bindingElement);
ServiceMetadataBehavior metadataBehavior = _rhinoServicesHost.Description.Behaviors.Find<ServiceMetadataBehavior>();
if (metadataBehavior == null)
{
metadataBehavior = new ServiceMetadataBehavior();
_rhinoServicesHost.Description.Behaviors.Add(metadataBehavior);
}
_rhinoServicesHost.AddServiceEndpoint(typeof(IMetadataExchange), customBinding, "MEX");
_rhinoServicesHost.Faulted += RhinoServicesHost_Faulted;
_rhinoServicesHost.Open();
I can now update the references regardless of the number of contracts.
I have to admit though, during this whole process the Attempted to read or write protected memory error that cropped up hasn't gone away since I switched back to this method.
So I guess I have to still track that down...
Also I found this solution on a different question (click to view), answered by #trendl. Thank you for your help.

WCF - "There was no endpoint listening at..." error

I have two applications that I want to test locally on the same machine. App 1 has a simple WCF service with the folloiwng config entry:
<service behaviorConfiguration="MyNamespace.ContainerManagementServiceBehavior"
name="MyNamespace.ContainerManagementService">
<endpoint address="ContainerManagementService" binding="basicHttpBinding"
name="ContainerManagementbasicHttpEndpoint"
contract="MyNamespace.IContainer" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/ContainerManagementService" />
</baseAddresses>
</host>
</service>
<behaviors>
<behavior name="MyNamespace.ContainerManagementServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</behaviors>
I start the service by running the web application project where it is hosted. I am able to successfully browse to the url and get web service information page from ie. I copy the same URL and use it for my client.
My other client, App 2, has the following in its config file:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00"
sendTimeout="00:10:00" allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="5242880" maxBufferPoolSize="524288"
maxReceivedMessageSize="5242880" messageEncoding="Text"
textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="5242880" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost:3227/Services/ContainerManagementService.svc"
binding="basicHttpBinding" bindingConfiguration="basicHttp"
contract="MyService.IService" name="externalService" />
</client>
</system.serviceModel>
However, when I try to execute a WCF call form client to the running service, I get the following error message:
There was no endpoint listening at
http://localhost:3227/Services/ContainerManagementService.svc
that could accept the message. This is often caused by an incorrect
address or SOAP action. See InnerException, if present, for more details.
What could be happening?
It looks likes the issue is due to the fact that both server and client are being run from the Cassini server. I am changing the architecture to host the server endpoint in IIS.
Do you have two applications ?
One which hosts the server endpoint and the other which is the client ? Are both active in IIS (considering the second application is a web app) ?
If you have two projects for those two components in your solution, you can configure VS to start both project at the same time. This way you can put breakpoints on both the client and the server and see if the server really gets called by the client or if the exception happens without the server method being called.
If your web service is on: http://localhost:8000/ContainerManagementService.svc
Your client app2 should point on this same addres:
<client>
<endpoint address="http://localhost:8000/ContainerManagementService.svc"
binding="basicHttpBinding" bindingConfiguration="basicHttp"
contract="MyService.IService" name="externalService" />
</client>