Can someone explain me what is happening in this code step by step ? why we are setting x-dp-response-code value = -1 and what it returns ?
<xsl:variable name="responsecode" select="normalize-space(dp:response-header('x-dp-response-code'))"/>
<dp:set-variable name="'var://context/service/responsecode'" value="$responsecode"/>
<dp:set-response-header name="'x-dp-response-code'" value="'-1'"/>
I assume value="$responsecode"/> should be value="{$responsecode}"/>
For info on <dp:set-response-header name="'x-dp-response-code'" value="'-1'"/> see the these docs of ibm.
The x-dp-response-code special code is a protocol response code. This
special code is not a response header, but contains the
protocol-specific response code.
Related
I am trying to make a bad words system for my server's custom bot, but it seems to only
listen for the first condition, ignoring the second one:
#bot.event
async def on_message(message):
###BAD WORDS CHECK
if message.author == bot.user:
pass
else:
if (any(x in message.content.lower() for x in words2)):
if "hack" or "crack" in message.content.lower():
await message.reply("I think you may be asking for illegal services or illegal advice. Please refer to rule #5 in the welcome channel!")
await message.channel.send("If you think this was a mistake please reply with $report!")
global CAN_REPORT
CAN_REPORT = "yes"
return
else:
pass
await bot.process_commands(message)
The bot will for some reason respond to any message containing any word from words2:
words2 = [
"instagram",
"snapchat",
"roblox",
"paypal",
"facebook",
"gmail",
"fortnite",
"minecraft",
"apex",
"youtube",
]
ignoring whether the message contains "hack", which leads to it replying to every message talking about social media or games. The goal is to check if BOTH conditions are true.
Any help is appreciated!
With this line if "hack" or "crack" in message.content.lower(): you are basically checking if either the string "hack" is true or if "crack" in message.content.lower() is true.
Thus the check always returns true, because "hack" will always be true.
The way to fix this would be something like this:
if "hack" in message.content.lower() or "crack" in message.content.lower():
Or, better yet, do it like you do in the first check:
word_list = ["hack", "crack"]
if any(x in message.content.lower() for x in word_list):
Its simple just add :
if words2 in message.content.lower():
await message.delete()
await ctx.send('that word is banned')
From the below response, I need to retrieve all the values of backgroundImage field(which can be found in Debug Sampler) and by using the ForEach Controller I need to call the values fetched from backgroundImage field and pass it in the path of the next request.
I used Regular exp Extract with code "backgroundImage":"(.*?)" to extract all the non-values, but sometimes it returns empty values and in this case, it fetches just an empty "" (double code) and passes in the path of the URL which leads to an error.
How can I avoid null and empty values in this scenario?
Response:
{"data":[{"id":5031,"createdAt":1582657779000,"updatedAt":null,"contentType":"TEXT","author":{"id":32,"teamName":"Team Content","teamShirtNumber":null,"role":"TEAM_LEAD","firstName":"Team Lead Jeremiah","lastName":"Dominguez Gorrin","profilePictureReference":"aca511ec-c552-4bce-90ce-d993684c5854"},"text":"Teeeeest"},{"id":5030,"createdAt":1582657696000,"updatedAt":null,"contentType":"TEXT","author":{"id":32,"teamName":"Team Content","teamShirtNumber":null,"role":"TEAM_LEAD","firstName":"Team Lead Jeremiah","lastName":"Dominguez Gorrin","profilePictureReference":"aca511ec-c552-4bce-90ce-d993684c5854"},"text":"Sassafras"},{"id":5029,"createdAt":1582657466000,"updatedAt":null,"contentType":"TEXT","author":{"id":32,"teamName":"Team Content","teamShirtNumber":null,"role":"TEAM_LEAD","firstName":"Team Lead Jeremiah","lastName":"Dominguez Gorrin","profilePictureReference":"aca511ec-c552-4bce-90ce-d993684c5854"},"text":"Lkdsasdad"},{"id":5028,"createdAt":1582657243000,"updatedAt":null,"contentType":"POLL","author":{"id":32,"teamName":"Team Content","teamShirtNumber":null,"role":"TEAM_LEAD","firstName":"Team Lead Jeremiah","lastName":"Dominguez Gorrin","profilePictureReference":"aca511ec-c552-4bce-90ce-d993684c5854"},"text":"Umfrage mit Bild Preview Upload","minValue":0.0,"maxValue":10.0,"minLabel":null,"maxLabel":null,"sliderIcon":null,"backgroundImage":"f426549f-b1e0-4d07-8786-685fcfa28835","result":{"attendances":0,"averageValue":null,"myAnswer":null},"votingEndAt":1585090800000},{"id":5027,"createdAt":1582657195000,"updatedAt":null,"contentType":"POLL","author":{"id":32,"teamName":"Team Content","teamShirtNumber":null,"role":"TEAM_LEAD","firstName":"Team Lead Jeremiah","lastName":"Dominguez Gorrin","profilePictureReference":"aca511ec-c552-4bce-90ce-d993684c5854"}
Thanks in Advance for your knowledgeable help!
How about this:
"backgroundImage":"([^"]+)"
It repeats non double quotes character at least one.
You can go for a filter operator like:
$.data[?(#.backgroundImage != null && #.backgroundImage != "")].backgroundImage
Demo:
More information: JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios
I am using REST-API for testing
I am stuck where I am checking the response with some specific string.
please refer below info
I got the response from a request is
{
"clusters":[
{
"id":10,
"name":"HP2",
"status":2,
"statusDisplay":"HParihar#4info.com",
"lastModifiedBy":"HParihar#4info.com",
"lastModifiedTime":"06/08/2017 23:42",
"sitesAppsCount":0
},
{
"id":799,
"name":"Regression_cluster_111_09",
"status":2,
"statusDisplay":"admin#4info.net",
"lastModifiedBy":"admin#4info.net",
"lastModifiedTime":"07/11/2017 08:19",
"sitesAppsCount":0
}
]}
and I wanted to match just
"name":"Regression_cluster_111_09",
"status":2,
"statusDisplay":"admin#4info.net",
"sitesAppsCount":0
right side values I'll be keeping as hard coded.
any guesses?
Since you are only checking those 4 parameters are in response or not.
Do no use regex for this.
Use jsonObject's find key/value feature.
Check whether the values to the keys are there.
If key/value is null, the parameter is not in response.
I got my answer
I used the following regex
"name":"Regression_cluster_111_09","status":2,"statusDisplay":"admin#4info.net","lastModifiedBy":"[a-z]+#[0-9a-z]+\.[a-z]+","lastModifiedTime":"[0-9]{2}\/[0-9]{2}\/[0-9]{4}\ [0-9]{2}:[0-9]{2}","sitesAppsCount":0
or I can simply use
"name":"Regression_cluster_111_09","status":2,"statusDisplay":"admin#4info.net",.+"sitesAppsCount":0
thank you all
I make a callout that response is like this:
<ns:return>
<ax2446:contract>
<ax2446:array>variable1</ax2446:array>
<ax2446:array>value1</ax2446:array>
</ax2446:contract>
<ax2446:contract>
<ax2446:array>variable2</ax2446:array>
<ax2446:array>value2</ax2446:array>
</ax2446:contract>
<ax2446:contract>
<ax2446:array>variable3</ax2446:array>
<ax2446:array>value3</ax2446:array>
</ax2446:contract>
<ax2446:documents>
<ax2446:array>attachement1</ax2446:array>
<ax2446:array>D:\AUTO\filename-1.txt</ax2446:array>
</ax2446:documents>
<ax2446:documents>
<ax2446:array>attachment2</ax2446:array>
<ax2446:array>D:\AUTO\filename-2.txt</ax2446:array>
</ax2446:documents>
<ax2446:process>TEST_PROCESS</ax2446:modulo>
</ns:return>
i want to create a new payload with contracts values (the number can change)
<p:instantiateProcess xmlns:p="http://carbon.sample">
<xs:process xmlns:xs="http://carbon.sample">TEST_PROCESS</xs:process>
<ns:contract xmlns:ns="http://carbon.sample">
<xs:array xmlns:xs="http://carbon.sample">variable1</xs:array>
<xs:array xmlns:xs="http://carbon.sample">value1</xs:array>
</ns:contract>
<ns:contract xmlns:ns="http://carbon.sample">
<xs:array xmlns:xs="http://carbon.sample">variable2</xs:array>
<xs:array xmlns:xs="http://carbon.sample">value2</xs:array>
</ns:contract>
<ns:contract xmlns:ns="http://carbon.sample">
<xs:array xmlns:xs="http://carbon.sample">variable3</xs:array>
<xs:array xmlns:xs="http://carbon.sample">value3</xs:array>
</ns:contract>
</p:instantiateProcess>ยด
i get all the contract by:
<property
expression="//ns:return/ax2431:contract"
name="contract" scope="default" type="STRING"
xmlns:ax2431="http://vo.carbon.sample/xsd" xmlns:ns="http://carbon.sample"/>
I try with payloadfactory, by i dont know how to enrinch (if it is correct to use this mediator) the message to make a call to a new web service. or if i have to make the payload with an iterator...
can anybody help me? thanks
You appear to have a few options:
Use a Payload factory
Use XSLT
Use Script meditator
I suspect all 3 could get the result you are after. It is a question of which you feel most comfortable with. Personally, I would head down the Script mediator route, mapping between two XML payloads, here is an example: http://nimbleapi.com/2016/05/javascript-mapping-between-xml-payloads/
Once you get the contract list you can use iterate mediator to iterate the list and inside the iterator you can add payloadFactory mediator to create payload, then, same time you can send the modified payload to a new web service.
Please find the following links which explain in detail how you use iterate mediator.
http://sparkletechthoughts.blogspot.com/2012/08/how-to-use-iterator-mediator-to-iterate.html
In addition to XSLT or Script meditators, ForEach mediator is also an option.
https://docs.wso2.com/display/ESB490/ForEach+Mediator
I am hoping someone can help get me in the right direction...
I am using Powerbuilder 12 Classic and trying to consume a Oracle CRM OnDemand web service.
Using Msxml2.XMLHTTP.4.0 commands, I have been able to connect using https and retrieve the session id, which I need to send back when I invoke the method.
When I run the code below, I get the SBL-ODU-01007 The HTTP request did not contain a valid SOAPAction header error message. I am not sure what I am missing??
OleObject loo_xmlhttp
ls_get_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=login"
try
loo_xmlhttp = CREATE oleobject
loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP.4.0")
loo_xmlhttp.open ("GET",ls_get_url, false)
loo_xmlhttp.setRequestHeader("UserName", "xxxxxxx")
loo_xmlhttp.setRequestHeader("Password", "xxxxxxx")
loo_xmlhttp.send()
cookie = loo_xmlhttp.getResponseHeader("Set-Cookie")
sesId = mid(cookie, pos(cookie,"=", 1)+1, pos(cookie,";", 1)-(pos(cookie,"=", 1)+1))
ls_post_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration/Activity;"
ls_response_text = "jsessionid=" + sesId + ";"
ls_post_url = ls_post_url + ls_response_text
loo_xmlhttp.open ("POST",ls_post_url, false)
loo_xmlhttp.setRequestHeader("COOKIE", left(cookie,pos(cookie,";",1)-1) )
loo_xmlhttp.setRequestHeader("COOKIE", left(cookie,pos(cookie,";",1)-1) )
ls_post_url2 = "document/urn:crmondemand/ws/activity/10/2004:Activity_QueryPage"
loo_xmlhttp.setRequestHeader("SOAPAction", ls_post_url2)
loo_xmlhttp.send()
ls_get_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=logoff"
loo_xmlhttp.open ("POST",ls_get_url, false)
loo_xmlhttp.send()
catch (RuntimeError rte)
MessageBox("Error", "RuntimeError - " + rte.getMessage())
end try
I believe you are using incorrect URL for Login and Logoff;
Here is the sample:
https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=login
https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=logoff
Rest of the code looks OK to me.
I have run into similar issues in PB with msxml through ole. Adding this may help:
loo_xmlhttp.setRequestHeader("Content-Type", "text/xml")
you need to make sure that the your value for ls_post_url2 is one of the values that is found in the wsdl file. Just search for "soap:operation soapAction" in the wsdl file to see the valid values for SOAPAction.