Consuming WCF service - c#

When I use Live WCF service it shows error
There was no endpoint listening at this that could accept the message. This is often caused by an incorrect address or SOAP action

Put your end-point configuration on Web.config on root of your project.
this is sample of a web.config with end-point.
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="TestWcfHttps1.Service1" name="TestWcfHttps1.Service1">
<endpoint address="https://MYSERVER/GpTest/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="TransportSecurity"
contract="TestWcfHttps1.IService1">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestWcfHttps1.Service1">
<serviceMetadata httpsGetEnabled="true" externalMetadataLocation="https://MYSERVER//GpTest/Service1.wsdl" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
The above sample code will fix your problem, but please describe more about your projects on your solution and put your code here. Did you consume the web-service in a class library and reference it on your web-app project ?

Related

Problems with Hosting WCF service on IIS (Using WAS) for netTCP bindings?

I created a simple WCF service and hosted it in IIS by creating a new website. In Web.config file,I am providing bindings for http and net tcp.
I created a console client and adding service reference. It generates two binding in client config - for http and for tcp. When I try to invoke the service using tcp, I get this error -
An unhandled exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll
Additional information: There was no endpoint listening at net.tcp://computername/Service.svc that could accept the message. This is often caused by an incorrect address or SOAP action.
when I run using Http endpoint , it works fine.
Note -
I am using Windows 10 OS, IIS 10.0 and WPAS\WAS (Windows Process Activation Service) are installed. I already enabled\checked HTTP Activation, TCP Activation in .Net framework in Windows features. And modified IIS server settings to include net tcp. Please check it in attached image.
My website Web.config file looks like
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NewBinding0" portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="My" name="WCFServiceOM.Service1"> <!-- the service name must match the configuration name for the service implementation. -->
<endpoint address="" binding="basicHttpBinding" contract="WCFServiceOM.IService1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint binding="netTcpBinding" bindingConfiguration="NewBinding0" contract="WCFServiceOM.IService1" />
<endpoint address="mexOM" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8087/Service1" />
<add baseAddress="http://localhost:7777/Service1"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehanior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="My">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
And my client App.Config look like
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IService1">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="http://computername:7777/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
<endpoint address="net.tcp://computername/Service.svc" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
name="NetTcpBinding_IService1" />
</client>
</system.serviceModel>

WCF strange Behavior

I have a strange WCF behavior. When the service is hosted on IIS I can navigate to the service url and see the service wsdl, but any hit on the service operations return a 404.0 not found exception.
so this works
http://localhost:8000/Simulators/BackendService/service.svc
and this doesn't work
http://localhost:8000/Simulators/BackendService/service.svc/ProcessRequest
The behavior happens on one machine only and I tried the same source code with the exact same web.config on 2 other machines and they work perfectly fine. Which makes me sure that the problem is the IIS configuration on my machine but I couldn't figure out what is the problem.
Would anybody know what could be causing that problem?
Thanks,
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
<bindings>
<customBinding>
<binding name="POXConfig">
<customTextMessageEncoding messageVersion="None" />
<httpTransport/>
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="MSAD.Bawaba.Backend.WebHost.BawabaBackendServiceBehavior" name="BawabaTestingTool.Simulators.BackendService.Service">
<endpoint address="ProcessRequest" binding="customBinding" bindingConfiguration="POXConfig" contract="MSAD.Bawaba.Backend.Service.IBackendService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MSAD.Bawaba.Backend.WebHost.BawabaBackendServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<extensions>
<bindingElementExtensions>
<add name="customTextMessageEncoding" type="MSAD.Bawaba.Backend.CustomEncoderBinding.CustomTextMessageEncodingElement, MSAD.Bawaba.Backend" />
</bindingElementExtensions>
</extensions>

How to configure URL of a WCF Service referenced within another WCF Service Library

This is hard to explain so please ask me to clarify anything that is unclear.
I have 3 WCF web service libraries and 3 host applications I will call them Service1, Service2 and Service3. Service2 is in the same solution but is not relevant to this question at the moment.
Service1 references Service3 Host Application. Once it is compiled I cannot see any way to configure the URL for Service3 in Service1.
I would like it to be in the config for Service1 Host Application. Is this possible? I can't believe this is hard coded in the DLL?
Service1 Library App.Config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service3Data" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://MyHost/gws/GService3.svc/gwd"
binding="basicHttpBinding" bindingConfiguration="Service3Data"
contract="GServices3.IGws" name="Service3Data" />
</client>
<services>
<service name="MyNameSpace.Business.WebServices.Service1">
<endpoint address="" binding="basicHttpBinding" contract="MyNameSpace.Business.WebServices.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/MyNameSpace.Business.WebServices/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
Service1 Host Application Web.Config (and where I need to configure the URL for Service3):
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service1Binding" openTimeout="00:10:00" maxBufferPoolSize="2147483646"
maxBufferSize="2147483646" maxReceivedMessageSize="2147483646">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646"
maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MyNameSpace.Business.WebServices.Service1">
<endpoint address="bwd" binding="basicHttpBinding" bindingConfiguration="Service1Binding"
name="BWData" contract="MyNameSpace.Business.WebServices.IService1" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
When you create a proxy for a WCF service, you can always add a <system.serviceModel> section to the main assembly and configure all the settings in there (including the URL of the service you creates a proxy for).
If you add your proxy in a library assembly, you can still add <system.serviceModel> to the main (executable/web host/etc.) assembly.
You need to copy the <client> section from the library config to the host application config (together with its binding and possibly other elements).

Unable to call through https request

I'm using the website which contain .svc file and hosted on https as rest api. My question is:
My website has SVCUTIL.exe is https://XXXXXXX but when I call it with https request it fails but working fine with http request.And I don’t want use SSL certificates
Thanks
This is my webconfig settings:
<serviceBehaviors>
<behavior name="Mybehaviour">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="Mybehaviour" name="PBUIService">
<endpoint address="https://XXXXXXXXXXXXXXX" behaviorConfiguration="PBBehaviour" binding="webHttpBinding" bindingConfiguration="wsHttpBindingSettings" contract="PBUIService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
I've added the following lines to make it work with https:
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>

WCF Web service is throwing EndPointNotFoundException

I am trying to configure a WCF service to support duplex communication to a client service and since I switched to WSDualHttpBinding I now get this on the service in IIS
There was no endpoint listening at http://exampple.com/Temporary_Listen_Addresses/06be1668-e09f-441c-9fc9-999e4922d4a8/1002945c-979b-484e-a2c5-fa3470b6706d that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The inner exception is null and basically the service on the server is hosted in IIS then I have a self hosted service on the client machine that connects to the server and a client application that connects to the self hosted service. The wsDualHttpbinding is from the server to the self hosted service and the self hosted service exposes a named pipe for the client application to communicate with.
Here is the Web.config from the service:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<protocolMapping>
<remove scheme="http" />
<add scheme="http" binding="wsDualHttpBinding" />
</protocolMapping>
<bindings>
<wsDualHttpBinding>
<binding name="WsDualHttp_EcuWebBinding" />
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="EcuWebServiceBehavior" name="EcuWeb.Service.EcuWebService">
<endpoint address="/EcuWebService.svc" binding="wsDualHttpBinding" bindingConfiguration="WsDualHttp_EcuWebBinding" name="WsDualHttp_EcuWeb" contract="EcuWeb.Service.IEcuWebService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="EcuWebServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="1" multipleSiteBindingsEnabled="true">
<serviceActivations>
<add relativeAddress="EcuWebService.svc" service="EcuWeb.Service.EcuWebService" />
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
</configuration>
Here is the App.config from my host application:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://localhost:51334/EcuWebService.svc/EcuWebService.svc" binding="wsDualHttpBinding" bindingConfiguration="WsDualHttp_EcuWeb" contract="EcuWebService.IEcuWebService" name="WsDualHttp_EcuWeb">
<identity>
<userPrincipalName value="myusername#domain.com" />
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior name="NetNamedPipeBehavior_EcuService">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netNamedPipeBinding>
<binding name="NetNamedPipedBinding_EcuService" />
</netNamedPipeBinding>
<wsDualHttpBinding>
<binding name="WsDualHttp_EcuWeb" />
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="NetNamedPipeBehavior_EcuService"
name="Ecu.Services.EcuService">
<endpoint address="net.pipe://localhost/EcuNamedPipe" binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipedBinding_EcuService" name="NetNamedPipeBinding_IEcuService" contract="Ecu.Services.IEcuService" />
</service>
</services>
</system.serviceModel>
</configuration>
And finally the App.config from the client test application:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NetNamedPipeBinding_IEcuService" />
</netNamedPipeBinding>
</bindings>
<client>
<endpoint address="net.pipe://localhost/EcuNamedPipe" binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IEcuService" contract="EcuServiceClient.IEcuService" name="NetNamedPipeBinding_IEcuService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
I have gotten this fixed thanks to another post on SO that pointed me to this article about WCF Duplex services. Duplex Article
Once I switched over to net.tcp and got everything setup to use it the duplex communication worked no problem.

Categories

Resources