Connect via Java client to WCF Service - c#

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

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.

WCF REST Service for ANdroid Client Producing Error

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?

Mutiple http base address for self hosted WCF service?

I have a WCF service that has one http endpoint,
I would like to add another http endpoint address with a different binding.
The service is not hosted in IIS and hence setting the multipleSiteBindingsEnabled
is of no use.
Am trying something like this.
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="ServiceBehaviorConfiguration"
name="ServerService">
<endpoint address="http://localhost:6732/ServerService" binding="webHttpBinding" behaviorConfiguration="webby"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:800/ServerService" binding="basicHttpBinding"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:800/ServerService" />
<add baseAddress="http://localhost:6732/ServerService" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
Try something like the config shown below. It exposes multiple endpoints through a single port but I'm sure this pattern of configuration is supported by WCF.
<services>
<service behaviorConfiguration="ServiceBehaviorConfiguration"
name="ServerService">
<endpoint address=""
binding="webHttpBinding"
behaviorConfiguration="webby"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="basic"
binding="basicHttpBinding"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:800/ServerService" />
</baseAddresses>
</host>
</service>
</services>
You could create two services that each have their own different baseAddress, but their internal endpoints are identical.

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