I have a sample wcf service,I want to one of endpoint is windows authenticated security ,My Config is like that ,In iis both windows and anynomous authentication is enabled.But I can call my endpoint directly,there is no user info my call code?What I am missing?I want to define multiple endpoints which can be accesible different authentication type for that reason I cannot close anonymous authentication.
My second question is,can endpoint work for specific user in windows authentication?
ServiceReference1.Service1Client sclient = new ServiceReference1.Service1Client();
var x= sclient.GetData(1);
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Service">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WsHttpBindingConfig" contract="IService">
<!--<identity>
<userPrincipalName value="xxxxxxx" />
</identity>-->
</endpoint>
</service>
</services>
<behaviors
I think, you should edit your contract name. It usually under your webservice package like this WebServiceName.IService
Related
I have a question about my soap services(wcf)
I implement my wcf service and all the function implement correctly at compile time
I do not have any compile time error but when i run my code I received this error message
An endpoint configuration section for contract 'test.ICore' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration
I think in soap services we need some change in web.config file
another point is that my project have multiple soap services.
may it cause a problem?
how can i solve this issue?
thank you so much
I think your problem is because of you have a multiple endpoint with the same address in your web.config file
like that
<binding name="TestSoap">
<security mode="Transport" />
</binding>
<binding name="TestSoap" />
<endpoint address="http://TestSoap/Core.svc/soap"
binding="basicHttpBinding" bindingConfiguration="Soap" contract="TestSoap.ICore"
name="TestSoap" />
<endpoint address="https://TestSoap/Core.svc/soap"
binding="basicHttpBinding" bindingConfiguration="TestSoap"
contract="TestSoap.ICore" name="TestSoap" />
you can use this example for your code.
I hople you can solve your problem
In general, an interface contract can be supported by multiple endpoints, but bindings and addresses can vary, such as this:
Server-side:
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<endpoint address="secure"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</service>
Client-side:
<client>
<endpoint name="basic"
address="http://localhost/servicemodelsamples/service.svc"
binding="basicHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<endpoint name="secure"
address="http://localhost/servicemodelsamples/service.svc/secure"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</client>
In the call:
CalculatorClient client = new CalculatorClient("basic");
Console.WriteLine("Communicate with basic endpoint.");
client = new CalculatorClient("secure");
Console.WriteLine("Communicate with secure endpoint.");
Feel free to contact me if have any issues.
I'm getting this dreaded message and have spent a fair bit of time reading about it but have still been unable to solve it
I have a console app running on my client trying to invoke a WCF service on a different machine. The service is running under a domain account. I believe under this scenario it tries to authenticate using Kerberos
I have also read that if you supply a dummy serviceprincipalname on the client
<servicePrincipalName value="MySystem/Service1"/>
then it will fall back to using ntml.
I have tried this without luck. If the client is on the same machine as the service then it works fine. Not sure what else I can try. Here is the config on my client
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_HelpersService" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://myserver/SPInterface/HelpersService.svc/TCP" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_HelpersService"
contract="HelpersService" name="NetTcpBinding_HelpersService">
<identity>
<servicePrincipalName value="MySystem/Service1"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
What I also don't understand is that if I use the WCFTestClient in Visual Studio which generates the same config file from my local machine it works fine
My server config files has this in it:-
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add relativeAddress="HelpersService.svc" service="SPInterface.Models.HelpersService" factory="SPInterface.WebService.HelpersServiceHostFactory"/>
</serviceActivations>
</serviceHostingEnvironment>
<services>
<service name="SPInterface.Models.HelpersService" behaviorConfiguration="Debug">
<endpoint address="TCP" binding="netTcpBinding" bindingNamespace="http://Server/SPInterface/Services" contract="SPInterface.Contracts.IHelpersService"/>
<endpoint address="Rest" binding="webHttpBinding" bindingNamespace="http://Server/SPInterface/Services" contract="SPInterface.Contracts.IHelpersService" behaviorConfiguration="Rest"/>
</service>
</services>
</system.serviceModel>
The inner exception is "the target principal name is incorrect"
I have this scheme:
IIS
hosts: OperatorService.svc (connects to ClientService)
Global.asax (on start): hosts ClientService via ServiceHost
WPF client
connects to ClientService
If I go to OperatorService the service is activated, web application started, and ClientService is successfully hosted at http://localhost:8020/ClientService. So far so good.
I can now access the ClientService in the aforementioned URL in a browser, I can add it through Add Service Reference. It's simply there - running.
But when I try to connect via generated client (looks OK), it suddenly doesn't work. Throwing:
There was no endpoint listening at http://localhost:8020/ClientService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Moreover the OperatorService connects to this ClientService itself (it is a WsDualHttpBinding to provide notifications). It subscribes itself correctly to this service (calling a method) and it works (same URL as my WPF client).
Why can't I connect from my WPF client?
WPF client config (only relevant sections):
<client>
<endpoint address="http://localhost:8020/ClientService" binding="wsDualHttpBinding"
bindingConfiguration="DefaultBindingClientService" contract="Server.IClientService"
name="DefaultBindingClientService">
<identity>
<servicePrincipalName value="host/OHS-UPC" />
</identity>
</endpoint>
</client>
<bindings>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService" />
</wsDualHttpBinding>
</bindings>
IIS hosted web.config (for ClientService)
<service name="TelPro.OHS.Server.Services.ClientService" behaviorConfiguration="UnsecuredBehavior">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DefaultBindingClientService" contract="TelPro.OHS.Server.Services.IClientService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8020/ClientService"/>
</baseAddresses>
</host>
</service>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService"/>
</wsDualHttpBinding>
<behavior name="UnsecuredBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
IIS hosted web.config (for OperatorService -> ClientService)
<client>
<endpoint address="http://localhost:8020/ClientService" binding="wsDualHttpBinding"
bindingConfiguration="DefaultBindingClientService" contract="ClientNotificationServer.IClientService"
name="DefaultBindingClientService" />
</client>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService" />
</wsDualHttpBinding>
I was able to solve it by switching to port 80.
http://localhost/ClientService
Somehow that works. I've tried to add rules to port 8020 everywhere (even stopped firewall), checked any port forwarding, Azure endpoints, etc. My theory is that the problem when server is trying to connect back (callback) to client and has no rights or something. My guess would be that IIS hosted service doesn't have enough rights to connect back. If anyone can still shed some light on the why, I would gladly switch answer to them. But so far I'm just glad it works regardless the port.
I have very specific question..
If i create one WCF Service and it has multiple endpoints with the name how can i access that using browser ?
Also How can i access that in my client application via Add Service Reference ?
like my config code:
<services>
<service name="MultipleEndpoint.SampleService" behaviorConfiguration="MultipleEndpoint.SampleService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:55052/SampleService.svc"/>
</baseAddresses>
</host>
<endpoint address="/basic" binding="basicHttpBinding" contract="MultipleEndpoint.ISampleService" bindingConfiguration="basicBinding" >
</endpoint>
<endpoint address="/wsHttp" binding="wsHttpBinding" contract="MultipleEndpoint.ISampleService" bindingConfiguration="wsBinding" >
</endpoint>
<endpoint address="/webHttp" binding="webHttpBinding" contract="MultipleEndpoint.ISampleService" behaviorConfiguration="REST">
</endpoint>
</service>
</services>
Now, when i tried to access that using
http://localhost:55052/SampleService.svc/basic or
http://localhost:55052/SampleService.svc/wsHttp
it gives me page/ resource not found IE Standard Error Message...
Same time i like to know how would i add this type of url as a service reference in my client application ?
Those service addresses are different and they are not strictly needs to be brow-sable, means you can't browse a service for an endpoint like http://localhost:55052/SampleService.svc/basic. Those addresses are used to distinguish endpoints in communication.
If you see the wsdl of the service all the addresses of those endpoints are specified there.
If you create the proxy of the service through "Add Service Reference" all the endpoints are created in the configuration separately like..
<client>
<endpoint address="http://localhost:54671/Service1.svc/basic"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
<endpoint address="http://localhost:54671/Service1.svc/ws" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
name="WSHttpBinding_IService1">
</endpoint>
...
</client>
Say if you want to talk to the service using the basic http endpoint then you can create the proxy for that by passing the corresponding endpoint configuration name in the ctor.
Ex.
// this will uses the basic http endpoint.
Service1Client client = new Service1Client("BasicHttpBinding_IService1");
If I am calling webservice asynchrnously on asp.net web page. And once submitting request to webservice I am able to close browser as I dont need to web service return any result to asp.net page. So what I want is that how can I increase time out of webservice execution which internally execute function which is taking more than 2-3 hourse to execute abd update in db.
So my objective of making web service independent of asp.net page is satisfied but I just want to know to increase time out of web service. Can I difine it in web.config of web service?
You can use below code to achieve this:
<system.serviceModel>
<services>
<service name="OrderService">
<endpoint address=""
contract="MyNamespace.IOrderService"
binding="WsHttpBinding"
bindingConfiguration="CloseTimeout">
</endpoint>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="CloseTimeout" closeTimeout="03:00:00">
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>