Xpath for creating config file and sharepoint deployment - sharepoint-2010

I am new to sharepoint 2010 and am trying to update the config file to look like this
<applicationSettings>
<Name.Library.Settings>
<setting name="FromAddress" serializeAs="String">
<value>tasks#munder.com</value>
</setting>
</Name.Library.Settings>
</applicationSettings>
by deploying a feature with the following code
,new ModificationEntry(
"applicationSettings/Name.Library.Settings"
,"configuration/applicationSettings"
,"<Name.Library.Settings/>"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,true)
,new ModificationEntry(
"applicationSettings/Name.Library.Settingsname='IsSharepointDeployed']"
,"configuration/applicationSettings/Name.Library.Settings"
,"<setting name='IsSharepointDeployed' serializeAs='String' />"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,true)
When I do this I'm getting the following error "Error occurred in deployment step 'Activate Features': Expression must evaluate to a node-set."
I belive this is telling me that my xpath query is wrong. It is configuration/applicationSettings/Name.Library.Settings
Any ideas what may be wrong with it?

I don't know if this solves all of your problem but:
"applicationSettings/Name.Library.Settings[#name='IsSharepointDeployed']"
Might help.

Related

How to set boolean in xml-action script

I am trying to set a flag so I do something like this:
<set field="existingFound" value="false" type="Boolean"/>
but the following line prints "true" in the log:
<log message="storeProperty, existingFound (0): ${existingFound}"/>
What is the best way to set flags?
The set.#value attribute is interpreted as a Groovy String (GString) so any non-empty value will be interpreted as true. The set.#from attribute is interpreted as a Groovy expression, so simply using from="false" instead of value="false" will get the desired result.
To see the generated Groovy code from an XML actions block you can write code that will cause an error and then the script will be logged, or you can change the log4j.xml file to turn on "debug" level logging for the XmlActions class (the latest log4j.xml file in the GitHub repository has an example of this). Looking at the Groovy code generated from the XML elements is a good way to track down issues when what is happening just doesn't make sense.

Tsung Issue with Dyn_Variable

I am very new to ERLANG and TSung, I never worked in this areas, but I am very much keen to know the fundamentals and do distributed load test for my web application. I am in half the way to complete, but I have a big hurdle and not able to moving forward , please read below tsung.xml file and advise me where & what I am missing?
**===> tsung.xml (this file perfectly working without any errors)**
*<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel = "debug" dumptraffic="true" version="1.0">
<clients>
<client host="localhost" weight ="1" maxusers="40000" cpu = "1" >
<ip value = '127.000.000.111'/>
</client>
</clients>
<servers>
<server host="127.000.000.112" port="80" type="tcp"></server>
</servers>
<load duration="1" unit="minute">
<arrivalphase phase="1" duration="1" unit="minute">
<users arrivalrate="10" unit="second"></users>
</arrivalphase>
</load>
<sessions>
<session name="mySession" probability="100" type="ts_http">
<transaction name="trx">
<request>
<dyn_variable name="myId" re="<myId>(\.*)\</myId>"/> <-- Trying with RegExp option, not getting the value myId
<!--dyn_variable name="myId" xpath="//response/myId" /--> <-- Trying with xpath option, not getting the value myId
<!--dyn_variable name="myId" jsonpath="response.myId" /--> <-- Trying with jsonpath option, not getting the value myId
<http url='http://127.000.000.112/Create_Rec' method='POST' version='1.1' content_type='text/xml'/>
</request>
<request subst="true">
<http url='http://999.000.000.999/Get_Rec/myId=%%_myId%%' method='GET' version='1.1' content_type='application/xml'/>
</request>
</transaction>
</session>
</sessions>
</tsung>*
When I run this url (it is web service call) "http://_127.000.000.112/Create_Rec" in the web browser, I get the following similar response from Server (in the back ground it creates the record in database and generates new id i.e. myId). When I run above tsung.xml, the first request working perfectly fine as I expected.
===> response (browser response)
<response id="SomeWebService">
<status>
<statusCode>1</statusCode>
<statusMsg>SomeMessage</statusMsg>
<statusTime>2013-06-20 02:52:25</statusTime>
</status>
<myId>298346728934734987</myId>
</response>
What I am looking here, I need to grab the myId from first request and pass into second request myId=%%_myId%%, but it is never working and myId always empty string. I am beyond of dyn_variable since two days, no clue and proper examples/documentation on it. Please suggest me, what I am missing.
You will have to set up the subst="true" in your request for substitution to work. So, your request should change to..
<request subst="true">
If still it doesn't work then I would suggest you to see the tsung.dump file and check the response which you are getting from server

XPath for web.config applicationSettings webdeploy parameters.xml file is not correct

I use webdeploy to deploy my web site project with a parameters.xml file I have been using a for a while. So far the parameters I've added are all element attributes and it all works well. But I am trying to get the xpath right to update an applicationSettings element value (not attributes) and am failing, badly, to work out if its my poor xpath skills to blame or a misunderstanding of the way the parameters file works.
When I do a deployment the field is not updated, it compiles fine and no errors\warnings during deployment. I want to be able to set this to True or False.
So I have following parameters field
<parameter name="ShowExceptionCallStackOnErrorView" description="Display a call stack on the UI Error view - true for debug only." defaultValue="False" tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/abc.123.Properties.Settings/setting[#name='ShowExceptionCallStackOnErrorView']/value" />
</parameter>
trying to match to the following application settings section
<configuration>
<applicationSettings>
<abc.123.Properties.Settings>
<setting name="ShowExceptionCallStackOnErrorView" serializeAs="String">
<value>True</value>
Any help would be much appreciated!
It's not giving you an error because it is simply not finding a match to replace. You need to add /text() to the end of your match tag if you want it to replace the contents of the value tag. As follows...
<parameter name="ShowExceptionCallStackOnErrorView" description="Display a call stack on the UI Error view - true for debug only." defaultValue="False" tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/abc.123.Properties.Settings/setting[#name='ShowExceptionCallStackOnErrorView']/value/text()" />
</parameter>

Replacing sections in web.config using web deployment project

I am trying to replace the following section to blank section ..
<secureWebPages mode="RemoteOnly" encryptedUri="abc.co.uk" unencryptedUri="www.abc.co.uk" maintainPath="True" warningBypassMode="AlwaysBypass" bypassQueryParamName="BypassSecurityWarning" ignoreHandlers="WithStandardExtensions">
<files>
<add path="abc.aspx"/>
</files>
</secureWebPages>
But after executing it is giving me the following error
WDP00002: missing section secureWebPages/configuration.
Can any one plz help me in this regard
This error appears to mean the section you wish to replace, cannot be found in the web.config.
For example, my entry in my WDP read
authentication=authentication.config
However authentication could not be found in the root, as it is under system.web, so I changed it to
system.web/authentication=authentication.config
and this worked.
Note that while debugging this, I tried to replace the whole system.web element, and this did not appear to work either - I am not sure what caused this, but if you cannot replace system.web, I suggest you try a different element, and see if that works, such as connectionStrings
So this problem has popped up for me recently and until finding this I was at a loss.
So it seems that the web.config is made up of not only sections, but section groups as well.
Now system.serviceModel, system.web etc are service groups and as such cannot be replaced as a whole.
You can replace sections in the group by using "section group"/"section"=x.config
Hope this helps :)

How do I set the xmlns attribute when using XMLFile in Wix 3

I am adding elements to an XML file during installation using the XmlFile element:
<util:XmlFile Id="SetOracleDialectProperty"
Action="createElement"
ElementPath="//hibernate-configuration/session-factory"
Name="property"
Sequence="9"
File="[INSTALLLOCATION]Config\hibernate.config"
Value="NHibernate.Dialect.Oracle10gDialect"/>
The empty file I am writing to looks like this:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
</session-factory>
</hibernate-configuration>
After running the installer I end up with this:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property xmlns="">NHibernate.Dialect.Oracle10gDialect</property>
</session-factory>
</hibernate-configuration>
The problem is that the empty xmlns attribute is overriding the xmlns specified in the root node of the file so the property element is not recognised correctly by nhibernate.
How can I either set the value to match the root node or remove the xmlns attribute?
I have spent some time searching for an answer and the closest I've found is "do what you would do in MSXML" which doesn't help me as it doesn't say how to do it in WiX (e.g. what attribute on XmlFile to use).
EDIT
To explain Rob's answer slightly, in a place where I can use nice formatting:
You add a document fragment by setting Node="document" on the XmlConfig element.
You have to explicitly set the namespace otherwise you get the default one again.
Also although you're adding a "document" it doesn't seem to work if you specify more than one element. You get a mysterious and thoroughly unhelpful "Setup wizard ended prematurely" runtime error.
So my fixed code looks like this:
<util:XmlConfig Id="MsSqlDialect"
Action="create"
ElementPath="//hibernate-configuration/session-factory"
File="[INSTALLLOCATION]Config\hibernate.config"
Node="document">
<![CDATA[
<property xmlns="urn:nhibernate-configuration-2.2" name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
]]>
</util:XmlConfig>
I know this is years later but if anyone else comes across this I think the true solution is this:
<util:XmlFile Id="SetOracleDialectProperty"
Action="createElement"
ElementPath="//hibernate-configuration/session-factory"
Name="urn:nhibernate-configuration-2.2:property"
Sequence="9"
File="[INSTALLLOCATION]Config\hibernate.config"
Value="NHibernate.Dialect.Oracle10gDialect"/>
change is from Name="property" to Name="urn:nhibernate-configuration-2.2:property" - when config is written it will apprear as just as it will recognize it is the default namespace. I had the same problem adjusting manifest files and this approach sorted it.
The problem here is that MSXML states that createElement will always give you the default namespace (just as you are seeing). I think you'll need to switch to the more complex but more powerful XmlConfig. In this case, try using a document fragment to add the entire element with correct namespace instead of depending on MSXML to create it for you.