WCF Basichttpbinding web.config example for REST API - c#

I tried to find web.config for my WCF service connect to server using REST call. However, its saying unable to connect server. Here is my web.config:
<?xml version="1.0"?>
<configuration>
<!--<system.net>
<defaultProxy useDefaultCredentials="true" >
</defaultProxy>
</system.net>-->
<appSettings>
<add key="UserName" value="admin"/>
<add key="Password" value="admin"/>
<add key="resturl" value="https://Clientname.atlassian.net/rest/api/2/"/>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IJiraService"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:19065/JiraService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IJiraService" contract="ServiceReference1.IJiraService"
name="BasicHttpBinding_IJiraService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Could anyone please help me, how can I correct this? I tried on net, however, not able to find any suitable tutorial for this. Please help.

This is resolved. Its was a proxy issue and after adding proxy to browser and IIS the issue got resolved. Thanks.

Related

Why is visual studio telling me I am running a different version of C# than what I am targeting in a WCF Service Project?

I created a new WCF Service Project targeting framework 4.7.2 in Visual Studio, but when I try to code an interpolated string, i get an error that interpolated strings are not available in C#5, please use version 6 or higher. The only place I see any mention of versioning is in the web.config file, and I confirmed that it indeed is targetting 4.7.2. Does anyone know how to fix this, and why its happening?
Web.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
TestMethod where error occurs
public string GetCurrentCount()
{
return $"Random stfuf";
}

C# WCF with IIS AAR cant process metadata

I have a WCF Service hosted in IIS with BasicHttpBinding.
WCF is available through IIS and is routed to an internal HTTP Port with IIS Reverse Proxy (AAR).
When I want to embed the WCF in VisualStudio from my IIS then I can't add the Service Reference and get this error:
The removeserver has returned an error: (415) Cannot process
the message because the content type 'application/soap+xml;
charset=utf-8' was not the expected type 'text/xml;
charset=utf-8'..HTTP GET Error URI:
http://myServer/WebServices/WCF_mywebapi/Service.svc
However if I disable the IIS ARR Reverse proxy (and Host WCF directly on Port 80) then there is no Error.
Is there a problem with ReverseProxy handling my Request?
How can I debug them?
I have some other WebServices on WsHttpBinding and they work well on retriving metadata.
The web.config must be right because I can embed the wervice without active ARR.
I know that there are a few solutions to this error but none of them mention the AAR Module as source.
Can you help me?
Edit: Here whe web.config from WCF:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1">
<assemblies>
<add assembly="Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89B483F429C47342"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5.1"/>
</system.web>
<system.serviceModel>
<services>
<service name="WcfNamespaces.Service.svc">
<endpoint address="Service.svc" bindingNamespace="" binding="basicHttpBinding" bindingConfiguration="" contract="WcfNamespaces.IService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
My Server Config for Proxy:
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="http://127.0.0.1:1010/{R:1}" />
</rule>
And I disabled svc ISAPI module for IIS Proxy Instance (because the're handled by IIS Instance on other port):
<handlers>
<remove name="svc-ISAPI-4.0_64bit" />
<remove name="svc-ISAPI-4.0_32bit" />
<remove name="svc-Integrated-4.0" />
</handlers>
Thanks :)

There was no endpoint listening at {0} that could accept the message. This is often cause by an incorrect address or SOAP action. (Xamarin Android)

I can normally run the application on the emulator and do some action before, but for some reason this suddenly appeared even though the webservice runs properly on the browser.
I looked for a solution with similar case as this but I can't seem to figure out how to do it because I am using Xamarin which has a different way of adding service reference.
Here are my codes:
ServiceReferences.ClientConfig
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFSREmployee" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:51678/FSREmployee.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IFSREmployee" contract="IFSREmployee"
name="BasicHttpBinding_IFSREmployee" />
</client>
<extensions />
</system.serviceModel>
</configuration>
Web.config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="SQL_HCMConnectionString" connectionString="Data Source=ADGTAPPS5;Initial Catalog=SQL_HCM;User ID=hcm;Encrypt=False;TrustServerCertificate=True"
providerName="System.Data.SqlClient" />
<add name="OFFICEConnectionString" connectionString="Data Source=ADGTAPPS5;Initial Catalog=OFFICE;User ID=office;Encrypt=False;TrustServerCertificate=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
Which emulator are you using it might be the problem of your emulator. Use genymotion emulator it is the works smooth without any problems. And a service hosted on localhost can be accessed through a proxy or with the IP.
Already solved by creating a webservice again and now it is working properly.

C# error wcf services

I am trying to deploy an WCF, using Internet Information Service. I worked with visual studio 2015. But i got this error:
Configuration binding extension 'system.serviceModel/bindings/true'
could not be found. Verify that this binding extension is properly
registered in system.serviceModel/extensions/bindingExtensions and
that it is spelled correctly.
My Web.config is the following:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.serviceModel>
<services>
<service name="ClientWebS.UserService"
behaviorConfiguration="mex">
<endpoint address="UserService" binding="wsHttpBinding"
contract="ClientWebS.IUserService"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mex">
<serviceMetadata httpGetBinding="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Thanks for help!!

There was no endpoint listening at https://localhost:44302/Service7.svc that could accept the message

I created a WCF service hosted on IIS and posted with HTTPS. When I launch my client code, I got error:
An unhandled exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll
Additional information: There was no endpoint listening at https://localhost:44302/Service7.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
However, when I launch https://localhost:44302/Service7.svc in the browser, I can get "You have created a service." like the picture shown below:
Those two url are exactly the same and I am confused why I am getting this error.
My client app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_IService7">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:44302/Service7.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpsBinding_IService7" contract="ServiceReference1.IService7"
name="BasicHttpsBinding_IService7" />
</client>
</system.serviceModel>
</configuration>
My service web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>

Categories

Resources