Camunda: How to get DMN to emit two variable/values to context of BPM workflow? - camunda

I want the two output values from DMN row, be sent to BPMN context, e.g DMN.output.var1=val1, DMN.output.var2=val2.
Input: (SPACE=LAW, THING=VANDALISM)
Output: (ROUT_TO_DEPT=BY_LAW, OUT_CATEGORY=INSPECTION)
These two variables must be in context, and available to next step in BPMN.
However I'm getting an error, how to make it happen?
DMN
Error
Stacktrace:
Caused by: org.camunda.bpm.engine.ProcessEngineException: ENGINE-22002 The decision result mapper 'CollectEntriesDecisionResultMapper{}' failed to process '[{ROUT_TO_DEPT=Value 'BY_LAW' of type 'PrimitiveValueType[string]', isTransient=false, OUT_CATETORY=Value 'INSPECTION' of type 'PrimitiveValueType[string]', isTransient=false}]'. The decision outputs should only contains values for one output name but found '[ROUT_TO_DEPT, OUT_CATETORY]'.
at org.camunda.bpm.engine.impl.dmn.DecisionLogger.decisionResultCollectMappingException(DecisionLogger.java:44)
at org.camunda.bpm.engine.impl.dmn.result.CollectEntriesDecisionResultMapper.mapDecisionResult(CollectEntriesDecisionResultMapper.java:46)
at org.camunda.bpm.engine.impl.util.DecisionEvaluationUtil.evaluateDecision(DecisionEvaluationUtil.java:79)
at org.camunda.bpm.engine.impl.bpmn.behavior.DmnBusinessRuleTaskActivityBehavior$1.call(DmnBusinessRuleTaskActivityBehavior.java:56)
at org.camunda.bpm.engine.impl.bpmn.behavior.DmnBusinessRuleTaskActivityBehavior$1.call(DmnBusinessRuleTaskActivityBehavior.java:53)
at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.executeWithErrorPropagation(AbstractBpmnActivityBehavior.java:90)
at org.camunda.bpm.engine.impl.bpmn.behavior.DmnBusinessRuleTaskActivityBehavior.execute(DmnBusinessRuleTaskActivityBehavior.java:53)
at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute$2.callback(PvmAtomicOperationActivityExecute.java:61)
at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute$2.callback(PvmAtomicOperationActivityExecute.java:50)
at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.continueIfExecutionDoesNotAffectNextOperation(PvmExecutionImpl.java:1996)
at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:42)
at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:31)
at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:96)
at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:128)
I tried to make it as resultList variable, however what I wanted is two output variables - a tuple.
Edit 1: If I choose "singleResult" option, I'm able to get it as a map in one single variable, however I want TWO varibles going to next STEP in a BPMN flow.

The mapping to resultList is used to map a list of rows with multiple output columns.
Switching to singleResult was the right direction. You are using a hit policy "First" (one rule/ row only), so the map decision result property can only be singleEntry (one output column) or singleResult (several output columns).
After mapping the decision result to a singleResult, you can use the Input/Output tab in the property panel to map the result entries to process variables:
In the text field of the output mapping you can use unified expression language, e.g. ${deptRoureDetail.get('ROUT_TO_DEPT')}
to access the result variable (in your case deptRoutDetail) of type Map and access the desired fields (ROUT_TO_DEPT, etc) by their keys.
Full example:
a) BPMN
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_17ij5vv" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
<bpmn:process id="Process_TwoOutputs" name="Two Outputs" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="customer" label="Customer" type="string" defaultValue="Miller" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:outgoing>SequenceFlow_1uzzene</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1uzzene" sourceRef="StartEvent_1" targetRef="Task_EvaluteRules" />
<bpmn:businessRuleTask id="Task_EvaluteRules" name="Evalute Rules" camunda:resultVariable="result" camunda:decisionRef="Decision_twoOutputs" camunda:mapDecisionResult="singleResult">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:outputParameter name="blacklisted">${result.get('blacklistedCustomer')}</camunda:outputParameter>
<camunda:outputParameter name="pep">${result.get('pepCustomer')}</camunda:outputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1uzzene</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_10pcdah</bpmn:outgoing>
</bpmn:businessRuleTask>
<bpmn:sequenceFlow id="SequenceFlow_10pcdah" sourceRef="Task_EvaluteRules" targetRef="Task_00rrqy1" />
<bpmn:endEvent id="EndEvent_0f61xh5">
<bpmn:incoming>SequenceFlow_1fsnixe</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1fsnixe" sourceRef="Task_00rrqy1" targetRef="EndEvent_0f61xh5" />
<bpmn:scriptTask id="Task_00rrqy1" name="Print both variables" scriptFormat="javascript">
<bpmn:incoming>SequenceFlow_10pcdah</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1fsnixe</bpmn:outgoing>
<bpmn:script>print("blacklisted: " + blacklisted);
print("pep: " + pep);</bpmn:script>
</bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_TwoOutputs">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1uzzene_di" bpmnElement="SequenceFlow_1uzzene">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="BusinessRuleTask_1oc25xp_di" bpmnElement="Task_EvaluteRules">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_10pcdah_di" bpmnElement="SequenceFlow_10pcdah">
<di:waypoint x="370" y="117" />
<di:waypoint x="430" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_0f61xh5_di" bpmnElement="EndEvent_0f61xh5">
<dc:Bounds x="592" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1fsnixe_di" bpmnElement="SequenceFlow_1fsnixe">
<di:waypoint x="530" y="117" />
<di:waypoint x="592" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ScriptTask_1xt3142_di" bpmnElement="Task_00rrqy1">
<dc:Bounds x="430" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
b) DMN
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_0cib9be" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
<decision id="Decision_twoOutputs" name="Two Outputs">
<extensionElements>
<biodi:bounds x="150" y="150" width="180" height="80" />
</extensionElements>
<decisionTable id="decisionTable_1">
<input id="input_1" label="Customer Name">
<inputExpression id="inputExpression_1" typeRef="string">
<text>customer</text>
</inputExpression>
</input>
<output id="output_1" label="blacklisted" name="blacklistedCustomer" typeRef="string" />
<output id="OutputClause_18xxjii" label="Politically Exposed Person" name="pepCustomer" typeRef="boolean" />
<rule id="DecisionRule_0qg0ni4">
<inputEntry id="UnaryTests_1i6rkew">
<text>"Miller"</text>
</inputEntry>
<outputEntry id="LiteralExpression_12xbrsq">
<text>"clear"</text>
</outputEntry>
<outputEntry id="LiteralExpression_1obxdmm">
<text>false</text>
</outputEntry>
</rule>
<rule id="DecisionRule_06aolv9">
<inputEntry id="UnaryTests_0oeomwy">
<text>"Smith"</text>
</inputEntry>
<outputEntry id="LiteralExpression_1xobooq">
<text>"clear"</text>
</outputEntry>
<outputEntry id="LiteralExpression_0sok0z4">
<text>true</text>
</outputEntry>
</rule>
<rule id="DecisionRule_0ki09vh">
<inputEntry id="UnaryTests_096b0z2">
<text>"Jones"</text>
</inputEntry>
<outputEntry id="LiteralExpression_11x7v5h">
<text>"blacklisted"</text>
</outputEntry>
<outputEntry id="LiteralExpression_1nit6ye">
<text>false</text>
</outputEntry>
</rule>
<rule id="DecisionRule_0tifgq8">
<inputEntry id="UnaryTests_0fqbez3">
<text>"Doe"</text>
</inputEntry>
<outputEntry id="LiteralExpression_0yghulu">
<text>"blacklisted"</text>
</outputEntry>
<outputEntry id="LiteralExpression_1j2jmlj">
<text>true</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions>
c) jUnit Test
import org.camunda.bpm.dmn.engine.DmnDecisionTableResult;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.camunda.bpm.engine.variable.Variables;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.init;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.decisionService;
public class DMNUnitTest {
#Rule
public ProcessEngineRule rule = new ProcessEngineRule();
#Before
public void setup() {
init(rule.getProcessEngine());
}
#Test
#Deployment(resources = {"twoOutputs.dmn"})
public void testNoFlags() {
Map<String, Object> variables = Variables.createVariables().putValue("customer", "Miller");
DmnDecisionTableResult results = decisionService().evaluateDecisionTableByKey("Decision_twoOutputs", variables);
assertThat(results).hasSize(1);
assertThat(results.getSingleResult())
.contains(entry("blacklistedCustomer", "clear"))
.contains(entry("pepCustomer", false));
}
#Test
#Deployment(resources = {"twoOutputs.dmn", "twoOutputs.bpmn"})
public void testProcessWithtwoDecisionOutputs() {
Map<String, Object> variables = Variables.createVariables().putValue("customer", "Miller");
ProcessInstance pi = rule.getRuntimeService().startProcessInstanceByKey("Process_TwoOutputs", variables);
org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.assertThat(pi).hasVariables("blacklisted","pep");
}
}

Related

OpenCover not working, it always shows 0% Code coverage

Visual Studio 2019 Community Edition
Project Framework 4.5
My Environment: Windows Server 2016
Expected Behavior: Expected to show code coverage as the covered percentage.
Actual Behavior: The Code coverage is always shown as 0
Command Used :
OpenCover.Console.exe -target:"<PATH>\xunit.runner.console.2.4.1\tools\net472\xunit.console.x86.exe" -targetargs:"<PATH>\bin\Debug\PROJECT_Tests.dll" -register:user -output:"<PATH>\bin\Debug\TestResults\OpenCover\coverage.xml"
I have tried the same with vstest runner also.
In cmd, the output is shown as :
=== TEST EXECUTION SUMMARY ===
PROJECT_Tests Total: 11, Errors: 0, Failed: 0, Skipped: 0, Time: 118.717s
Committing...
Visited Classes 235 of 1338 (17.56)
Visited Methods 942 of 17022 (5.53)
Visited Points 2632 of 58653 (4.49)
Visited Branches 1607 of 36315 (4.43)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 235 of 1570 (14.97)
Alternative Visited Methods 942 of 18541 (5.08)
But, when checking the coverage.xml file or using report generator (v4.5.0) we generate the report all the files are shown as 0% coverage.
<Method visited="false" cyclomaticComplexity="4" nPathComplexity="2" sequenceCoverage="0" branchCoverage="0" crapScore="20" isConstructor="false" isStatic="false" isGetter="false" isSetter="false">
<Summary numSequencePoints="8" visitedSequencePoints="0" numBranchPoints="3" visitedBranchPoints="0" sequenceCoverage="0" branchCoverage="0" maxCyclomaticComplexity="4" minCyclomaticComplexity="4" maxCrapScore="20" minCrapScore="20" visitedClasses="0" numClasses="0" visitedMethods="0" numMethods="1" />
<MetadataToken>100664627</MetadataToken>
<Name>project.BusinessEntities.CoordinationNotes.CoordinationNotesInfo project.CoordinationNotes.DalCoordinationNotes::GetDetails(project.BusinessEntities.SystemManagement.GeneralRequest,project.BusinessEntities.Member.MemberTaskList&,System.Object&)</Name>
<FileRef uid="2505" />
<SequencePoints>
<SequencePoint vc="0" uspid="75974" ordinal="0" offset="0" sl="38" sc="9" el="38" ec="10" bec="0" bev="0" fileid="2505" />
<SequencePoint vc="0" uspid="75975" ordinal="1" offset="1" sl="39" sc="13" el="39" ec="131" bec="0" bev="0" fileid="2505" />
<SequencePoint vc="0" uspid="75976" ordinal="2" offset="44" sl="41" sc="20" el="41" ec="56" bec="0" bev="0" fileid="2505" />
<SequencePoint vc="0" uspid="75977" ordinal="3" offset="56" sl="42" sc="13" el="42" ec="14" bec="0" bev="0" fileid="2505" />
<SequencePoint vc="0" uspid="75978" ordinal="4" offset="57" sl="43" sc="17" el="43" ec="75" bec="0" bev="0" fileid="2505" />
<SequencePoint vc="0" uspid="75979" ordinal="5" offset="72" sl="45" sc="17" el="45" ec="115" bec="2" bev="0" fileid="2505" />
<SequencePoint vc="0" uspid="75980" ordinal="6" offset="99" sl="47" sc="17" el="47" ec="29" bec="0" bev="0" fileid="2505" />
<SequencePoint vc="0" uspid="75981" ordinal="7" offset="114" sl="49" sc="9" el="49" ec="10" bec="0" bev="0" fileid="2505" />
</SequencePoints>
<BranchPoints>
<BranchPoint vc="0" uspid="75982" ordinal="0" offset="79" sl="45" path="0" offsetend="81" fileid="2505" />
<BranchPoint vc="0" uspid="75983" ordinal="1" offset="79" sl="45" path="1" offsetend="84" fileid="2505" />
</BranchPoints>
<MethodPoint xsi:type="SequencePoint" vc="0" uspid="75974" ordinal="0" offset="0" sl="38" sc="9" el="38" ec="10" bec="0" bev="0" fileid="2505" />
</Method>
Any suggestions? What am I doing wrong? Or any alternative for Code coverage in c# community Edition?
The issue was with the profiler. profiling was timing out after 60 seconds and not showing any error. More details can be found at : https://github.com/OpenCover/opencover/issues/728
The issue in filed in the latest release candidate v 4.7.1138.

Sitecore Feature ActiveDirectory - adding AD domain to the domainManager doesn't work

I'm using Habitat Sitecore. It comes with a bunch of foundation and feature projects. One of the feature projects is Sitecore.Feature.ActiveDirectory.
I'm trying to configure domains from patch files. It is outlined by Kam in this blog.
In the /App_config/Include/Feature/Feature.ActiveDirectory.config, I added the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<switchingProviders>
<membership>
<provider providerName="ad" storeFullNames="false" wildcard="*" domains="ad" />
</membership>
<roleManager>
<provider providerName="ad" storeFullNames="false" wildcard="*" domains="ad" />
</roleManager>
</switchingProviders>
<domainManager>
<domains>
<domain id="ad" type="Sitecore.Security.Domains.Domain, Sitecore.Kernel" patch:after="domain[#id='default']">
<param desc="name">$(id)</param>
<ensureAnonymousUser>false</ensureAnonymousUser>
<locallyManaged>false</locallyManaged>
<isDefault>false</isDefault>
</domain>
</domains>
</domainManager>
</sitecore>
</configuration>
However, I get the following Exception:
A domain specified in the Sitecore.Security.SwitchingRoleProvider provider/domain map could not be found. Domain name: ad
in
<add name="switcher" type="Sitecore.Security.SwitchingRoleProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/roleManager" />
What am I doing wrong?
Domains must be added directly to to Domains.config, located in App_Config\Security. It is not able to be patched. Make it part of your build train.

Tracing to LogSource 'All Events' failed. Enterprise Library logging error

I am getting error. I am unable to understand what causing error. There are no exception on UI.
Category tables has values (Information,Exception,Debug,General). When all events failed error occurs there is no record entered into CategoryLog table. Can someone please help me to understand this error and to fix it.
Tracing to LogSource 'All Events' failed. Processing for other sources will continue.
See summary information below for more information. Should this problem persist,
stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.
Summary for Enterprise Library Distributor Service:
====================================== -->
Message: Timestamp: 11/4/2014 9:35:46 PM
Message: 'Some message'.
WebConfig:-
<listeners>
<add name="DatabaseTraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=########"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=#######"
databaseInstanceName="LoggingDatabase" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory"
formatter="Text Formatter"
traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=#####"
template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="Error" name="Error">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</add>
<add switchValue="Information" name="Information">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</add>
<add switchValue="Warning" name="Warning">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</errors>
</specialSources>
Error record in log table looks like this
LogID: ######
EventID : 6352
Priority: -1
Severity: Error
Title :
Timestamp: 2014-11-10 00:55:51.770
MachineName : ########
AppDomainName: /LM/W3SVC/3/ROOT-######
ProcessID: 5272
ProcessName: c:\windows\system32\inetsrv\w3wp.exe
ThreadName: NULL
Win32ThreadId: 8852
Message :Tracing to LogSource 'All Events' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks. Summary for Enterprise Library Distributor Service:
====================================== --> Message: Timestamp:
FormattedMessage :
You are encountering an error logging to your database. But it seems that it is not totally catastrophic since it seems errors are being logged. This rules out a common cause such as invalid connection string.
You need to find out what the actual error is. To do this change the errors special source to log to a file (in a location with proper permissions). So add a flat file trace listener:
<listeners>
<add name="DatabaseTraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=########"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=#######"
databaseInstanceName="LoggingDatabase" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory"
formatter="Text Formatter"
traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" />
<add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="trace.log" />
</listeners>
and then set the error special source to use the flat file trace listener:
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
With that setting you should hopefully see the full details of the error.
Making the user tries to write the log as admin is the solution for this problem. UAC setting can also be changed to make the IIS user as admin.

ant-contrib for loop and regex in ant scripting

I have a requirement using ant, that the target should extract the two parameters passed as comma separated in a long list of similar pair of parameters passed which are semicolon separated. Currently I am doing something like this:
<?xml version="1.0"?>
<project name="" basedir="." default="test" xmlns:ac="antlib:net.sf.antcontrib">
<target name="test" >
<echo message="Hey There I am using What's App" />
<ac:for list="asdfg,dasfdf;vxxexqxx,hyyypyly;dksfgsgdgf,abaifuacu" delimiter=";" param="val">
<ac:sequential>
<ac:propertyregex property="param1"
input="#{val}"
regexp="([^\.]*)\,.*"
select="\1"
casesensitive="true" />
<ac:propertyregex property="param2"
input="#{val}"
regexp=".*,([^\.]*)"
select="\1"
casesensitive="true" />
<echo message = "val = ${param1}"/>
<echo message = "value = ${param2}"/>
</ac:sequential>
</ac:for>
</target>
</project>
But I am getting the output as:
Buildfile: /tmp/Manish/build.xml
test:
[echo] Hey There I am using What's App
[echo] val = asdfg
[echo] value = dasfdf
[echo] val = asdfg
[echo] value = dasfdf
[echo] val = asdfg
[echo] value = dasfdf
So this is getting looped 3 times(correct) but by only the first value passed in the for loop parameter. Is there some obvious mistake I am making?
Thanks,
Manish Joshi
Try using foreach instead of for and put the propertyregex into a separate target. Here is an example from my ant script, it basically does the same thing.
<target name="loadTestStatic" depends="setTargetEnv,setPassword">
<loadfile property="controlFile" srcFile="${projectDir}/test/config/static/controlFile.txt"/>
<foreach list="${controlFile}" delimiter="${line.separator}" param="descriptor" target="loadConfig"/>
</target>
<target name="loadConfig">
<if>
<matches string="${descriptor}" pattern="^camTool:"/>
<then>
<propertyregex property="camToolFile"
input="${descriptor}"
regexp="camTool:(.*)"
select="\1"
casesensitive="false" />
<echo message="Got cam tool file ${camToolFile}"/>
<camTool file="${camToolFile}"/>
</then>
<else>
<!-- todo: add CM Tool, SQL as required -->
<echo message="Unexpected config ${descriptor} ignored"/>
</else>
</if>
</target>
An alternative approach is to use a scripting language like groovy.
<groovy>
<arg value="asdfg,dasfdf;vxxexqxx,hyyypyly;dksfgsgdgf,abaifuacu"/>
args[0].tokenize(";").each {
def m = it.tokenize(",")
println "val = ${m[0]}"
println "value = ${m[1]}"
}
</groovy>
Alternatively use Ant addon Flaka, f.e. :
<project xmlns:fl="antlib:it.haefelinger.flaka">
<!-- with cvs property -->
<property name="foobar" value="asdfg,dasfdf;vxxexqxx,hyyypyly;dksfgsgdgf,abaifuacu"/>
<fl:for var="item" in="split('${foobar}', ';')">
<fl:let>
param1 ::= split(item, ',')[0]
param2 ::= split(item, ',')[1]
</fl:let>
<echo>
$${param1} => ${param1}
$${param2} => ${param2}
</echo>
</fl:for>
<!-- with list inline -->
<fl:for var="item" in="split('asdfg,dasfdf;vxxexqxx,hyyypyly;dksfgsgdgf,abaifuacu', ';')">
<fl:let>
param1 ::= split(item, ',')[0]
param2 ::= split(item, ',')[1]
</fl:let>
<echo>
$${param1} => ${param1}
$${param2} => ${param2}
</echo>
</fl:for>
</project>
Notice the double '::' in param1 ::= split(item, ',')[0]
means overriding any (also userproperties, defined via -Dkey=value as commandline arguments) existing property
whereas ':=' creates a property but won't overwrite if property already exists.
<target name="myTarget">
<ac:propertyregex property="param1"
input="${myValue}"
regexp="([^\.]*)\,.*"
select="\1"
casesensitive="true" />
<ac:propertyregex property="param2"
input="${myValue}"
regexp=".*,([^\.]*)"
select="\1"
casesensitive="true" />
<echo message = "val = ${param1}"/>
<echo message = "value = ${param2}"/>
</target>
<ac:for list="asdfg,dasfdf;vxxexqxx,hyyypyly;dksfgsgdgf,abaifuacu" delimiter=";" param="val">
<ac:sequential>
<antcall target="myTarget">
<param name="myValue" value="#{val}" />
</antcall>
</ac:sequential>
</ac:for>
Properties in Ant are immutable. You will need to use the variable task from ant-contrib (although it is discouraged) to unset the properties:
<ac:for list="asdfg,dasfdf;vxxexqxx,hyyypyly;dksfgsgdgf,abaifuacu" delimiter=";" param="val">
<ac:sequential>
<ac:propertyregex property="param1"
input="#{val}"
regexp="([^\.]*)\,.*"
select="\1"
casesensitive="true" />
<ac:propertyregex property="param2"
input="#{val}"
regexp=".*,([^\.]*)"
select="\1"
casesensitive="true" />
<echo message = "val = ${param1}"/>
<echo message = "value = ${param2}"/>
<ac:var name="param1" unset="true"/>
<ac:var name="param2" unset="true"/>
</ac:sequential>
</ac:for>

POST Method in wcf Rest Service

i am getting the same error:
protected void Button1_Click(object sender, EventArgs e)
{
BasicHttpBinding binding = new BasicHttpBinding();
binding.ReaderQuotas.MaxStringContentLength = 2000000;
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
binding.Security.Transport.ClientCredentialTypeHttpClientCredentialType.Windows;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.CloseTimeout = new TimeSpan(4, 0, 0);
binding.OpenTimeout=new TimeSpan(4, 0, 0);
binding.ReceiveTimeout=new TimeSpan(2, 0, 0);
binding.SendTimeout = new TimeSpan(5, 0, 0);
EndpointAddress endpoint = new EndpointAddress(new Uri("http://localhost:35798/RestServiceImpl.svc"));
RestPostService.RestServiceImplClient obj = new RestPostService.RestServiceImplClient(binding, endpoint);
RestPostService.EmailDetails obj1 = new RestPostService.EmailDetails();
obj.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
RestPostService.EmailDetails obj2=obj.SendMail(obj1);
}
**web.config**
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"/>
</webHttpBinding>
</bindings>
<services>
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
<endpoint address ="http://localhost:35798/RestServiceImpl" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="webHttp"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="webHttp">
<!-- 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="true"/>
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
What changes should i made in order to make the code working.
Error: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
Please help in the indiacted issue.
You are using the wrong WCF binding in you code. The config XML shows the WCF service using the WebHttpBinding. Refactor your client creation code to something like:
WebHttpBinding binding = new WebHttpBinding();
// The rest of the configuration
Don't know if all the properties you are setting will be valid for this binding but the compiler will know :)