Creating Dynamic XML request body in Jmeter - jmeter

I am new to Jmeter and need some help with creating a dynamic Soap message.I am trying to post the below XML body as HTTP request in Jmeter -
<soap:Envelope xmlns:soap="http://XXXXXsoap-envelope" xmlns:tem="http://XXXXX/“>
<soap:Header/>
<soap:Body>
<tem:ProcessMessage>
<tem:message>
<![CDATA[
<LoyaltyMessages xmlns:xsi="http://www.w3.org/XXXX/XMLSchema-instance" xmlns:xsd="hXXXX/XMLSchema" XID="4" YYY="4186" ZZZ="998" PPP="1" LLLL="2" DateTime="2022-09-13T13:30:12" LLL="1">
<TransactionRequests>
<TransactionRequest Type="0">
<Request JJJ="0" SSS="1">
<Items>
<Item SeqID="1" ItemCode="1145677" DepCode="105" SaleType="0" QtyType="1" Qty="2" NetPrice="1400" NetAmount="2800"/>
<Item SeqID="2" ItemCode="1145677" DepCode="105" SaleType="0" QtyType="1" Qty="2" NetPrice="1400" NetAmount="2800"/>
</Items>
<Total TotalAmount="28.00" TotalNumberOfItems="2"/>
</Request>
</TransactionRequest>
</TransactionRequests>
</LoyaltyMessages>
]]>
</tem:message>
</tem:ProcessMessage>
</soap:Body>
</soap:Envelope>
I want to substitute the tags within Items field with a dynamic body that can have upto 50-100 items with incrementing SeqID so it looks like -
<Items>
<Item SeqID="1" ItemCode="${ItemCode}" DepCode="${DepCode}" SaleType="${SaleType}" QtyType="${QtyType}" Qty="${Qty}" NetPrice="${NetPrice}" NetAmount="${NetAmount}"/>
<Item SeqID="2" ItemCode="${ItemCode}" DepCode="${DepCode}" SaleType="${SaleType}" QtyType="${QtyType}" Qty="${Qty}" NetPrice="${NetPrice}" NetAmount="${NetAmount}"/>
<Item SeqID="3" ItemCode="${ItemCode}" DepCode="${DepCode}" SaleType="${SaleType}" QtyType="${QtyType}" Qty="${Qty}" NetPrice="${NetPrice}" NetAmount="${NetAmount}"/>
</Items>
I am using a CSV dataset config but it adds the same values for all item list as it is the same request. Also not sure how to achieve multiple tag blocks inside Items tag.

You can generate dynamic block of Items using JSR223 PreProcessor and the Groovy code like:
Change your request body to:
<soap:Envelope xmlns:soap="http://XXXXXsoap-envelope" xmlns:tem="http://XXXXX/">
<soap:Header/>
<soap:Body>
<tem:ProcessMessage>
<tem:message>
<![CDATA[
<LoyaltyMessages xmlns:xsi="http://www.w3.org/XXXX/XMLSchema-instance" xmlns:xsd="hXXXX/XMLSchema" XID="4" YYY="4186" ZZZ="998" PPP="1" LLLL="2" DateTime="2022-09-13T13:30:12" LLL="1">
<TransactionRequests>
<TransactionRequest Type="0">
<Request JJJ="0" SSS="1">
<Items>
${items}
</Items>
<Total TotalAmount="28.00" TotalNumberOfItems="${numberOfItems}"/>
</Request>
</TransactionRequest>
</TransactionRequests>
</LoyaltyMessages>
]]>
</tem:message>
</tem:ProcessMessage>
</soap:Body>
</soap:Envelope>
Add JSR223 PreProcessor as a child of the HTTP Request sampler and put the following code into "Script" area
def numberOfItems = 10
def items = new StringBuilder()
1.upto(numberOfItems, { index ->
items.append('<Item SeqID="')
.append(index)
.append('" ItemCode="')
.append(vars.get('ItemCode'))
.append('"')
.append('"')
.append(' DepCode="')
.append(vars.get('DepCode'))
.append('" SaleType="')
.append(vars.get('SaleType'))
.append('" QtyType="')
.append(vars.get('QtyType'))
.append(" Qty=")
.append(vars.get('Qty'))
.append('" NetPrice="')
.append(vars.get('NetPrice'))
.append('" NetAmount="')
.append(vars.get('NetAmount'))
.append('"/>')
.append(System.getProperty('line.separator'))
})
vars.put('items', items.toString())
vars.put('numberOfItems', numberOfItems as String)

Related

Internal server error with UpdateItem EWS call from Outlook Addin

My goal is to update the subject of an Emailmessage using makeewsrequestasync.
At first I issue a GetItem request to get the latest ChangeKey of the message i want to update. This request works fine and i succesfully get the item ChangeKey.
After that I send another request to finally update my Email subject. However, i always get an internal server error with error code 500. Below is the request i send in the data object of the makeewsrequestasync method.
<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap = 'https://schemas.xmlsoap.org/soap/envelope/'> xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types'> <soap:Header> <t:RequestServerVersion Version='Exchange2013'/> </soap:Header> <soap:Body> <UpdateItem MessageDisposition='SaveOnly' ConflictResolution='AutoResolve' xmlns='http://schemas.microsoft.com/exchange/services/2006/messages'> <ItemChanges> <t:ItemChange> <t:ItemId Id='AAMkAGNkZWM1OTUzLTVhMzAtNDQyZS1hYzNmLTFhNDQ5ODc4NTYwMABGAAAAAABB8zSmRPuuRoRPHF1NS2srBwA9GscujNfkQL9s6uP7T+MpAAAAAAEMAADOgKz/bqQyTqxlZnzyc9ndAAH8Uu4tAAA=' ChangeKey='CQAAABYAAADOgKz/bqQyTqxlZnzyc9ndAAILRklX'/> <t:Updates> <t:SetItemField> <t:FieldURI FieldURI='item:Subject'/> <t:Message> <t:Subject>[Venga] MyAnalytics | Network Edition</t:Subject> </t:Message> </t:SetItemField > </t:Updates> </t:ItemChange> </ItemChanges> </UpdateItem> </soap:Body></soap:Envelope>
I already tried several ways to Update my subject, but unfortunetaly without success.
There is a similar question which i used to build my request
(similar Question), but I always end up in the Internal Server Error. I would love to get an advice, how to resolve this issue.
There are multiple issues with your XML request (it's not even valid XML)
<soap:Envelope xmlns:soap = 'https://schemas.xmlsoap.org/soap/envelope/'>
The namespace schema is wrong you have modified the correct schema to https note this has nothing to do with using http or https is just the schema definition and by changing it you have made it invalid. You have also added an extra > at the end which closes the tag but you have extra namespace attributes that should be included in the namespace which just become invalid text at that point in your request eg it should be
<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types'>
You also have extra whitespace in the closing SetItemField tag. This appears to be valid now
<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope
xmlns:soap = 'http://schemas.xmlsoap.org/soap/envelope/'
xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types'>
<soap:Header>
<t:RequestServerVersion Version='Exchange2013'/>
</soap:Header>
<soap:Body>
<UpdateItem MessageDisposition='SaveOnly' ConflictResolution='AutoResolve'
xmlns='http://schemas.microsoft.com/exchange/services/2006/messages'>
<ItemChanges>
<t:ItemChange>
<t:ItemId Id='AAMkAGNkZWM1OTUzLTVhMzAtNDQyZS1hYzNmLTFhNDQ5ODc4NTYwMABGAAAAAABB8zSmRPuuRoRPHF1NS2srBwA9GscujNfkQL9s6uP7T+MpAAAAAAEMAADOgKz/bqQyTqxlZnzyc9ndAAH8Uu4tAAA=' ChangeKey='CQAAABYAAADOgKz/bqQyTqxlZnzyc9ndAAILRklX'/>
<t:Updates>
<t:SetItemField>
<t:FieldURI FieldURI='item:Subject'/>
<t:Message>
<t:Subject>[Venga] MyAnalytics | Network Edition</t:Subject>
</t:Message>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</ItemChanges>
</UpdateItem>
</soap:Body>
</soap:Envelope>

How to set programatically a selector to a checkbox

I need to set a selector to checkboxes that are created programatically, this way:
var cbAll = new CheckBox(Activity);
LinearLayout.LayoutParams llAll = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
cbAll.Text = "All zones";
llAll.LeftMargin = 27;
llAll.TopMargin = 24;
cbAll.ButtonDrawable = //what to put here?
My selector (named cb_edit.xml) in drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/cb_active" android:state_checked="true" />
<item android:drawable="#drawable/cb_default" android:state_checked="false"/>
</selector>
i don't know what exactly you trying.but if u setting background then try this
cbAll.SetBackgroundResource( Resource.Drawable.cb_edit);
First, add an XML into your drawable folder:
CheckBoxDrawable.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="#drawable/CheckedImage" />
<item android:state_checked="false" android:drawable="#drawable/UnCheckedImage" />
</selector>
Then declare the checkbox and set the button drawable to it something like this:
Checkbox btnOption = new Checkbox(context);
btnOption.SetButtonDrawable(Resource.Drawable.CheckBoxDrawable);
That should make it work in case it does not revert

EWS FindItem call returns incorrect EffectiveRights values

I'm using a FindItem call to get items (appointments) from Exchange Web Services (EWS). The properties which are fetched are the item Id and the EffectiveRights. The EffectiveRights property often does not contain the correct values. Sometimes, however, the values are correct (using the same code), but I don't know what causes this.
The Calendar folder I'm searching in is delegated with Author rights to the service user I authenticate with and it contains appointments of which this service user is the author of.
I'm using the ews-java-api library and the response traces show that this isn't a parsing bug.
The code used to retrieve the items:
ItemView view = new ItemView(100);
PropertySet propertySet = new PropertySet();
propertySet.add(ItemSchema.Id);
propertySet.add(ItemSchema.EffectiveRights);
view.setPropertySet(propertySet);
FolderId folderId = new FolderId(WellKnownFolderName.Calendar, Mailbox.getMailboxFromString(targetSmtpAddress));
FindItemsResults<Item> items = service.findItems(folderId, filter, view);
Item firstItem = items.getItems().get(0);
firstItem.getEffectiveRights(); // Returns NONE, READ. This is incorrect.
Item bindItem = Item.bind(service, firstItem.getId()); //
bindItem.getEffectiveRights(); // Returns NONE, READ, MODIFY, DELETE. This is correct.
The request trace:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2"></t:RequestServerVersion>
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:ItemId"></t:FieldURI>
<t:FieldURI FieldURI="item:EffectiveRights"></t:FieldURI>
</t:AdditionalProperties>
</m:ItemShape>
<m:IndexedPageItemView MaxEntriesReturned="1000" Offset="0" BasePoint="Beginning"></m:IndexedPageItemView>
<m:Restriction>
<t:And>
<t:IsEqualTo>
<t:ExtendedFieldURI PropertySetId="039b4d91-2f03-44da-887c-aad704243ba8" PropertyName="SyncId" PropertyType="String"></t:ExtendedFieldURI>
<t:FieldURIOrConstant>
<t:Constant Value="syncID:330"></t:Constant>
</t:FieldURIOrConstant>
</t:IsEqualTo>
<t:IsGreaterThanOrEqualTo>
<t:FieldURI FieldURI="calendar:Start"></t:FieldURI>
<t:FieldURIOrConstant>
<t:Constant Value="2015-01-28T13:53:38Z"></t:Constant>
</t:FieldURIOrConstant>
</t:IsGreaterThanOrEqualTo>
</t:And>
</m:Restriction>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="calendar">
<t:Mailbox>
<t:EmailAddress>TARGETUSER#SMTP.ADDRESS</t:EmailAddress>
</t:Mailbox>
</t:DistinguishedFolderId>
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
The trace of a 'faulty' response:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="224" MinorBuildNumber="2" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:FindItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:RootFolder IndexedPagingOffset="1000" TotalItemsInView="1868" IncludesLastItemInRange="false">
<t:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkAGVlZmVlY2JjLTcxOTItNDBkYi1hOTljLTkwZjQwZjE4MTU1NQBGAAAAAADZ8IosQv76QbxS0r8FeFzgBwB25IsPmJcKTaP6zvCUqaybAAAAoIe5AAB25IsPmJcKTaP6zvCUqaybAABcSsgnAAA=" ChangeKey="DwAAABYAAAB25IsPmJcKTaP6zvCUqaybAABcS6ER"/>
<t:EffectiveRights>
<t:CreateAssociated>false</t:CreateAssociated>
<t:CreateContents>false</t:CreateContents>
<t:CreateHierarchy>false</t:CreateHierarchy>
<t:Delete>false</t:Delete>
<t:Modify>false</t:Modify>
<t:Read>true</t:Read>
<t:ViewPrivateItems>false</t:ViewPrivateItems>
</t:EffectiveRights>
</t:CalendarItem>
<t:CalendarItem>
<t:ItemId Id="AAMkAGVlZmVlY2JjLTcxOTItNDBkYi1hOTljLTkwZjQwZjE4MTU1NQBGAAAAAADZ8IosQv76QbxS0r8FeFzgBwB25IsPmJcKTaP6zvCUqaybAAAAoIe5AAB25IsPmJcKTaP6zvCUqaybAABcSsglAAA=" ChangeKey="DwAAABYAAAB25IsPmJcKTaP6zvCUqaybAABcS6EN"/>
<t:EffectiveRights>
<t:CreateAssociated>false</t:CreateAssociated>
<t:CreateContents>false</t:CreateContents>
<t:CreateHierarchy>false</t:CreateHierarchy>
<t:Delete>false</t:Delete>
<t:Modify>false</t:Modify>
<t:Read>true</t:Read>
<t:ViewPrivateItems>false</t:ViewPrivateItems>
</t:EffectiveRights>
</t:CalendarItem>
<!-- MORE ITEMS HERE... -->
</t:Items>
</m:RootFolder>
</m:FindItemResponseMessage>
</m:ResponseMessages>
</m:FindItemResponse>
</s:Body>
</s:Envelope>
I already found this blog post which seems somewhat related, but nothing more than that.
FindItems loads values from the contents table of a folder, rather than from the items themselves. Many times, with computed properties like EffectiveRights, a simplistic approach is used to populate the table to give an approximation. It seems like that's what's happening here. The comment in your code mentions that the value is correct after you Bind to the item (which loads values from the item itself).

WSO2 ESB xpath problems

I want to use the following xpath
/Users/User/UserID
This does not work because the ESB adds a soap envelope and body around my xml, what is the correct xpath to use or how can I remove the soap envelope and body?
The xml is:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Users xmlns="http://ws.wso2.org/dataservice">
<User>
<UserID>a</UserID>
<Username>a</Username>
<Email>a</Email>
<Password>a</Password>
</User>
<User>
<UserID>a</UserID>
<Username>a</Username>
<Email>a</Email>
<Password>a</Password>
</User>
<User>
<UserID>a</UserID>
<Username>a</Username>
<Email>a</Email>
<Password>a</Password>
</User>
</Users>
</soapenv:Body>
</soapenv:Envelope>
EDIT:
This works when I try to log it outside of my iterate mediator
//*[local-name() = 'Users']/*[local-name() = 'User']/*[local-name() = 'UserID']
but when I try to log it inside the iterate mediator it returns nothing?
Got this working by using the following
<property xmlns:int="http://ws.wso2.org/dataservice" name="uri.var.ID" expression="$body/int:User/int:UserID/text()" scope="default" type="STRING"/>
To access your elements you should go through envelope and body.
Here is an example with switch mediator:
<switch xmlns:ns="http://org.apache.synapse/xsd"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:int="http://ws.wso2.org/dataservice"
source="boolean(/soap:Envelope/soap:Body/int:Users/int:User/int:UserID/text() = 'string_to_compare'">
<case regex="true">
....
</case>
<default/>
</switch>
UPD
corrected XPath expression
Try this:
<property name="yourParamName" expression="$body/Users/User/UserID" scope="default" type="STRING"/>
You can read more on the predefined Synapse XPath variables here.

YQL Losing HTML Element Attributes?

YQL Console Link
Query:
select * from html where url='http://www.cbs.com/shows/big_brother/video/' and xpath='//div[#id="cbs-video-metadata-wrapper"]/div[#class="cbs-video-share"]/a'
Returns:
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="1" yahoo:created="2011-07-09T23:14:02Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-time="146" proxy="DEFAULT"><![CDATA[http://www.cbs.com/shows/big_brother/video/]]></url>
<user-time>163</user-time>
<service-time>146</service-time>
<build-version>19262</build-version>
</diagnostics>
<results>
<a class="twitter-share-button" href="http://twitter.com/share"/>
</results>
</query>
Should Return Something Similar To:
<results>
</results>
If I back out the query one level, it totally strips out the element, which I could also use to get the data I need.
We have a new html parser that recognizes custom attributes now.
Add compat="html5" to trigger the new parser.
e.g.:
select * from html where url = "http://mydomain.com" and compat="html5"

Resources