Call web services from event sink - c#

I am using C# to build an event sink to monitor a specific exchange server inbox.
My implementation is based on this example: http://www.codeproject.com/KB/exchange/ManagedEventSinks.aspx?fid=382114&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26#xx0xx
Instead of the functionality described in the example i am trying to send some specific information to a web service.
I use visual studio to add the service reference to my class library and the following code to call the single method in the web service:
public void OnSave(IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags)
{
try
{
Message iMessage = new MessageClass();
iMessage.DataSource.Open(bstrURLItem, null,
ADODB.ConnectModeEnum.adModeRead,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource, "", "");
string sub= iMessage.Subject;
string body = iMessage.HTMLBody;
MyWSSoapClient wsc = new MyWSSoapClient();
wsc.SingleMethodinWS(sub, body);
}
catch (Exception ex)
{
}
}
After i build the COM component and add the event sink to the inbox and test it i get the error:
Could not find default endpoint element that references contract 'MyWS.MyWSSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase`1..ctor()
at ReplyParserEventSink.AnswerQuestionWS.AnswerQuestionWSSoapClient..ctor()
at ReplyParserEventSink.AsyncParser.OnSave(IExStoreEventInfo pEventInfo, String bstrURLItem, Int32 lFlags)
EDIT:
This is what i found in the app config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyWSSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<endpoint address="http://127.0.0.1/MyProject/WebService/MyWS.asmx"
binding="basicHttpBinding" bindingConfiguration="MyWSSoap"
contract="MyWS.MyWSSoap" name="MyWSSoap" />
</system.serviceModel>
#Alexander: I tried what you said but i get the same error. Thanks

This is of course VS2010. Thing is with autogenerated code in app.config.
Check your app.config. This file contains all defenitions for bindings and endpoints. Just check you endpoints 1st, check whether your endpoint is described, and binding is defined too.
After that try:
MyWSSoapClient wsc = new MyWSSoapClient( "<endpointConfigurationName>" );
and see what would happen.
Also in <client> area you will find description of endpoints. Try to change binding to basicHttpBinding manually - that worked for me.
<endpoint address="http://service.address.com"
binding="basicHttpBinding" bindingConfiguration="yourService"
contract="Domain.Serice" name="serviceName" />

I am answering my own question because i have found and fixed the problem
The problem was that the information form the app.config file of the class library was not getting into the com component and therefore the error.
I fixed it by setting all my parameter values in my code from an external text file by following the example at: Consume a SOAP web service without relying on the app.config
Thanks for the suggestions everyone.

Related

Connect to a web service using a mapped configuration file

We have a CRM2011 plugin running async which needs to connect to a webservice to get some missing data. The way i'm trying to solve this is to use a webservice client, made using 'add service reference'.
But for configuration i don't want to hard code the endpoint and binding. So i thought i would just load the configuration for the webservice using OpenMappedExeConfiguration like so.
var config = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap{ ExeConfigFilename = #"c:\Path\to\config.xml"}, ConfigurationUserLevel.None);
The config file is loaded... however it is not visible to the client. Because calling
var client = new MyDataServiceClient();
will throw
InvalidOperationException :
Could not find default endpoint element that references contract
'MyDataService.IMyDataService' in the ServiceModel client
configuration section. This might be because no configuration file
was found for your application, or because no endpoint element
matching this contract could be found in the client element.
The configuration file i'm using is:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyDataService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="https://integrationservices-dev.thecompany.com/MyDataService/MyDataService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyDataService"
contract="MyDataService.IMyDataService"
name="BasicHttpBinding_IMyDataService" />
</client>
</system.serviceModel>
</configuration>
I know i could initialize a binding and endpoint and give those to the MyDataServiceClient(Binding, Endpoint) constructor. But i rather don't want to write my own configuration loader logic.
Is there a way to make the loaded config known to the code constructing the client? If not what other options are there ?
You are trying to read a exe configuration but you are on Web Context, I think you must use OpenWebConfiguration.
In short this command opens the Web-application configuration file as a Configuration object.
Alternatively you can add your configuration into web.config on CRM site
See this Stackoverflow article
See MSDN

.NET Web Service Using WEB CONFIG Settings Hard Coded Net TCP

I wanted to confirm something.
Below is how I am spinning up a call to my WCF web service in my ASP.NET application.
var xml = "my xml string";
var ep = new EndpointAddress("http://myendpoint");
xml = new Proxy.ServiceClient(new NetTcpBinding(), ep).getNewXML(new Proxy.CallContext(), xml);
My web config looks similar to below. My question is, even though these settings are in the web config, the fact that my calls above are newing up the a service client and fresh New TCP binding everytime tell me that these settings aren't being referenced. Is this correct based on above?
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_SCSService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://myendpoint"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_SCSService"
contract="Proxy.Service" name="NetTcpBinding_SCSService">
<identity>
<userPrincipalName value="user#user.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
That's correct. In this case, you are not using the configuration settings found in the config file.
Proxies typically derive from the abstract class ClientBase<T> which provides several different ways to create an instance of a client proxy. Some of the constructors listed will use all of the config file while others will attempt to use the config file to fill in the information that has not been explicitly supplied in the constructor. There are even constructor overloads which do not use the configuration file at all which ClientBase<TChannel>(Binding, EndpointAddress) is one of them.
If you wanted to use what was in the application configuration file, you could use:
var client = new Proxy.ServiceClient("NetTcpBinding_SCSService");

The remote server returned an unexpected response: (413) Request Entity Too Large

If anyone can help me figure out why I am getting the following error when making a call to my WCF service I would be eternally grateful.
The maximum message size quota for incoming messages (65536) has been
exceeded. To increase the quota, use the MaxReceivedMessageSize
property on the appropriate binding element.
I have tried modifying the config file on both the service and client, and made sure the service name includes the namespace. I cannt seem to make any progress.
Here is my service config settings:
<services>
<service name="CCC.CA-CP & Sightlines Campus Carbon Calculator">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding2" contract="CCC.ICCCService" behaviorConfiguration="WebBehavior2" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="Binding2" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647"
maxBufferPoolSize="52428800" maxReceivedMessageSize="2147483647" messageEncoding="Text"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384"
maxBytesPerRead="20000" maxNameTableCharCount="16384" ></readerQuotas>
</binding>
</basicHttpBinding>
</bindings>
..
<dataContractSerializer maxItemsInObjectGraph="12097151" />
...
<requestLimits maxAllowedContentLength="157286400" />
...
<httpRuntime useFullyQualifiedRedirectUrl="true" maxRequestLength="2147483647"...
I also set the client config with the same binding values.
Here is the service contract :
namespace CCC
{
[ServiceContract(Name = "CA-CP & Sightlines Campus Carbon Calculator", Namespace = "http://www.sightlines.com/CCC/01")]
public interface ICCCService
{
....
}
Thanks in advance for any help given!
The name attribute of the service tag had did not have the name of the class implementation. It had the name in the "ServiceContract" attribute for the service interface. Thank you to Vinay Kumar for the suggestion.

WCF Service Client: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding

I've got a WCF Service running on my local IIS server. I've added it as a service reference to a C# Website Project and it adds fine and generates the proxy classes automatically.
However, when I try and call any of the service contracts, I get the following error:
Description: An unhandled exception occurred during the
execution of the current web request.
Please review the stack trace for more
information about the error and where
it originated in the code.
Exception Details: System.ServiceModel.ProtocolException:
The content type text/html;
charset=utf-8 of the response message
does not match the content type of the
binding (application/soap+xml;
charset=utf-8). If using a custom
encoder, be sure that the
IsContentTypeSupported method is
implemented properly. The first 1024
bytes of the response were: '
function
bredir(d,u,r,v,c){var w,h,wd,hd,bi;var
b=false;var p=false;var
s=[[300,250,false],[250,250,false],[240,400,false],[336,280,false],[180,150,false],[468,60,false],[234,60,false],[88,31,false],[120,90,false],[120,60,false],[120,240,false],[125,125,false],[728,90,false],[160,600,false],[120,600,false],[300,600,false],[300,125,false],[530,300,false],[190,200,false],[470,250,false],[720,300,true],[500,350,true],[550,480,true]];if(typeof(window.innerHeight)=='number'){h=window.innerHeight;w=window.innerWidth;}else
if(typeof(document.body.offsetHeight)=='number'){h=document.body.offsetHeight;w=document.body.offsetWidth;}for(var
i=0;i
I also have a console application which also communicates with the WCF Service and the console app is able to call methods fine without getting this error.
Below are excerpts from my config files.
WCF Service Web.Config:
<system.serviceModel>
<services>
<service name="ScraperService" behaviorConfiguration="ScraperServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IScraperService"
contract="IScraperService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://example.com" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IScraperService"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas
maxDepth="2000000" maxStringContentLength="2000000"
maxArrayLength="2000000" maxBytesPerRead="2000000"
maxNameTableCharCount="2000000" />
<reliableSession
enabled="false" ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ScraperServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Website Project Service Client Web.Config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IScraperService"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas
maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession enabled="false"
ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint name="WSHttpBinding_IScraperService"
address="http://example.com/ScraperService.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IScraperService"
contract="ScraperService.IScraperService" >
<identity>
<servicePrincipalName value="host/FreshNET-II" />
</identity>
</endpoint>
</client>
</system.serviceModel>
I had a similar issue. I resolved it by changing
<basicHttpBinding>
to
<basicHttpsBinding>
and also changed my URL to use https:// instead of http://.
Also in <endpoint> node, change
binding="basicHttpBinding"
to
binding="basicHttpsBinding"
This worked.
Try browsing to http://localhost/ScraperService.svc in the web browser on the server hosting the service, using the same Windows credentials that the client normally runs under.
I imagine that IIS is displaying an html error message of some description instead of returning xml as expected.
This also can occur when you have an http proxy server that performs internet filtering. My experience with ContentKeeper is that it intercepts any http/https traffic and blocks it as "Unmanaged Content" - all we get back is an html error message. To avoid this, you can add proxy server exception rules to Internet Explorer so that the proxy doesn't intercept traffic to your site:
Control Panel > Internet Options > Connections > LAN Settings > Advanced > Proxy Settings
An HTML response from the web server normally indicates that an error page has been served instead of the response from the WCF service. My first suggestion would be to check that the user you're running the WCF client under has access to the resource.
what's going on is that you're trying to access the service using wsHttpBind, which use secured encrypted messages by default (secured Messages).
On other hand the netTcpBind uses Secured encrypted channels. (Secured Transport)... BUT basicHttpBind, doesn't require any security at all, and can access anonymous
SO. at the Server side, Add\Change this into your configuration.
<bindings>
<wsHttpBinding>
<binding name="wsbind">
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
then add change your endpoint to
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsbind" name="wshttpbind" contract="WCFService.IService" >
That should do it.
As with many, in my situation I was also getting this because of an error. And sadly I could just read the CSS of the html error page.
The source of my problem was also a rewrite rule on the server. It was rewriting http to https.
I tried all the suggestions above, but what worked in the end was changing the Application Pool managed pipeline from Integrated mode to Classic mode.
It runs in its own application pool - but it was the first .NET 4.0 service - all other servicves are on .NET 2.0 using Integrated pipeline mode.
Its just a standard WCF service using is https - but on Server 2008 (not R2) - using IIS 7 (not 7.5) .
In my WCF serive project this issue is due to Reference of System.Web.Mvc.dll 's different version. So it may be compatibility issue of DLL's different version
When I use
System.Web.Mvc.dll version 5.2.2.0 -> it thorows the Error The content type text/html; charset=utf-8 of the response message
but when I use
System.Web.Mvc.dll version 4.0.0.0 or lower -> it works fine.
I don't know the reason of different version DLL's issue but by changing the DLL's verison it works for me.
This Error even generate when you add reference of other Project in your WCF Project and this reference project has different version of System.Web.Mvc DLL or could be any other DLL.
NOTE: If your target server endpoint is using secure socket layer (SSL) certificate
Change your .config setting from basicHttpBinding to basicHttpsBinding
I am sure, It will resolve your problem.
In my case a URL rewrite rule was messing with my service name, it was rewritten as lowercase and I was getting this error.
Make sure you don't lowercase WCF service calls.
You may want to examine the configuration for your service and make sure that everything is ok. You can navigate to web service via the browser to see if the schema will be rendered on the browser.
You may also want to examine the credentials used to call the service.
I had a similar situation, but the client config was using a basicHttpBinding. The issue turned out to be that the service was using SOAP 1.2 and you can't specify SOAP 1.2 in a basicHttpBinding. I modified the client config to use a customBinding instead and everything worked. Here are the details of my customBinding for reference. The service I was trying to consume was over HTTPS using UserNameOverTransport.
<customBinding>
<binding name="myBindingNameHere" sendTimeout="00:03:00">
<security authenticationMode="UserNameOverTransport" includeTimestamp="false">
<secureConversationBootstrap />
</security>
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="4194304"
maxReceivedMessageSize="4194304" allowCookies="false" authenticationScheme="Basic"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="4194304" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" requireClientCertificate="false" />
</binding>
</customBinding>
Even if you don't use network proxy, turning 'Automatically detect settings' in proxy dialog makes this exception go off.
If your are using both wshttpbinding along with https request, then i resolved it by using the below configuration change.
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="Certificate" />
</security>
I had a similar issue in my asp.net core 5 web api project to call a soap service. I resolved it by :
1.changing its url : return new System.ServiceModel.EndpointAddress("http://ourservice.com/webservices/service1.asmx?wsdl"); to https://ourservice.com/...
use these config in its Reference.cs :
private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.TaxReturnSoap))
{
System.ServiceModel.BasicHttpsBinding result = new System.ServiceModel.BasicHttpsBinding();
result.TextEncoding = System.Text.Encoding.UTF8;
result.MaxBufferSize = int.MaxValue;
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
result.MaxReceivedMessageSize = int.MaxValue;
result.AllowCookies = true;
return result;
}
if ((endpointConfiguration == EndpointConfiguration.TaxReturnSoap12))
{
System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement();
textBindingElement.WriteEncoding = System.Text.Encoding.UTF8;
textBindingElement.MessageVersion = System.ServiceModel.Channels.MessageVersion.CreateVersion(System.ServiceModel.EnvelopeVersion.Soap12, System.ServiceModel.Channels.AddressingVersion.None);
result.Elements.Add(textBindingElement);
System.ServiceModel.Channels.HttpsTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpsTransportBindingElement();
httpBindingElement.AllowCookies = true;
httpBindingElement.MaxBufferSize = int.MaxValue;
httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
result.Elements.Add(httpBindingElement);
return result;
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
X++
binding = endPoint.get_Binding();
binding.set_UseDefaultWebProxy(false);
Hy,
In my case this error appeared because the Application pool of the webservice had the wrong 32/64 bit setting. So this error needed the following fix: you go to the IIS, select the site of the webservice , go to Advanced setting and get the application pool. Then go to Application pools, select it, go to "Advanced settings..." , select the "Enable 32 bit applications" and make it Enable or Disable, according to the 32/64 bit type of your webservice.
If the setting is True, it means that it only allows 32 bit applications, so for 64 bit apps you have to make it "Disable" (default).
For me, it was the web app connection string pointing to the wrong database server.
In my case it was happening because my WCF web.config had a return character as its first line. It was even more frustrating because it was behind a load balancer and was happening only half the time (only one of the two web.configs had this problem).
This error happens also when :
targetNamespace is wrongly defined in the wsdl
or
when the ns2 is wrongly defined in the response (different from the ns in the request) . For example
request
<.. xmlns:des="http://zef/">
response
<ns2:authenticateResponse xmlns:ns2="http://xyz/">
i was getting this error in NavitaireProvider while calling BookingCommit service (WCF Service Reference)
so, when we get cached proxy object then it will also retrived old SigninToken which still may not be persisted
so that not able to authenticate
so as a solution i called Logon Service when i get this exception to retrieve new Token
I solved this problem by setting UseCookies in web.config.
<system.web>
<sessionState cookieless="UseCookies" />
and setting enableVersionHeader
<system.web>
<httpRuntime targetFramework="4.5.1" enableVersionHeader="false" executionTimeout="1200" shutdownTimeout="1200" maxRequestLength="103424" />
For me the issue was resolved when I commented the following line in Web.config
<httpErrors errorMode="Detailed" />
My solution was rather simple: backup everything from the application, uninstall it, delete everything from the remaining folders (but not the folders so I won't have to grant the same permissions again) then copy back the files from the backup.

app.config being ignored?

I have read several posts where users were having this same issue. When compiled, the .exe is unable to load any resources from app.config. This is occurring even when the app.config is copied to the output directory.
Specifically, I'm having an issue with a web service client being unable to determine the proper endpoint configuration, even if I statically compile it in like this:
this.ws = new MyServicePortTypeClient("MyServicePort", "http://mysite.com/customer_portal/ws.php");
The exception thrown states "System.InvalidOperationException: Could not find default endpoint element that references contract 'MyWebService.MyServicePortType' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."
I'm at a loss so any help would be appreciated.
Edit: Here's the MyService.exe.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyServiceBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://mysite.com/customer_portal/ws.php"
binding="basicHttpBinding" bindingConfiguration="MyServiceBinding"
contract="MyWebService.MyServicePortType" name="MyServicePort" />
</client>
</system.serviceModel>
</configuration>
EXE is taking the settings from FileName.exe.config, not from App.config
The FileName.exe.config should be auto generated when compiling the code, and placed alongside the EXE itself.
Check the folder where you have the EXE.. do you see FileName.exe.config in there?
(Posted as answer due to length and formatting)
Well, I figured it out with the help from the information provided by everyone.
The issue is that installutil.exe is trying to use its own config, instead of the one created by the service. In this case, It's trying to load C:\Windows\Microsoft.NET\Framework\v2.0...\InstallUtil.config.
Now that I've figured that out, I can work with it and get it to work correctly.
Thanks, y'all!

Categories

Resources