WCF REST Service for ANdroid Client Producing Error - c#

Hi I want to make a WCF Rest service to be consumed by an android client.
Can somebody please post a easy helpful solution for the same problem step by step.
As far as I see
Web.config:
<service name="ServifyCoreModulesService.Service1">
<endpoint address="" behaviorConfiguration="restfulBehavior"
binding="webHttpBinding" bindingConfiguration="" contract="ServifyCoreModulesService.IService1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/service1" />
</baseAddresses>
</host>
</service>
App.config:
<client>
<endpoint
name="endpoint1"
address="http://localhost/ServifyCoreModulesService/Service1.svc"
binding="webHttpBinding"
bindingConfiguration=""
behaviorConfiguration="restfulBehavior"
contract="ServifyCoreModulesService.IService1" >
<metadata>
<wsdlImporters>
<extension
type="Microsoft.ServiceModel.Samples.WsdlDocumentationImporter, WsdlDocumentation"/>
</wsdlImporters>
</metadata>
<identity>
<servicePrincipalName value="host/localhost" />
</identity>
</endpoint>
</client>
I am getting issue with metadata.
I dont understand all of these tags does anybody have a start to finish tutorial on this ? Or any clue about why i should configure in a particular way?

Related

Configure single endpoint for all WCF services offerend in project?

In my WCF project, I have two services Products and Customers. Both these services have separate interface and implementation .cs files. In App.Config I could see the below,
<service name="DemoProj.Services.ProductService">
<endpoint address="" binding="basicHttpBinding" contract="DemoProj.Services.Interfaces.IProductService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/DemoProj/Service/ProductService/" />
</baseAddresses>
</host>
</service>
<service name="DemoProj.Services.CustomerService">
<endpoint address="" binding="basicHttpBinding" contract="DemoProj.Services.Interfaces.ICustomerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/DemoProj/Service/CustomerService/" />
</baseAddresses>
</host>
</service>
When the client consumes this WCF service, it will require both Products and Customers service.
My question is, I will have many more services and the App.config is going to be big with lots of endpoints. In my current scenario, I will need only one contract, binding, address for all my services like Products, Customers and so on. I need to only configure one endpoint that is shared by all the services I expose to my client.
I understand, it is by WCF design where it is more flexible to have different configurations for different services offered. But in my case i don't require like that. I want to make my App.config simple with only one endpoint.

Cant connect to WCF Service. Missing EndPointElemt

i'm trying to create my own WCF service and client. I've created my Service with the following app.config settings:
<system.serviceModel>
<services>
<service name="Interface.MyWCFService">
<endpoint address="http://localhost:9999/MyService" binding="basicHttpBinding"
bindingConfiguration="" name="MyServiceEndpoint" contract="Interface.IMyWCFService" />
</service>
</services>
</system.serviceModel>
The service starts without an exception.
My client should connect to this service. His app.config is this one:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://localhost:9999/MyService" binding="basicHttpBinding"
bindingConfiguration="" contract="Interface.IMyWCFService"
name="MyServiceEndpoint" kind="" endpointConfiguration="" />
</client>
</system.serviceModel>
</configuration>
In the c# code i try to create a channelfactory in the client.cs with the following code:
ChannelFactory<IMyWCFService> channelFactory = new ChannelFactory<IMyWCFService>("MyServiceEndpoint", new EndpointAddress("http://localhost:9999/MyService"));
IMyWCFService proxy = channelFactory.CreateChannel();
This is not working. Every time i try to start the program i get the following exception:
No Endpointelement with the name "MyServiceEndpoint" and contract
"Interface.IMyWCFService" was found in
ServiceModel-Clientconfigurationsection.
I hope you can help me.
This is how I have my service configured:
<service name="foo.bar.BlaService">
<host>
<baseAddresses>
<add baseAddress="http://localhost/BlaService" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="foo.bar.IBlaService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
And here the client:
<client>
<endpoint name="BlaService" address="http://localhost/BlaService" binding="basicHttpBinding" contract="foo.bar.IBlaService" />
</client>

Connect via Java client to WCF Service

I have WCF service which has 2 endpoints: wsHttpBinding and basicHttpBinding. I can connect to each endpoint via C# client.
My Wcf Service configuration
<service behaviorConfiguration="App.ServiceBehavior"
name="MyService">
<endpoint address="/ws" binding="wsHttpBinding" bindingConfiguration="httpBindingForWs"
contract="Namespace.IMyService">
<identity>
<dns value="127.0.0.1" />
</identity>
</endpoint>
<endpoint address="/basic" binding="basicHttpBinding" bindingConfiguration="httpBindingForBasic"
contract="Namespace.IMyService">
<identity>
<dns value="127.0.0.1" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://127.0.0.1:12000/MyService" />
</baseAddresses>
</host>
</service>
I can generate wsdl in Java. Can you show me sample code, how can I consume basicHttpBinding in Java?
you can consume the webservice using Java there are different frameworks to make your job easier, like AXIS and Apache CXF
Look at following article for more pointers on same
Consuming WCF services with Java

web service endpoint wrong address

<services>
<service name="WebServices.Service" behaviorConfiguration="WebServices.ServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="http://ip/Service.svc" binding="wsHttpBinding" contract="WebServices.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
but my endpoint is still
svcutil.exe http://server-iis/Service.svc?wsdl. How to change server-iis to my IP?
Try solution suggested in here.
I'am not sure but I hope this suggestion helps you.

1 end point multiple servicecontracts - wcf?

I created a service which allows clients to search for user information. This is exposed as an interface ISearchUsers.
I used this article as a base but to no avail: Not sure if this is the way to go
link text
Now I want to create and expose an interface called ICreateUser and i assumed that i had to create a new endpoint , basicHttp binding and used the article above.
This is part of my config:
<services>
<service behaviorConfiguration="Service.Service1Behavior"
name="Service.SearchService">
<clear />
<endpoint binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding"
contract="Service.ISearchService" listenUriMode="Explicit">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
listenUriMode="Explicit">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Service/Service1/" />
</baseAddresses>
</host>
</service>
</services>
You can extend your current service class which implements ISearchUser and let it implement ICreateUser as well - in that case, you could add a second endpoint to your service config:
<services>
<service name="Service.SearchService"
behaviorConfiguration="Service.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Services/" />
</baseAddresses>
</host>
<endpoint
address="SearchUser"
binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding"
contract="Service.ISearchService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="CreateUser"
binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding"
contract="Service.ICreateUserService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
One thing that most likely doesn't work in your case is the fact you pick "basicHttpBinding" as your binding, but the bindingConfiguration seems to indicate WsHttpBidning..... those need to match and thus should probably be:
<endpoint
address="CreateUser"
binding="basicHttpBinding" bindingConfiguration="basicHttpMtomBinding"
contract="Service.ICreateUserService">
Marc

Categories