Enterprise library with workflow foundation 4.0-throwing exception in starting service? - enterprise-library

I want to use enterprise library validation with wf4.0. Below is my configuration.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Service1" behaviorConfiguration="PublishMetadata">
<endpoint address=""
binding="basicHttpBinding" contract="ITestService" behaviorConfiguration="Validation"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Validation">
<validation enabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="PublishMetadata">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="validation"
type="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.ValidationElement, Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
It is throwing exception when i try to browse service in web browser.
Exception :-
Server Error in '/' Application.
Value cannot be null.
Parameter name: operation.SyncMethod
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.ArgumentNullException: Value cannot be null.
Parameter name: operation.SyncMethod

As we know that WF service is a type of WCf async service. Enterprise library does not support async services.
One expert suggested some updating in enterprise library but also not work with workflow services.
To view full discussion please follows this link.
http://entlib.codeplex.com/discussions/357087
And thanks to "randylevy” for his support and understanding

Related

Calling JSON Rest service from browser

Want to enable https on my REST JSON WCF service and test it in IE browser.
WSDL is loading with no issues (https://localhost/myservice/Imyservice.svc?WSDL).
But i tried to call a operation ( https://localhost/myservice/Imyservice.svc/Getdata), I am getting
Request Error The server encountered an error processing the request. .
Below is my web.config. Can anyone help me with this
<webHttpBinding>
<binding name="SecureBasicRest" allowCookies="true" >
<security mode="Transport" />
<readerQuotas maxDepth="32"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="svcBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="svcEndpoint">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="myservice.Imyservice" behaviorConfiguration="svcBehavior">
<endpoint binding="webHttpBinding" bindingConfiguration="SecureBasicRest"
behaviorConfiguration="svcEndpoint" name="webHttp"
contract="myservice.Imyservice" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
The root cause is that there is something wrong with the definition of the service endpoint.
<service name="myservice.Imyservice" behaviorConfiguration="svcBehavior">
<endpoint binding="webHttpBinding" bindingConfiguration="SecureBasicRest"
behaviorConfiguration="svcEndpoint" name="webHttp"
contract="myservice.Imyservice" />
</service>
Your idea is correct, we should add a service endpoint with transport security mode. However, the service name should be a fully qualified name of the service implemented class instead of the service interface.
<service name="myservice.myservice"
Feel free to let me know if the problem still exists.

How do you enable logging for CrmServiceClient in the Xrm Tooling toolkit?

I'm having issues trying to log in to a CRM Online organization through the use of the latest version of the Xrm Tooling nuget package using the connection string constructor from a custom powershell cmdlet.
I'm receiving a rather unhelpful "Unable to Login to Dynamics CRM" error message and am attempting to enable tracing to troubleshoot but have not been able to enable it by modifying the .dll.config file like the below (taken from an XrmToolbox issue on GitHub):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
switchName="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="console" type="System.Diagnostics.DefaultTraceListener" />
<remove name="Default" />
<add name ="fileListener" />
</listeners>
</source>
<source name="Microsoft.Xrm.Tooling.CrmConnectControl"
switchName="Microsoft.Xrm.Tooling.CrmConnectControl"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="console" type="System.Diagnostics.DefaultTraceListener" />
<remove name="Default" />
<add name ="fileListener" />
</listeners>
</source>
</sources>
<switches>
<!--
Possible values for switches: Off, Error, Warning, Info, Verbose
Verbose: includes Error, Warning, Info, Trace levels
Info: includes Error, Warning, Info levels
Warning: includes Error, Warning levels
Error: includes Error level
-->
<add name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient" value="Verbose" />
<add name="Microsoft.Xrm.Tooling.CrmConnectControl" value="Verbose" />
<add name="Microsoft.Xrm.Tooling.WebResourceUtility" value="Verbose" />
</switches>
<sharedListeners>
<add name="fileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="XRMToolingLogs.log" />
<!--<add name="eventLogListener" type="System.Diagnostics.EventLogTraceListener" initializeData="XRMTooling" />-->
</sharedListeners>
</system.diagnostics>
</configuration>
I was able to work around this by configuring the listener programmatically through:
Microsoft.Xrm.Tooling.Connector.TraceControlSettings.TraceLevel = System.Diagnostics.SourceLevels.All;
Microsoft.Xrm.Tooling.Connector.TraceControlSettings.AddTraceListener(new TextWriterTraceListener("log.txt"));
Which pointed me to the actual error which was that the CrmServiceClient was expecting a URL with the organization unique name instead of the URL name.

EntityFramework failing to connect when downloaded by ClickOnce (vs2010) on Windows 8

A newbie question.
Having completed an application using WCF and EntityFramework (each in different projects), I am trying to deploy it with ClickOnce. In visual studio 2010, the application was published to a directory on my laptop. The files were then copied to a tablet pc running windows 8.
When the program is run, I get a Connection Error with a target machine actively refusing it 127.0.0.1:24324.
This application runs well on my laptop and nowhere is 127.0.0.1 used (by me). The working program (on my laptop) has a class that determines the network I am on and then adjusts the connection string to the appropriate address of the network server.
What happened? And how do I fix it?
Any help or insight would be greatly appreciated.
Edit: The Web.config file for my working machine, the laptop, is:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="LibraryConnection"
connectionString="server=xxx.xxx.xxx.xxx;port=xxxx;user id=id;password=mypassword;database=mydatabase"
providerName="Npgsql" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
The working app.config from the client project is:
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_INovaDataService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="6553600" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600" 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://localhost:24324/DataService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_INovaDataService" contract="DataService.INovaDataService" name="BasicHttpBinding_INovaDataService"/>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

dotnetopenauth Provider WebConfig Error

I am required to create a provider using the DNOA. I have downloaded the libraries from the DNOA site and attempted to load the oAuthServiceProvider example. I couldn't load this as this is looking for
\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"
which is part of Visual Studio 2010, I however am on 2008. Despite changing the version to v9.0 it was still looking for v10.0. Nevermind.
I open the project as a website and tried to run this. But now get the error "Error 1 Unrecognized configuration section uri."
Any ideas as to what is going on here? Below is the webconfig
<?xml version="1.0"?>
<!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names),
which is necessary for OpenID urls with unicode characters in the domain/host name.
It is also required to put the Uri class into RFC 3986 escaping mode, which OpenID and OAuth require. -->
<uri>
<idn enabled="All"/>
<iriParsing enabled="true"/>
</uri>
<system.net>
<defaultProxy enabled="true" />
<settings>
<!-- This setting causes .NET to check certificate revocation lists (CRL)
before trusting HTTPS certificates. But this setting tends to not
be allowed in shared hosting environments. -->
<!--<servicePointManager checkCertificateRevocationList="true"/>-->
</settings>
</system.net>
<!-- this is an optional configuration section where aspects of dotnetopenauth can be customized -->
<dotNetOpenAuth>
<!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
<reporting enabled="true" />
<messaging>
<untrustedWebRequest>
<whitelistHosts>
<add name="localhost"/>
</whitelistHosts>
</untrustedWebRequest>
</messaging>
</dotNetOpenAuth>
<appSettings/>
<connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" targetFramework="4.0">
<assemblies>
<remove assembly="DotNetOpenAuth.Contracts"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms name="oauthSP" />
</authentication>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<log4net>
<appender name="TracePageAppender" type="OAuthServiceProvider.Code.TracePageAppender, OAuthServiceProvider">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline"/>
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<level value="INFO"/>
<!--<appender-ref ref="RollingFileAppender" />-->
<appender-ref ref="TracePageAppender"/>
</root>
<!-- Specify the level for some specific categories -->
<logger name="DotNetOpenAuth">
<level value="ALL"/>
</logger>
</log4net>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="DataApiBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization serviceAuthorizationManagerType="OAuthServiceProvider.Code.OAuthAuthorizationManager, OAuthServiceProvider" principalPermissionMode="Custom"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DataApiBehavior" name="OAuthServiceProvider.DataApi">
<endpoint address="" binding="wsHttpBinding" contract="OAuthServiceProvider.Code.IDataApi">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

Unable to set maxReceivedMessageSize through web.config

I have now investigated the 400 - BadRequest code for the last two hours.
A lot of sugestions goes towards ensuring the bindingConfiguration attribute is set correctly, and in my case, it is.
Now, I need YOUR help before destroying the building i am in :-)
I run a WCF RestFull service (very lightweight, using this resource for inspiration: http://msdn.microsoft.com/en-us/magazine/dd315413.aspx) which (for now) accepts an XmlElement (POX) provided through the POST verb.
I am currently ONLY using Fiddler's request builder before implementing a true client (as this is mixed environments).
When I do this for XML smaller than 65K, it works fine - larger, it throws this exception:
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.
Here is my web.config file (which I even included the client-tag for (desperate times!)):
<system.web>
<httpRuntime maxRequestLength="1500000" executionTimeout="180"/>
</system.web>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<webHttpBinding>
<binding name="WebHttpBinding" maxReceivedMessageSize="1500000" maxBufferPoolSize="1500000" maxBufferSize="1500000" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
<readerQuotas maxStringContentLength="1500000" maxArrayLength="1500000" maxBytesPerRead="1500000" />
<security mode="None"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="" binding="webHttpBinding" bindingConfiguration="WebHttpBinding" contract="Commerce.ICatalogue"/>
</client>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Catalogue">
<endpoint address=""
behaviorConfiguration="RestFull"
binding="webHttpBinding"
bindingConfiguration="WebHttpBinding"
contract="Commerce.ICatalogue" />
<!-- endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" / -->
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestFull">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Thanks in advance for any help leading to succesfull call with >65K XML ;-)
All right, this one really caused me a hard time resolving, which I will spare others for.
The challenge was in the fact, that I used the <%# ServiceHost Factory="System.ServiceModel.Activation.WebServiceHostFactory" Service="fullyQualifiedClassName" %>, which is a nice and easy factory implementation approach.
However, this approach has it drawbacks; since no configuration is needed in the web.config file, the WebServiceHostFactory class by design does not ever read from the web.config file.
I know; I could inherit from this class, and make the appropriate changes so it may indeed read from the config file, but this seemed a little out of scope.
My solution was to go back to the more traditional way of implementing the WCF; <%# ServiceHost Service="fullyQualifiedClassName" CodeBehind="~/App_Code/Catalogue.cs" %>, and then use my already configured values in the web.config file.
Here is my modified web.config file (with respect to Maddox headache):
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="XmlMessageBinding" maxReceivedMessageSize="5000000" maxBufferPoolSize="5000000" maxBufferSize="5000000" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
<readerQuotas maxStringContentLength="5000000" maxArrayLength="5000000" maxBytesPerRead="5000000" />
<security mode="None"/>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="fullyQualifiedClassName" behaviorConfiguration="DevelopmentBehavior">
<endpoint name="REST" address="" binding="webHttpBinding" contract="fullyQualifiedInterfaceName" behaviorConfiguration="RestEndpointBehavior" bindingConfiguration="XmlMessageBinding" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestEndpointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DevelopmentBehavior">
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior name="ProductionBehavior">
<serviceDebug httpHelpPageEnabled="false" includeExceptionDetailInFaults="false"/>
<serviceMetadata httpGetEnabled="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Another benefit of this change is, that you can now reference your WCF-rest service directly from .NET; this cannot be done using the Factory model and my implementation of XmlElement through out the solution.
I hope this can help others with similar issues ...
I know this is a very old Question and it already has an answer...
Anyway...
What I did to solve this "issue" I created a Factory inherited from WebServiceHostFactory and created a Custom Service Host inherited from WebServiceHost
And in the host I overrode the OnOpening method like this
protected override void OnOpening()
{
base.OnOpening();
foreach (var endpoint in Description.Endpoints)
{
var binding = endpoint.Binding as System.ServiceModel.Channels.CustomBinding;
foreach (var element in binding.Elements)
{
var httpElement = element as System.ServiceModel.Channels.HttpTransportBindingElement;
if (httpElement != null)
{
httpElement.MaxBufferSize = 2147483647;
httpElement.MaxReceivedMessageSize = 2147483647;
}
}
}
}
I think i had the same issue, but when i configured the default-binding for webHttp then it worked:
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2000000"
maxBufferSize="2000000">
<readerQuotas maxStringContentLength="2000000"/>
</binding>
</webHttpBinding>
</bindings>
Observe: no name on the binding.
This is a blog entry I wrote that reproduces this problem with an absolutely minimal WCF server and client piece:
WCF - Fixing client side string length exceptions
In particular, you may need a Custom Binding Configuration. At least reproducing this sample may give you some ideas for your particular situation.