I getting this error :An unhandled exception of type 'System.ServiceModel.CommunicationException'
full discripton of error:
An unhandled exception of type
'System.ServiceModel.CommunicationException' occurred in mscorlib.dll
Additional information: An error occurred while receiving the HTTP
response to
http://localhost:8733/Design_Time_Addresses/SnUpdateService/Service1/.
This could be due to the service endpoint binding not using the HTTP
protocol. This could also be due to an HTTP request context being
aborted by the server (possibly due to the service shutting down). See
server logs for more details.
When in clien i am trying to get response with stream data
SnUpdateService.Service1Client SnService = new SnUpdateService.Service1Client();
SnUpdateService.UpdateFiles com = new SnUpdateService.UpdateFiles();
com.Path = "C:\\temp";
com.SearchType = 1;
com.Version = "20150101";
SnUpdateService.UpdateFiles comReturn = new SnUpdateService.UpdateFiles();
comReturn = SnService.GetUpdateFiles(com);//here error
if there is no stream data all work fine.
What i am doing wrong?
This my client 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="BasicHttpBinding_IService1" maxBufferPoolSize="200000000"
maxReceivedMessageSize="200000000" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8733/Design_Time_Addresses/SnUpdateService/Service1/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="SnUpdateService.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
This my server webConfig
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="SnUpdateService.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/SnUpdateService/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="SnUpdateService.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<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="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I think you are missing the definition for the binding configuration BasicHttpBinding_IService1 in client configuration file.
Also, you can set includeExceptionDetailInFaults="False" to "true" to get more detailed stack trace. Which helps you debug.
I had the same problem some time back and resolved it by enabling 32-Bit applications in the app pool where my service was hosted.
Related
I have created a IDummyService contract implemented by DummyService. I am trying to self-host this service using the following configuration:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<services>
<service name="DummyService.DummyService" behaviorConfiguration="MEX">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/" />
</baseAddresses>
</host>
<endpoint address="DummyService"
binding="basicHttpBinding"
contract="DummyService.IDummyService"/>
<endpoint address="net.tcp://localhost:8734/DummyService/"
binding="netTcpBinding"
bindingConfiguration = "TransactionalTCP"
contract="DummyService.IDummyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name = "TransactionalTCP" transactionFlow = "true"/>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name = "MEX">
<serviceMetadata/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The Service Host code that runs fine and starts these endpoints. However, when I try to access the following endpoints I get error as Page isn't working in Chrome browser.
http://localhost:8733/DummyService/
http://localhost:8733/mex/
However, I can access the page http://localhost:8733/
I don't understand why is that.
I thought the endpoint address is address entry for that endpoint appended to host's baseaddress
Any ideas what I am doing wrong ?
Thanks.
You have applied the attribute behaviorConfiguration="MEX" but didnt make use of it,you need to enable the metadata discovery which is false by default in WCF for security reasons.
<serviceBehaviors>
<behavior name = "MEX">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
Now when you browse the http://localhost:8733/DummyService/ and http://localhost:8733/mex/ ,a blank page will be displayed in the browser,instead of default error page.
And also if you want to test the net.tcp endpoint you can use WCFtestclient.exe.
I need to call a WCF manually (via HttpWebRequest). I can call my service by adding a web reference and calling it through the proxy, so I know the service is setup correctly and the certs, web config, etc. is all correct. Based on samples I've found, I think I'm doing it correctly, but still getting an internal error 500.
EDIT: WebService is using wsHttpBinding.
Console app code is:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1");
string strRequest = Properties.Resources.TextFile1;
req.Method = "POST";
req.ContentType = "application/soap+xml; charset=utf-8";
req.ContentLength = strRequest.Length;
req.Credentials = new NetworkCredential("test", "test");
using (Stream stream = req.GetRequestStream())
{
stream.Write(UTF8Encoding.Default.GetBytes(strRequest), 0, strRequest.Length);
}
using (WebResponse res = req.GetResponse())
{
// nothing to do here
}
TextFile1 is the XML request... just hard coding for now:
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action s:mustUnderstand="1">http://tempuri.org/IService1/GetData</a:Action>
<a:MessageID>urn:uuid:f3c2172e-eeb9-4dfd-8e1b-3a623088b78f</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
</s:Header>
<s:Body>
<GetData xmlns="http://tempuri.org/">
<value>0</value>
<value2>test</value2>
</GetData>
</s:Body>
</s:Envelope>
What am I missing here? There are no further details inside the exception.
EDIT:
Web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WcfServiceLibrary1.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="RequestUserName" contract="WcfServiceLibrary1.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="RequestUserName">
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<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" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WcfServiceLibrary1.DistributorValidator, WcfServiceLibrary1" />
<serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindBySubjectName"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
You need to use HttpWebBinding to access any WCF service over Http.
I have a webservice which I can get to run on my computer, but when deployed to a webserver (in a DMZ) it doesn't work.
When running the service on the web server, it shows a WSDL and singleWSDL that seemingly appear to be correct. Using the singleWSDL in SoapUI to test the service returns the following error message
The message could not be processed. This is most likely because the
action 'http://tempuri.org/IService1/TestStringContract' is incorrect
or because the message contains an invalid or expired security context
token or because there is a mismatch between bindings. The security
context token would be invalid if the service aborted the channel due
to inactivity. To prevent the service from aborting idle sessions
prematurely increase the Receive timeout on the service endpoint's
binding.
From what I gather, the most likely cause, is an issue in the App.Config file, which I have detailed herein
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MyService.Service1" behaviorConfiguration="MyService.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:{port}/MyService.Service1.svc" />
</baseAddresses>
</host>
<endpoint address="http://{external_ip}:{port}/MyService.Service1.svc" binding="wsHttpBinding" contract="MyService.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="EquitaWcfCbl.Service1Behavior">
<serviceThrottling maxConcurrentCalls="10"/>
<serviceMetadata httpGetEnabled="True" httpGetUrl="http://{external_ip}:{port}/EquitaWcfCblMyService.Service1.svc/mex"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
[update # 2014-02-19 1400hrs]
With further research continually pointing that the setup of the App.Config; I decided to pull out the current App.Config file and start it again, from scratch, using the WCF Service Configuration Editor, which is built into Visual Studio (tools menu) adding in the information a piece at a time and testing progress, which resulted in a working service with the following App.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior1">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata
httpGetEnabled="true"
httpGetUrl=" http://{externalip}:{port}/MyService.Service1.svc/mex"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding>
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service
behaviorConfiguration="ServiceBehavior1"
name="EquitaWcfCbl.TabletService">
<endpoint
address="http://{externalip}:{port}/MyService.Service1.svc/mex"
binding="basicHttpBinding"
bindingConfiguration=""
name="ServiceEndpoint1"
contract=" MyService.Service1" />
</service>
</services>
</system.serviceModel>
</configuration>
I'm not (yet) entirely convinced that this is exactly what we need, but with a working service ... I can at least progress.
I am trying to include two endpoints in my WCF web based service - wsHttp and netTcp.
As shown in the Web.config below I have added them, but receive the following error when when I compile and click on Service.svc in my web browser:
Error page:
Server Error in '/MyService' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The binding at system.serviceModel/bindings/wsHttpBinding does not have a configured binding named 'wsHttpBinding'. This is an invalid value for bindingConfiguration.
Source Error:
Line 16: </baseAddresses> Line 17: </host> Line 18: <endpoint address="http://localhost:8090/Services/MyService" Line 19: binding="wsHttpBinding" Line 20: bindingConfiguration="wsHttpBinding"
Source File: C:\MyService\web.config Line: 18
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
<services>
<service
name="Microsoft.ServiceModel.Samples.MyService">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9001/"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:8090/Services/MyService"
binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding"
name="MyService_WsHttp"
contract="Microsoft.ServiceModel.Samples.IService" />
<endpoint address="net.tcp://localhost:9000/Services/MyService"
binding="netTcpBinding"
bindingConfiguration="tcpBinding"
name="MyService_Tcp"
contract="Microsoft.ServiceModel.Samples.IService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
take this out:
bindingConfiguration="wsHttpBinding"
from here:
address="http://localhost:8090/Services/MyService"
binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding"
I don't thing that you have properly answer the question I'am sure he want to implement the
a binding configuration so instead of removing bindingConfiguration="wsHttpBinding, just make sure that the binding in your and point match the one in your configure file.
Hope this will work
e.g:
<bindings>
<netTcpBinding>
<!--Configure the Service operation instance object timeout of an endpoint -->
<binding name="netTCP" receiveTimeout="00:00:10" />
</netTcpBinding>
</bindings>
<endpoint address="PerSessionService" binding="netTcpBinding" contract="InstanceContext_PerSessionService.IPerSessionService" bindingConfiguration="netTCP">
I am attempting to create WCF client files using the svcutil.exe. I run my wpf app that is hosting my wcf service library. I get the following error when running svcutil from visual studio command prompt 2010:
WS-Metadata Exchange Error
URI: net.tcp://localhost:50100/duplex
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:50100/duplex'.
Can someone explain what is wrong with my configuration file, and how I can successfully generate my client files using svcutil.exe?
Here is my svcutil command (I run this command after starting my service of course):
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>svcutil.exe net.tcp://localhost:50100/duplex /d:c:\temp
Here is my app.config for wpf application hosting the wcf service library:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="baseAddress" value="net.tcp://localhost:50100/duplex"/>
</appSettings>
<system.serviceModel>
<!--<bindings />-->
<client />
<services>
<service name="TrackRejectCommunication.RejectService"
behaviorConfiguration="RejectServiceBehavior">
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="DuplexNetTcpBinding_IRejectService"
name="netTcp"
contract="TrackRejectCommunication.IRejectService" />
<endpoint name="NetTcpMetadataPoint"
address="mexTcp"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="DuplexNetTcpBinding_IRejectService"
sendTimeout="00:00:10"
portSharingEnabled="false">
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="RejectServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:50103/Metadata/Duplex" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
I get the base address via the configuration manager in my wpf application. The I use the following code to start the service in my wpf application:
RejectService rejectService = new RejectService();
//start the reject service.
HostStartup.StartService(rejectService);
The StartService code:
Uri baseAddress = new Uri(ConfigurationManager.AppSettings["baseAddress"]);
//Instantiate new ServiceHost with the singleton instance being passed in
myServiceHost = new ServiceHost(instance, baseAddress);
//Open myServiceHost
myServiceHost.Open();
I encountered a similar problem when using svcutil to create wsdl/proxy for a singleton service started via "myServiceHost = new ServiceHost(instance, baseAddress);". I was able to work around the problem by temporarily commenting out the code that created/opened the ServiceHost instance, then running svcutil to create the wsdl, then restoring the code to it's original format. It appears that whatever svcutil is doing is incompatible with the in-code instantiated ServiceHost.
For reference, the particular error that I encountered was:
Warning: There was an error loading the service type to be exported: ...
Details:The type initializer for ... threw an exception.