I have a class library that is supposed to build a connection to an existing named-pipes server. The error I get is:
Could not find endpoint element with name 'internal' and contract 'SelectedStudentReference.ISelectedStudent' 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 name could be found in the client element.
Here is xml from dll.config:
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="internal" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport protectionLevel="EncryptAndSign" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<client>
<endpoint address="net.pipe://localhost/SelectedStudent" binding="netNamedPipeBinding"
bindingConfiguration="internal" contract="SelectedStudentReference.ISelectedStudent"
name="internal">
<identity>
<userPrincipalName value="name#company.org" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Here is the code I use to instanciate the client, and also where it throws the error:
using AwardManager.SelectedStudentReference;
if (_client == null) _client = new SelectedStudentClient("internal");
I know the server is running and the error message only mentions the client failure. Is there any problem doing this from a class library? The install program did not copy the .config out with the dll, I did that manually, so I'm not sure the .dll is paying attention to the .config.
This is a registered COM-visible dll that is instanciated and called by another process. I'm not able to add this system.serviceModel to the .config for that other process.
I could build the client in code, if that would work and I had some examples of how to accomplish that.
I could also use some help with the userPrincipleName. It doesn't seem correct for it to use my credentials. Shouldn't it specify the user's credentials, or some generic credentials? Does it even need to be included in the client configuration?
Thanks
This stuff needs to be in the config for the exe that hosts your DLL. A DLL does not have a stand-alone config - or at least .NET does not read it unless you do something custom.
If you can't modify the hosting EXEs config, you're probably going to have to build this configuration in code.
Related
I have two web sites-- one with an aspx file, one with a wcf service with two end points, one http and one named pipes. They both run on the same machine, so they seemed like a candidate for using the net.pipe binding.
The aspx file creates a service client and attempts to call the net.pipe. And I get this:
"Server Error in '/dev' Application.The message could not be
dispatched because the service at the endpoint address
'net.pipe://localhost/netNamedPipeBinding' is unavailable for the
protocol of the address."
Googling suggest this could be a security problem (no permissions errors are the same as no listener errors), but I've already granted NTFS rights to the [NETWORK] user group to the websites files with the services and no change.
The site with the aspx is using Forms authentication (i.e. not windows auth) and the service website is anonymous auth. The web.config's have the net.pipe security set to ="None"
Locally, this works fine-- although I have to run the named pipes host in a console app since the Visual Studio Dev Server can't do named pipes. Also, the Http endpoint works fine on IIS.
It's running .NET 4.0, IIS 7.5, Win2008.
IIS Config
As far as I can tell,
net.pipe has been enabled for the service website, with config info of *
WAS is installed and enabled, (via windows features)
the net.pipe listener Windows service is enabled.
Each website is anonymous access (auth is done by a 3rd party single sign on sever)
Each website has it's own app pool (probably not relevant)
The service site is in web garden mode (probably not relevant)
Service Config (Running on IIS on same machine, different VDIR)
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="netNamedPipeBindingConfig" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport protectionLevel="EncryptAndSign" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<services>
<service name="MyService">
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/" />
</baseAddresses>
</host>
<endpoint
address="netNamedPipeBinding"
bindingConfiguration="netNamedPipeBindingConfig"
binding="netNamedPipeBinding"
contract="IMyService" >
</endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Client Config (ASP.NET website, same machine, different VDIR from service)
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NetNamedPipeBinding_IMyService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport protectionLevel="EncryptAndSign" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<client>
<endpoint
address="net.pipe://localhost/netNamedPipeBinding"
binding="netNamedPipeBinding"
bindingConfiguration="NetNamedPipeBinding_IMyService"
contract="MyService.IMyService"
name="NetNamedPipeBinding_IMyService">
</endpoint>
</client>
</system.serviceModel>
(Service & contract names changed to protect the innocent)
The C# isn't anything special, just the Add-Service-Reference generated proxy. (And all that code works fine with the wsHttp binding
You cannot set the base address of a named pipe when it is hosted in IIS in this fashion. As a result the service can not be found by the client. Look at the answer here for more details:
controlling-the-name-of-a-named-pipe-when-hosting-wcf-net-pipe-binding-in-iis
I am calling my WCF service from excel VBA code using moniker string. However, as my service returns large data as response, excel gives error message
"Maximum message size quota for incoming messages (65534) has been exceeded. To increase the quota used the MaxReceivedMessageSize property on the appropriate binding element"
Here is the moniker string:
addrToService = "service4:mexAddress=""net.tcp://localhost/MyApp/API/Excel/ExcelAPIService.svc/mexTCP"", "
addrToService = addrToService + "address=""net.tcp://localhost/PruCapWebCMHost/API/Excel/ExcelAPIService.svc"", "
addrToService = addrToService + "contract=""IExcelAPIService"", contractNamespace=""http://Prucap/Services"", "
addrToService = addrToService + "binding=""NetTcpBinding_IExcelAPIService"", bindingNamespace=""http://MyApp/Services"""
To resolve this, I increased the size in my WCF service's web.config file as shown below:
<netTcpBinding>
<binding name="NetTcpBinding_IPublicService" maxBufferPoolSize="8388608" maxBufferSize="8388608" maxReceivedMessageSize="8388608" portSharingEnabled="true">
</binding>
</netTcpBinding>
<basicHttpBinding>
<binding name="BasicHttpBidning_IPublicService" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="00:05:00" maxReceivedMessageSize="8388608" />
<binding name="BasicHttpBidning_ISecureService" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="00:05:00" maxReceivedMessageSize="8388608" />
</basicHttpBinding>
....
<service name="ExcelAPIService" behaviorConfiguration="PublicServiceTypeBehaviors">
<endpoint address="" bindingNamespace="http://MyApp/Services" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IPublicService" contract="API.Service.ExcelAPI.IExcelAPIService" name="NetTcpBinding_IExcelAPIService" />
<endpoint address="" bindingNamespace="http://MyApp/Services" binding="basicHttpBinding" bindingConfiguration="BasicHttpBidning_IPublicService" contract="API.Service.ExcelAPI.IExcelAPIService" name="BasicHttpBidning_IExcelAPIService" />
<endpoint address="mex" bindingNamespace="http://MyApp/Services" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="mexTCP" bindingNamespace="http://MyApp/Services" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
</service>
According to various forums on this topic, the above solution should work. But this does not work in my case when called from excel. Is there anything I need to do from excel side to set the maxReceivedMessageSize? If yes then how can I do this using VBA code?
Additional information:
I use Office 2010 (with VBA), Windows 7 Prof, 64bit OS
The maximum size must be set by the client as well as the server. However, the service moniker form you are using does not support specifying this parameter.
From first hand experience I can tell you, using monikers may seem appealing at first, since it allows you to call services from VBA with minimal coding, but it is very limited in what it can do. I discovered, as no doubt you are in the process of dicovering as well, the best way to approach this is to build a proper WCF client - probably in .NET - and call the client class from your VBA, or even Excel directly.
If you are trying that and are still having trouble, please start a new thread so you can post your code, and more fully explain what you have tried, and what the problem is.
You should set maxReceivedMessageSize="2147483647" to increase message size.
Try increasing message size like:
<binding maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
--OR
<basicHttpBinding>
<binding name="BasicHttpBinding_IManagementService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
refer WCF Error "Maximum number of items that can be serialized or deserialized in an object graph is '65536'"
Wcf-The maximum message size quota for incoming messages (65536) has been exceeded?
UPDATE
You also can change endpoint/service behavior programatically.
Refer links:
How to: Specify a Service Binding in Code
How to: Programmatically Configure a WCF Endpoint
Update2:
Sorry Anil, Previously I totally overlook you are doing this in excel.
The easiest way for your scenario to use WCF service from VB6 is to create a .Net ComObject wrapper for the service client. Then in VB6 all your are doing is a create object and calling some methods on the object. All the WCF work takes place in the .Net com object.
Simply create the WCF client to the service in a separate project as described in this link. Register the .NET assembly as a type library which you would then link from the VB6 app : link.
Sources:
Using WCF in VB6
Integrating WCF Services with COM+
Communicate with WCF Windows Service in VB6?
Hope it helps. :)
i am new in WCF but i am bit familiar with web service (ASMX file)
i have couple of question on wcf client config entry
when we create any web service (ASMX) proxy then nothing add in config file like below entry but in case of WCF the below entry adds. i just need to know the significant of the below entry.
1) if i delete these below entry then what will happen....can't i call the service from the client side?
2) just tell me when we call web service from client side then how do i say that which endpoint address my service will use to call service if there are more than one endpoint address added in client side ?
3) how do i explicitly mention web service url from cient side when i will make a service call?
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_ICommService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:00:05"
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/CommService/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ICommService"
contract="Services.ICommService" name="WSDualHttpBinding_ICommService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Yes these are important configuration that are required by WCF. Either you provide it through config file or your code.
1) You need to provide it some where. If you take them fro config . You should be doing it in code.
2) WCF has basic rule of ABC . Address , Binding and Contract. Again you don't have to say anything if its already in your config file.
For multiple clients . You can also mention the endpoint name from your config file. ForExample
MyClient someClientObject = new MyClient("WSDualHttpBinding_ICommService");
3) By default, when you Add Service Reference operation, WCF Runtime gets you a client side proxy .
You can do it like this in a simple way. ParameterLess.
MySVCClient svcproxy = new MySVCClient ();
You need to have entry with your service contract .
You can also use as follows with constructor ... using endpoint Adddress and Bidning etc.
BasicHttpBinding myBinding= new BasicHttpBinding(SecurityMode.None);
EndpointAddress endpointAdd= new EndpointAddress("http://localhost/CommService/");
MySVCClient svcproxy = new MySVCClient (myBinding, endpointAdd);
Since you are defining everything in code here. You don't need anything in config file.
I've successfully published a WCF service on our production server. I can navigate to the page and see the default WCF page.
I can add the service via "Add Service Reference" to a client on my computer. I can also "Update Service Reference" with no problems what so ever.
The service was confirmed to work on my local computer with and without the client by running the default debugger that comes with VS2010.
When trying to call a service method (from the server hosted service), I receive this exception..
There was no endpoint listening at that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
InnerException...
{"The remote server returned an error: (404) Not Found."}
I've also tried running a client on the server itself to see if I can connect but I get the same error.
I even tried just deploying the basic WCF service that's created for you when you create a WCF service library (very basic), changed nothing, deployed successfully, and get the same error.
What am I doing wrong? I've went down the road of IIS configurations, SSL certificates, etc but nothing seems to fix it. I feel as though I'm missing something very basic here.
EDIT CLIENT CONFIG...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" 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>
</bindings>
<client>
<endpoint address="http://SERVER_NAME.DOMAIN_NAME.com/TestService/TestService.Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
Some pitfalls to check:
1) Check if the service URL is correct on your configuration files. This includes the protocol. It happened to me recently: the .config file had "http://" and the webserver was only accessible through HTTPS.
2) Disable the "required client certificate" setting on IIS.
3) If your service is inside an asp.net application, check if there are any restrictions of Authentication / Authorization in place. Allow anonymous access to your .SVC
I'm trying to figure out how to set up my web.config (the client) to consume two different WCF web services one using the other using
I have the two endpoint, I guess I need two different Binding configurations. This is my current binding node:
<basicHttpBinding>
<binding name="WebServiceProxyServiceSoapBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
I can't add another basicHttpBinding node. The thing is if ALL I changed was the mode parameter in <security mode="Transport"> then the binding will work great for one or the other endpoint.
This seems like a common issue, but have not found an answer. Overall I'm not very experiences with WCF (if that is not obvious) outside the simple consume and call. Any help would be GREAT!
This article was close but not quite the same issue as they did not need a different security mode.:
How to consume multiple WCF services from one client
Thanks in advance.
You just need to add another <binding> node, with a different name and whatever different options you like, under the <basicHttpBinding> node.
Then, obviously, just make sure each client is configured to use the binding that's specific to them by setting the appropriate name in the bindingConfiguration attribute for each <endpoint> node.
I have the two endpoint, I guess I
need two different Binding
configurations. This is my current
binding node:
Not necessarily - if these two services use the same settings and same protocols, one binding configuration will do.
What you need to add two of is a client element:
<system.serviceModel>
<bindings>
..... (as you already have it) ....
</bindings>
<client>
<endpoint name="Service1Endpoint"
address="http://yourserver/service1.svc"
binding="basicHttpBinding"
bindingConfiguration="WebServiceProxyServiceSoapBinding"
contract="IWCFService1" />
<endpoint name="Service2Endpoint"
address="http://yourserver/service2.svc"
binding="basicHttpBinding"
bindingConfiguration="WebServiceProxyServiceSoapBinding"
contract="IWCFService2" />
</client>
</system.serviceModel>
That should do.
Of course, if your second service uses another binding, or needs different security settings, then yes, you'd need to add a second <binding name="something else" .....> under your <basicHttpBinding> node and reference that second binding configuration from one of your two client endpoints here.