My WCF service has two endpoints(Normal and REST, one for Silverlight client and other for HTML5 client) and my Silverlight client application works perfectly without any issues. When I open my service in the IE, I am getting HTTP 400 bad request. It looks like REST part of my service has some issue. I have given both end points below. Appreciate any help!
Normal end point
<endpoint address="" binding="basicHttpBinding" contract="Test.Service1"
bindingConfiguration="BasicHttpBinding_Config"
behaviorConfiguration="MessageInspectorEndpointBehavior">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
WCF end point
<endpoint address="rest" binding="webHttpBinding" contract="Test.Service1"
behaviorConfiguration="web">
</endpoint>
The request should be made to .../WCF/Test/Service1.svc/rest, since this is the address for the REST endpoint you added in config.
Related
suppose my wcf has many end point with different binding.so when user / client add service ref from VS IDE at then multiple endpoint related data expose & added in client config file at client side.
Can we design service in such a way as a result only one endpoint related address will be revealed at client side?
Suppose I have one service with HTTP & TCP related endpoint and I want when external customer will add our service from their VS IDE then they will see our HTTP endpoint address not TCP. So guide me how could I do this? How to design service end config file for my requirement?
here i am attaching a small sample code for multiple endpoint related in config file.
<services>
<service behaviorConfiguration="MulContractService" name="MyWCFLibrary.MultipleContract">
<clear />
<endpoint binding="basicHttpBinding" bindingConfiguration="MulContractBasicBinding"
name="MulContractBasicEndPoint" contract="MyWCFLibrary.IMultipleContract"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="test1" binding="wsHttpBinding" bindingConfiguration="MulContractWsHttpBinding"
name="MulContractWsHttp" contract="MyWCFLibrary.IByeWorld"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="test1" binding="wsHttpBinding" bindingConfiguration="MulContractWsHttpBinding"
name="MulContractWsHttp" contract="MyWCFLibrary.IHelloWorld"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8733/Design_Time_Addresses/MyWCFLibrary/MultipleContract/"
binding="netTcpBinding" bindingConfiguration="MulContractTCPBinding"
name="MulContractTCPEndPoint" contract="MyWCFLibrary.IMultipleContract" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/MyWCFLibrary/MultipleContract/" />
</baseAddresses>
</host>
</service>
</services>
EDIT
here i am giving my new full code and just guide me does it work?
namespace CustomService
{
[ServiceContract]
public interface IEmp
{
[OperationContract]
string GetEmp();
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class BusinessLayer : IEmp
{
public BusinessLayer()
{
}
public string GetEmp()
{
return "Casino";
}
}
}
Config code at service end
<services>
<service name="CustomService.BusinessLayer">
<endpoint address="CustomerFactory" binding="basicHttpBinding"
bindingConfiguration="HTTPBindingConfig" name="CustomerFactoryHTTP"
contract="CustomService.IEmp" listenUriMode="Explicit" />
</service>
<service name="CustomService.BusinessLayer">
<endpoint binding="basicHttpBinding" bindingConfiguration="HTTPBindingConfig"
name="CustomerMasterHTTP2" bindingName="CustomerMaster" contract="CustomService.IEmp" />
</service>
</services>
just tell me the above config will work?
in the above config i define two service tag with same name because my service full name with namespace is CustomService.BusinessLayer
is it ok or do i need to give unique name for each service tag?
my intention is i will have same service but with multiple service tag and when customer will add my service ref at their end then they will not be able to see all the endpoint.
my intention is not expose all endpoint & address to every client.
so guide me what i have done does it work or not....if not then rectify my config entry and tell me how could i restrict my endpoint not to expose each binding & address before all client. thanks
Maybe not what you are looking for but you could easily add another service to your project and give it the endpoints you want your client to see. Then the existing service could be just for TCP or for both types. Under the covers of course both services would run the same code.
Adding a service is just like adding any other file, right click, add New Item, WCF service. Then you can use the WCF configuration Editor to configure it if you dont want to do it by hand.
For what it is worth here is a config with two services. You can see that the first service has two endpoints, an Http and a TCP while the second service exposes just the http endpoint. Your two services would then each implement IService and would delegate to a common class or library.
<services>
<service name="Mynamespace.Service1">
<endpoint binding="basicHttpBinding"
bindingConfiguration="HTTPBindingConfig" name="MyserviceHTTP"
contract="Mynamespace.IService" listenUriMode="Explicit">
</endpoint>
<endpoint binding="netTcpBinding"
bindingConfiguration="TCPSecured" name="MyserviceHTTP"
contract="Mynamespace.IService" />
</service>
<service name="Mynamespace.Service2">
<endpoint binding="basicHttpBinding"
bindingConfiguration="HTTPBindingConfig" name="MyserviceHTTP"
contract="Mynamespace.IService" listenUriMode="Explicit">
</endpoint>
</service>
</services>
I develop a WCF service (3.5) in VS 2010. Generally I am able to test it via the WCF Test Client and call the service from any browser. I'm on my Windows 7 development machine, so everything is default. The address is like http://localhost:54538/MyService.svc
However, when I try to call the service from a third party client (which in the end is my target), the client gets no response at all. The response is just empty. I also tried to call the service by PHP curl from a local Apache webserver - also an empty response.
So I think there might be a problem with the configuration. The services part is:
<services>
<service behaviorConfiguration="MyNamespace.Service1Behavior" name="MyNamespace.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyNamespace.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Do I have to add an endpoint or change anything else?
So the solution I found (based on #marc_s' comment) is adding another endpoint as webHttpBinding:
<endpoint address="rest" binding="webHttpBinding" contract="MyNamespace.IMyCometService" bindingConfiguration="UnsecuredWeb">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
Then calling the service from the third party software via http://localhost:54538/MyService.svc/rest
On our build server, we have a service that calls another service on the same box via net.pipe, but it is failing saying that there is no endpoint listening to net.pipe. IIS does have Net.pipe set for both the calling and called service.
<endpoint address="net.pipe://build.QQQQQ.com/QQQ/QQQ.svc"
binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IMembershipService"
contract="QQQ.IMembershipService" name="NetNamedPipeBinding_IMembershipService">
<identity>
<servicePrincipalName value="host/ABCDF.XX.net" />
</identity>
</endpoint>
Note: build.QQQ.com is actually ABCDF.XX.net. is that the problem, do they need to match even though they are the same.
IMO - they should much.
I'd try to remove last "/QQQ.svc" from address.
First off I'll apologise as this is probably a duplicate but everything I read seems to be either incomplete or confusing as I'm very new to WCF.
I basically am looking to deploy a WCF service in IIS with 2 endpoints accessible and have been going around in circles all day :(
I have a service library WCF dll with the following structure
App.config
TestSvc1.cs
ITestSvc1.cs
TestSvc2.cs
ITestSvc2.cs
This works fine in the VS WCF test client and now im deploying to IIS so I created a WCF Service Application and referenced the dll. This project has the following structure
Service1.svc
Web.config
Service1.svc contains this
<%# ServiceHost Language="C#" Debug="true"
Service="WCFServices.TestServices.ITestSvc1" CodeBehind="Service1.svc.cs" %>
and my web.config has the following
<services>
<service name="WCFServices.TestServices.TestSvc2">
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/wcf2/TestServices/TestSvc2/" />
</baseAddresses>
</host>
</service>
<service name="WCFServices.TestServices.TestSvc1">
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc1"
listenUri="http://localhost:8080/wcf2/service1.svc">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc2"
listenUri="http://localhost:8080/wcf2/service1.svc">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/wcf2/TestServices/TestSvc1/" />
</baseAddresses>
</host>
</service>
</services>
Any help would be greatly appreciated. As you can see I've tried to add an additional endpoint in the web.config but this doesn't work, I get an error saying that TestSvc2 calls can't be found in TestSvc1 which I guess relates to the entry in Service1.svc
I also read about creating a class that inherits these interfaces but I am not sure exactly how to implement it based on what I have above. Do I need to modify the Service1.svc?
public interface MultipleSvc : ITestSvc1, ITestSvc2
{
// What exactly do I put here? I have no idea, do I leave it blank? This didn't work for me
}
Any help would be greatly appreciated guys thanks :)
Golden rule: one .svc = one service (or more specifically: one service implementation class)
So if you do have two separate, distinct services (in classes WCFServices.TestServices.TestSvc1 and WCFServices.TestServices.TestSvc2), then you need two .svc files (one each, for each service)
What you could do is have one service implementation class that implements both service contracts:
public class MultipleServices : ITestSvc1, ITestSvc2
{
// implement the service logic here, for both contracts
}
In that case, one svc file will be enough (the .svc file is per implementation class and can host multiple service contracts). But then you'd need to change your config, too - since you really only have one service class (therefore: one <service> tag) and multiple contracts hosted inside it:
<services>
<service name="WCFServices.TestServices.MultipleServices">
<endpoint
address="Service1"
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc1">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint
address="Service2"
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
Also: since you seem to be hosting your WCF service in IIS, there's no point in defining any <baseAddress> values - the "base" address of your service is the location (URI) where the *.svc file lives.
You do'nt need two svc file. Choose ServiceReference1.Service1Client or ServiceReference1.Service2Client.
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");