I have a chef deployment that runs like this:
encryptedvalues = chef_vault_item(node.chef_environment, 'my_app_name')
do_windows_service "Installing Windows Service" do
action :install
#...
app_config_changes ({
"configuration/secureAppSettings/add[#key='XSWebserviceUser']/#value" => "#{encryptedvalues['XSWebserviceUser']}",
"configuration/secureAppSettings/add[#key='XSWebservicePassword']/#value" => "#{encryptedvalues['XSWebservicePassword']}"
})
end
I have determined that the values are correct, they are inserted into the correct position, and everything is fine, until the encrypted password value has "$" in it. I cannot change the password, and tried to escape it by wrapping it in an interpolated string: "#{pass}", but unfortunately it didn't work. Any ideas on how I can get the deploy to succeed?
Originally in the app config it looks like
<secureAppSettings>
<add key="XSWebserviceUser" value="XXX" />
<add key="XSWebservicePassword" value="XXX" />
</secureAppSettings>
and after deployment with a password="xyz#$%xyz"
<secureAppSettings>
<add key="XSWebserviceUser" value="User" />
<add key="XSWebservicePassword" value="xyz#" />
</secureAppSettings>
Update: Checking the logs I see this in the server
4. 2020-01-08T23:36:36.3315043Z STDERR: Cannot convert value "System.String" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 0.
Looks like it may actually be an issue with windows powershell?
Related
I have a scenario where I am filtering a xml payload based on a xpath value.
<int:channel id="documentReceiptFilterChannel" />
<int:chain input-channel="documentReceiptFilterChannel" output-channel="nullChannel">
<!-- Filter to discard message if <statusCode> value is 'EMLOK' -->
<int-xml:xpath-filter match-type="regex" match-value="^(?!\bEMLOK\b).*$" discard-channel="nullChannel">
<int-xml:xpath-expression expression="//*[local-name()='statusCode']" />
</int-xml:xpath-filter>
<int:service-activator expression="#opsLogger.logError('TransactionId=' + headers.correlationId, ' Msg=' + #opsExceptionUtils.createOPSExceptionInstance(#root))" />
</int:chain>
Following is the payload:
<?xml version="1.0" encoding="UTF-8"?>
<GetDocumentReceiptReply xmlns="http://example.org"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<mergeReceiptDeliveryStatus>
<statusCode>EMLOK</statusCode>
</mergeReceiptDeliveryStatus>
</GetDocumentReceiptReply>
My requirement is that when <statusCode>EMLOK</statusCode> element is available, discard the message and hence nullChannel is mentioned as discard-channel.
But then there is any other value, proceed to the next step in the chain and do the error logging - <int:service-activator expression="#opsLogger.logError().
The above setup works fine as long as <statusCode> element is present in the payload. But doesn't work on the following situations:
<statusCode></statusCode>
<statusCode/>
<statusCode> is missing
Or any other xml payload
To get rid of namespace issues, the xpath expression is formed as <int-xml:xpath-expression expression="//*[local-name()='statusCode']" />. The xpath value is matched against regex expression match-type="regex" match-value="^(?!\bEMLOK\b).*$" (For value != 'EMLOK').
What happens when <int-xml:xpath-expression /> evaluation fails?
My only requirement is that if <statusCode>EMLOK</statusCode> is present, discard the message, else for all other, log an error in the log file. (And not to throw an exception that will propagate to error-channel).
You could write a custom subclass of AbstractXPathMessageSelector and delegate to a BooleanTestXPathMessageSelector and a RegexTestXPathMessageSelector, or simply use 2 filters...
<int:chain input-channel="documentReceiptFilterChannel" output-channel="errors">
<int-xml:xpath-filter discard-channel="errors">
<int-xml:xpath-expression expression="//*[local-name()='statusCode']" />
</int-xml:xpath-filter>
<int-xml:xpath-filter match-type="regex" match-value="^(?!\bEMLOK\b).*$">
<int-xml:xpath-expression expression="//*[local-name()='statusCode']" />
</int-xml:xpath-filter>
</int:chain>
<int:service-activator
expression="#opsLogger.logError('TransactionId=' + headers.correlationId, ' Msg=' + #opsExceptionUtils.createOPSExceptionInstance(#root))" />
Notice that you don't need to discard to nullChannel - just omitting the discard channel will cause discards. Messages that pass the second filter go to the chain's output channel.
The custom selector would be a little more efficient because only one conversion to node is needed.
I have a simple http-inbound-gateway that calls a service-activator and returns the result to the HTTP client.
The service-activator returns a String containing Unicode escape sequences, like this:
Fran\u00e7ais
This is passed to the http-inbound-gateway to be returned to the client as a response payload.
When I call the inbound gateway's URL, however, there seems to be some conversion going on; the escape sequences are rendered into their binary format which my browser cannot render:
Fran�ais
I would like the escape sequences to be passed through the inbound-http-gateway and returned to the browser.
What I should be doing to achieve that result?
Here is the relevant SI config:
<http:inbound-gateway
id="inboundGateway"
request-channel="inboundClientRequestChannel"
request-payload-type="java.lang.String"
reply-channel="inboundClientResponseChannel"
reply-timeout="30000"
supported-methods="GET"
message-converters="stringJsonMessageConverter"
path="/test">
<http:request-mapping produces="application/json"/>
</http:inbound-gateway>
<int:service-activator
input-channel="inboundClientRequestChannel"
output-channel="inboundClientResponseChannel"
ref="clientRequestHandler"/>
<bean id="stringJsonMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="writeAcceptCharset" value="false"/>
<property name="supportedMediaTypes">
<list>
<value>application/json</value>
</list>
</property>
</bean>
The problem here was that the stringJsonMessageConverter, an instance of org.springframework.http.converter.StringHttpMessageConverter, by default converts Strings to the ISO-8859-1 encoding.
See the Javadoc here. Note the defaultCharset constructor parameter.
Initializing stringJsonMessageConverter to use the UTF-8 encoding solved the problem.
in my proxy i'm using a filter mediator. My target is to activate a sequence if some conditions on some properties are verified:
codice = 0
idElementoCross is different from null or empty string or if it exists
tipoElementoCross is different from null or empty string or if it exists
i wrote this condition:
<sequence>
<property name="codice" expression="//codice"></property>
<property name="idElementoCross" expression="//idElementoCross"></property>
<property name="tipoElementoCross" expression="//tipoElementoCross"></property>
<filter xpath="boolean(fn:get-property('codice')=0 and fn:get-property('tipoRisposta')='worker' and fn:get-property('tipoElementoCross')!='null' and fn:get-property('idElementoCross')!='null' and fn:get-property('tipoElementoCross')!='' and fn:get-property('idElementoCross')!='' and fn:get-property('tipoElementoCross') and fn:get-property('idElementoCross'))">
<then> ...
but in my log i see that esb enter the sequence even if idElementoCross and tipoElementoCross are empty.
Im using WSO2 ESB 4.8.1.
What am i missing?
This is because when there is no value, //tipoElementoCross return the node and not the text value :
send <tipoElementoCross></tipoElementoCross>
//tipoElementoCross = <tipoElementoCross></tipoElementoCross>
//tipoElementoCross/text() =
In SSIS (MS Visual Studio 2010) I have created a SQL Task with Single Row output (int32) that is passed to User::Variable. Then I have a "For Loop" that I want to run as many times as the integer from the SQL Task query equals to. I have setup the For Loop with the following:
InitExpression: #Start = 1
EvalExpression: #Variable >= #Start
AssignExpression: #Start = #Start+1
In my test example, the #Variable is set to 4 by SQL Task query, and the loop runs fine for the first loop, but then immediately finishes reporting package successfully executed (after just 1 loop when it should have looped 4 times).
It is like the #Variable resets to default value (0) after the first loop is done instead of keeping the original value (4).
How can I fix this?
What's more likely: using the name Variable, which SSIS defaults to for a new variable, is incompatible with anything in an SSIS package or that you've done something that you haven't shown?
I have created a package with two Variables, Variable and Start. I have populated Variable from a SQL Query with the value of 4 and then used a For Loop as described and I did not experience early termination.
My package, variables with design time values set to zero.
My For Loop Container
Last iteration of the loop
Reproducible results
Biml, the Business Intelligence Markup Language, describes the platform for business intelligence. Here, we're going to use it to describe the ETL. BIDS Helper, is a free add on for Visual Studio/BIDS/SSDT that addresses a host of shortcomings with it.
You will need to edit line 3 to be a valid OLE DB Connection Manager for your machine (point to a SQL Server installation and possibly update the Provider)
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<OleDbConnection Name="CM_OLE" ConnectionString="Data Source=localhost\dev2012;Initial Catalog=tempdb;Provider=SQLNCLI11;Integrated Security=SSPI;" />
</Connections>
<Packages>
<Package Name="so_25878932" ConstraintMode="Linear">
<Variables>
<Variable Name="Variable" DataType="Int32">0</Variable>
<Variable Name="Start" DataType="Int32">0</Variable>
</Variables>
<Tasks>
<ExecuteSQL ConnectionName="CM_OLE" Name="SQL Variable" ResultSet="SingleRow">
<DirectInput>SELECT 4 AS Variable;</DirectInput>
<Results>
<Result Name="0" VariableName="User.Variable"/>
</Results>
</ExecuteSQL>
<ForLoop ConstraintMode="Linear" Name="FLC Go">
<InitializerExpression>#Start = 1</InitializerExpression>
<LoopTestExpression>#Variable >= #Start</LoopTestExpression>
<CountingExpression>#Start = #Start + 1</CountingExpression>
<Tasks>
<!--
Pilfered from http://bimlscript.com/Snippet/Details/74
-->
<Script
ProjectCoreName="ST_232fecafb70a4e8a904cc21f8870eed0"
Name="SCR Emit Variable and Start">
<ReadOnlyVariables>
<ReadOnlyVariable VariableName="User.Variable" />
<ReadOnlyVariable VariableName="User.Start" />
</ReadOnlyVariables>
<ScriptTaskProject>
<ScriptTaskProject ProjectCoreName="ST_c41ad4bf47544c49ad46f4440163feae" Name="TaskScriptProject1">
<AssemblyReferences>
<AssemblyReference AssemblyPath="Microsoft.SqlServer.ManagedDTS.dll" />
<AssemblyReference AssemblyPath="Microsoft.SqlServer.ScriptTask.dll" />
<AssemblyReference AssemblyPath="System.dll" />
<AssemblyReference AssemblyPath="System.AddIn.dll" />
<AssemblyReference AssemblyPath="System.Data.dll" />
<AssemblyReference AssemblyPath="System.Windows.Forms.dll" />
<AssemblyReference AssemblyPath="System.Xml.dll" />
</AssemblyReferences>
<Files>
<File Path="AssemblyInfo.cs">
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("ST_c41ad4bf47544c49ad46f4440163feae.csproj")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Varigence")]
[assembly: AssemblyProduct("ST_c41ad4bf47544c49ad46f4440163feae.csproj")]
[assembly: AssemblyCopyright("Copyright # Varigence 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.*")]
</File>
<File Path="ScriptMain.cs">
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
// if SSIS2012, use the following line:
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
// if earlier version, use the next line instead of the above line:
// [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
public void Main()
{
int i = 0;
MessageBox.Show(string.Format("{0}:{1}", Dts.Variables[i].Name, Dts.Variables[i].Value));
i++;
MessageBox.Show(string.Format("{0}:{1}", Dts.Variables[i].Name, Dts.Variables[i].Value));
Dts.TaskResult = (int)ScriptResults.Success;
}
}
</File>
</Files>
</ScriptTaskProject>
</ScriptTaskProject>
</Script>
<ExecuteProcess Executable="cmd.exe" Name="EP Do nothing" Arguments="/C">
</ExecuteProcess>
</Tasks>
</ForLoop>
</Tasks>
</Package>
</Packages>
</Biml>
Root cause guess
Variables can be created at different scopes within a package. I would presume that since a variable is created with the default name of Variable two, or more, such variables exist with the same name but at different application scopes. Thus, if I had defined a second SSIS variable named Variable on my ForLoop Container, it would start with a value of 0, unless defined otherwise. My package execution would begin, assign the value of 4 to my package level Variable. Control switches to my ForLoop Container. The Variable defined there wins from a scoping perspective so my value there is 0, not 4 because nothing has initialized it. In that case, the ForLoop would never fire as the terminal condition has already been met. For your case, I further presume that someone initialized that variable to 1.
Notice the Scope here, this is what I believe to be your root cause.
Solution:
DO NOT name SSIS variables #Variable. Doing so will unintentionally cause the variable value to pick up exit codes of other processes in the package as they run.
In my case the #Variable value would automatically change to 0 after a successfully run Execute Process Task with exit code 0; or change to -1073741510 when that process run failed.
H,
I need to get a user input during installation then use it as an argument for an application which is executed in the processPanle. How can I get the variable which contains the user input in the processPanel?
You can reference the variable using ${} syntax like shown in the following example.
userInputSpec.xml (snippet):
<field type="rule" variable="tomcat_http_port">
<spec txt="HTTP-Port:" id="panel0.field2.label" set="0:80" layout="N:5:5" />
</field>
process.xml (snippet):
<job name="Launching Browser">
<executeclass name="edu.ccdb.util.BareBonesBrowserLauncher">
<arg>http://localhost:${tomcat_http_port}/klaros-web</arg>
</executeclass>
</job>