transferring values from request to response (soapUI mock service) - soap

I'm receiving a 15 digit user ID and wanna trim its last 3 digit then send back to request sender. Request sample is below :
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<lookupSubscriberInfo xmlns="http://testID.com/V1_0">
<callingParty>testParty</callingParty>
<subscriberRequestList>
<testId>888905425616681</opaqueId>
</subscriberRequestList>
</lookupSubscriberInfo>
</env:Body>
</env:Envelope>
I have read this
http://www.soapui.org/Service-Mocking/creating-dynamic-mockservices.html
but could not figure out..

I could not do it by XPATH on the other hand XmlSlurper has worked..
import groovy.util.XmlSlurper
def parsedContent = new XmlSlurper().parseText(mockRequest.requestContent)
context.MSISDN = parsedContent.Body.lookupSubscriberInfo.subscriberRequestList.opaqueId.toString().substring(3,15)
In order to use MSISDN value ou should use the following
${MSISDN}

Related

how i can reply to outlook email using python for the same sender by using below code?

I am trying to reply outlook email as we do manually it goes with previous conversations. But Below code is giving some error : Failed to send to the recipient address..I need to know how i can send it back to the person who sent me email..
import win32com.client, datetime
from datetime import timedelta
outlook =win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") # to trigger outlook application
inbox = outlook.GetDefaultFolder(6) # 6 is used for the index of the folder
messages = inbox.Items
message = messages.GetLast()# message is treated as each mail in for loop
for message in messages:
if message.Subject=="request": # based on the subject replying to email
#body_content = message.body
message.Reply()
message.Body = "shortly will be processed!!!"
message.Send()
The reply is a MailItem returned by reply(). So try this:
reply = message.Reply()
reply.Body = "shortly will be processed!!!"
reply.Send()
continuing to above answer
to reply all:
`rplyall=message.ReplyAll()`
to reflect previous conversations:
`rplyall.Body="your message here"+rplyall.Body()`
`rplyall.Send()`
Since MailItem.Body is a String and it is not callable. Reference document
I think the correct code in #Akhil 's answer is
rplyall.Body = "your message here" + rplyall.Body
rplyall.Send()

Rest Assured API testing - Pass a Json Object as parameter to a get request

REST Assured Testing -
How to use delete request to delete the Workspace from this url
http://in-kumaran2-1:8080/devops-workbench-web/rest/api/workspace/delete/{projectId}
given the request
given().when().delete(url,JSON body);
Where Sample Request JSON body is given below
{"name":"newworkspace","workspaceFlow":"Open
Sorce","versionControl":"SVN","featureManagement":"JIRA","defectManagement":"","buildAutomation":"Selenium","deploymentAutomation":"","buildRepository":"Nexus","codeQualityTools":"SonarQube","automatedTestingTools":"Selenium","environmentProvision":"Puppet","environmentConfiguration":"Puppet","projectId":{"id":"56cebe578850d51c6fe07684","name":"wbproject","description":"wbproject","processTemplate":"Agile","projectManager":"Anil","projectStartDate":1454284800000,"projectEndDate":1475193600000,"remarks":null,"accountId":{"id":"56cebe218850d51c6fe07683","accountName":"workbench","accountDescription":"workbench
account"}}}
projectID has another Object {"id": "56cebe578850d51c6fe07684" ....} How to pass this projectId in the delete Request
actually, i have passed json object like below:
Response res =given().
content(jo). //jo is the json object to pass with the url.
with().
contentType("application/json").
header("Content-Type", "application/json").
when().
post(settings.getApiUrl()); //this is the url, i use post method
and jo is something like this:
JsonObject jo = new JsonObject();
jo.addProperty("username", "abc");//key and value
jo.addProperty("password", "abc");//key and value
u may try something like this.i used here as header u may send it as param.
URL is: http://example.com/building
My Query Strings are :
globalDates:{"startMs":1473672973818,"endMs":1481448973817,"period":90}
limitTo:6
loadTvData:true
startFrom:0
userId:5834fb36981baacb6a876427
Way to pass Query String Parameters in GET url using Rest Assured like this :-
when() .parameter("globalDates","startMs","1474260058054","endMs","1482036058051","period","90")
.parameters("limitTo","6")
.parameters("loadTvData","true")
.parameters("startFrom","0")
.parameters("userId","5834fb36981baacb6a876427");

Netsuite - how to specify record_type for getall request

I want to get a list of all InventoryItems
According to this document:
https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/getAll.html
I'm forming the following request:
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:platformMsgs="urn:platform_2013_1.webservices.netsuite.com" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<passport>
<email>******</email>
<password>******</password>
<account>******</account>
</passport>
</env:Header>
<env:Body>
<platformMsgs:getAll>
<recordType>InventoryItem</recordType>
</platformMsgs:getAll>
</env:Body>
</env:Envelope>
But receiving response with the error:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2013_1.platform.webservices.netsuite.com">
<platformMsgs:nsId>WEBSERVICES_969904_100920131651936419141601801_cbf1690968b43</platformMsgs:nsId>
</platformMsgs:documentInfo>
</soapenv:Header>
<soapenv:Body>
<getAllResponse xmlns="urn:platform_2013_1.webservices.netsuite.com">
<platformCore:getAllResult xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com">
<platformCore:status isSuccess="false">
<platformCore:statusDetail type="ERROR">
<platformCore:code>GETALL_RCRD_TYPE_REQD</platformCore:code>
<platformCore:message>The getAll record type is required.</platformCore:message>
</platformCore:statusDetail>
</platformCore:status>
</platformCore:getAllResult>
</getAllResponse>
</soapenv:Body>
</soapenv:Envelope>
I've tried to request currencies, states - the response always the same
I've tried following variants:
<GetAllRecordType>inventoryItem</GetAllRecordType>
and
<recordType>inventoryItem</recordType>
and
<GetAllRecordType>currency</GetAllRecordType>
and
<recordType>currency</recordType>
with the same response:
<platformCore:message>The getAll record type is required.</platformCore:message>
According to https://webservices.netsuite.com/xsd/platform/v2013_2_0/coreTypes.xsd - I've specified correctly recordType (btw I've also tried without any success)
I'm using ruby and there is no complete library for ruby. The one that is exists doesn't contain almost all things I'm going to use.
Can someone help me what I'm doing wrong or may be someone have working example
getAll cannot be used for all record types. Here is what is supported via getAll:
budgetCategory
campaignAudience
campaignCategory
campaignChannel
campaignFamily
campaignOffer
campaignSearchEngine
campaignSubscription
campaignVertical
costCategory
currency
leadSource
salesTaxItem
state
supportCaseIssue
supportCaseOrigin
supportCasePriority
supportCaseStatus
supportCaseType
taxGroup
taxType
The most complete implementation of SuiteTalk in Ruby is the netsuite ruby gem.
It doesn't yet support ItemSearchAdvanced (note that unlike most NetSuite records there isn't a ItemSearchBasic). Also, note that there isn't a InventoryItemAdvancedSearch, NonInventoryItemAdvancedSearch, etc like you would expect. Take a look at the lists.accounting.xsd for more information in the schema browser.
Like someone else mentioned, there is no getAll call for item record types. The best (and possibly only) way to get all of the items in a NetSuite instance is do a paginate through a search and combine all of the results.
I've coded a quick hack to demonstrate what needs to be done in order to implement item searching in the NetSuite gem. I wouldn't use the referenced hack in production, but could you easily integrate item searching into the NetSuite gem using the info the above referenced hack.
Below is searching code that, when used in combination with the above hack, will get you all of the items in your NetSuite instance.
item_list = []
item_search = NetSuite::Records::InventoryItem.search(
criteria: {
basic: [
]
},
preferences: {
page_size: 100,
}
)
item_search.results_in_batches do |batch|
item_list += batch
end
(the above code will probably break if the search returns a NonInventoryItem or another item record that isn't a InventoryItem, but this should be enough to get you started)
I stumbled upon this question with the same issue as
<platformCore:message>The getAll record type is required.</platformCore:message>
Figured I would come post a snippet of what a proper soap envelope should look like for this request. As others have mentioned, this call only supports certain record types...but once you identify the record type you desire, the below code should help.
<soap:Envelope xmlns:platformFaults="urn:faults_2014_1.platform.webservices.netsuite.com" xmlns:platformMsgs="urn:messages_2014_1.platform.webservices.netsuite.com" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="urn:platform_2014_1.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<passport>
<email>test#example.com</email>
<password>*******</password>
<account>AccountNumber</account>
<role internalId="3"/>
</passport>
</soap:Header>
<soap:Body>
<platformMsgs:getAll xmlns="urn:messages_2014_1.platform.webservices.netsuite.com" xmlns:platformMsgs="urn:messages_2014_1.platform.webservices.netsuite.com">
<platformMsgs:record recordType="currency"/>
</platformMsgs:getAll>
</soap:Body>
</soap:Envelope>
Also we are using the node-soap module to communicate with this web service and here is what it looks like from that perspective as well.
soap.createClient(this.url, function (err, client) {
client.addSoapHeader({
passport: {
email: 'test#example.com',
password: 'pass',
account: 'Acct Number',
role: {
attributes: { internalId: 3 }
}
}
});
client.getAll({
"record": {
"attributes": {
"recordType": "currency"
}
}
}, callback);
});
});
Anyways I hope this helps others as it did stump me for awhile.
inventoryItem, not InventoryItem.
Also, what language are you using? If PHP, there is a PHPToolkit to help you out.
As Dave suggested, the request will be case-sensitive, so make sure the value you use matches exactly what the XSD says.
If you scroll down the XSD further, you will see the enumeration for GetAllRecordType instead of just RecordType. This does not have an entry for inventoryItem or anything similar, so Inventory Items are most likely not available in this type of request.
You may instead have to build an Item search with no filters to return all Inventory Items.
For anyone using PHP and specially this library you can specify the record type this way:
$getAllRequest = new GetAllRequest();
$getAllRequest->record = new GetAllRecord();
$getAllRequest->record->recordType = RecordType::currency;
$getAllResponse = $service->getAll($getAllRequest);
This for example returns list of all the existing currencies.
Maybe this link is helpful : http://tellsaqib.github.io/NSPHP-Doc/df/d09/class_get_all_record_type.html
GetAllRecordType Class don't have InventoryItem
Data Fields
const budgetCategory = "budgetCategory"
const campaignAudience = "campaignAudience"
const campaignCategory = "campaignCategory"
const campaignChannel = "campaignChannel"
const campaignFamily = "campaignFamily"
const campaignOffer = "campaignOffer"
const campaignSearchEngine = "campaignSearchEngine"
const campaignSubscription = "campaignSubscription"
const campaignVertical = "campaignVertical"
const costCategory = "costCategory"
const currency = "currency"
const leadSource = "leadSource"
const salesTaxItem = "salesTaxItem"
const state = "state"
const supportCaseIssue = "supportCaseIssue"
const supportCaseOrigin = "supportCaseOrigin"
const supportCasePriority = "supportCasePriority"
const supportCaseStatus = "supportCaseStatus"
const supportCaseType = "supportCaseType"
const taxGroup = "taxGroup"
const taxType = "taxType"

How do I extract the ACK from a webservice response in Mirth?

I have a destination which sends an HL7 v2 message to a WCF webservice. I've managed to get the message correctly to the webservice (after fixing various encoding problems) and I can confirm that the message is reaching the WCF endpoint correctly. However, after much hunting around in the forums and documentation, I am unable to correctly parse the ACK we receive back to indicate when an error has occurred.
The response coming back from the webservice looks like:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header/>
<s:Body>
<ProcessMessageResponse xmlns="http://www.bluewire-technologies.com/webservices">
<ProcessMessageResult>
MSH|^~\&|Epro|RGR|||||ACK||D||||||GBR|ASCII|
MSA|AE||Empty message|
ERR|^^^100|
</ProcessMessageResult>
</ProcessMessageResponse>
</s:Body>
</s:Envelope>
The response contains an ACK in the ProcessMessageResult element. How to I extract this ACK from the response and pass it as the output of the destination? Will Mirth automatically parse the ACK and determine that there was an error?
I had thought that I needed some kind of transformer on the destination (called 'SOAP') and use something along the lines of:
var xml = responseMap.get('SOAP').getMessage();
and then extract the ProcessMessageResponse element but responseMap.get('SOAP') returns null so that seems the wrong approach.
I've now solved part of this thanks to an answer on the Mirth forums.
To summarize, I use the following postprocessor to extract the ack and update the status:
var s = new Namespace('http://schemas.xmlsoap.org/soap/envelope/');
var bw = new Namespace('http://www.bluewire-technologies.com/webservices');
var response = new XML($r('SOAP').getMessage());
var ack = new XML(SerializerFactory.getHL7Serializer().toXML(response.s::Body.bw::ProcessMessageResponse.bw::ProcessMessageResult.toString()));
var ackCode = ack.MSA['MSA.1']['MSA.1.1'].toString();
if(ackCode == 'AE')
{
var errorMessage = ack.MSA['MSA.3']['MSA.3.1'].toString();
var messageController = com.mirth.connect.server.controllers.DefaultMessageObjectController.create();
var channelStatisticsController = com.mirth.connect.server.controllers.DefaultChannelStatisticsController.create();
messageObject.getContext().put("replace", "true"); // yuk - this is to make setError below work.
messageController.setError(messageObject, null, errorMessage, null, null);
channelStatisticsController.decrementSentCount(new java.lang.String(channelId));
}
Not pretty, but it works...

Groovy HTTPBuilder SOAP response not being parsed properly

I don't understand why XmlSlurper is apparently not working on the result.
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
def String WSDL_URL = ...
def http = new HTTPBuilder( WSDL_URL , ContentType.XML )
String soapEnvelope =
"""<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetTerritories xmlns="...">
<State>AZ</State>
<ZipCode>85203</ZipCode>
</GetTerritories>
</soap12:Body>
</soap12:Envelope>"""
http.request( POST, XML ) {
headers."Content-Type" = "application/soap+xml; charset=utf-8"
headers."Accept" = "application/soap+xml; charset=utf-8"
body = soapEnvelope
response.success = { resp, xml ->
println "XML was ${xml}"
println "Territories were ${xml.Territories}"
println "State were ${xml.Territories.State}"
println "City was ${xml.Territories.Territory.City}"
println "County was ${xml.Territories.Territory.County}"
}
response.failure = { resp, xml ->
xml
}
}
leads to
XML was <Territories><State>AZ</State><ZipCode>85203</ZipCode><Territory><City>Mesa</City><County>Maricopa</County>...</Territory></Territories>
Territories were
State were
City was
County was
UPDATE: Thanks to John Wagenleitner's insight, I did a little more digging.
When I add that assert, I see an issue:
assert "Territories" == xml.name()
| | |
| | Envelope
| <Territories><State>AZ</State><ZipCode>85203</ZipCode</Territories>
false
Changing the request parameters from POST, XML to POST, TEXT is revealing:
XML was <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetTerritoriesResponse xmlns="...">
<GetTerritoriesResult><Territories><State>AZ</State><ZipCode>85203</ZipCode><Territory><City>Mesa</City><County>Maricopa</County>...</Territory></Territories>
</GetTerritoriesResult>
</GetTerritoriesResponse>
</soap:Body>
</soap:Envelope>
...
So it looks like the XmlSlurper, when the variable is being printed out, is throwing away the SOAP stuff and evaluating the innermost node () while not actually navigating to that node. Is this expected behavior?
I have been unable to find a a more complete and modern SOAP call and parse using httpBuilder, so I assumed XML would be the right content type. But it looks like I'll just have to accept TEXT and parse the body myself, which seems lame. Is there a better way of handling SOAP responses with httpBuilder?
I would recommend printing the raw text of the response:
println "XML was ${resp.data.text}"
Assuming that the printed XML line is what you expect (though odd since there is no Envelope or Body nodes), then you should be able to remove Territories from your references to xml. When parsed with XmlSlurper the root node is the GPathResult.
assert "Territories" == xml.name()
println "State were ${xml.State.text()}"
println "City were ${xml.Territory.City.text()}"
println "County were ${xml.Territory.County.text()}"
Also, just wanted to point out that the SOAP 1.2 media type is "application/soap+xml".
UPDATE:
So it looks like the XmlSlurper, when the variable is being printed
out, is throwing away the SOAP stuff and evaluating the innermost node
() while not actually navigating to that node. Is this expected
behavior?
Yes, the toString() method for a GPathResult just prints all text nodes and not the actual elements or attributes. With HTTPBuilder you can print out the raw response text by using:
println resp.data.text
I have been unable to find a a more complete and modern SOAP call and
parse using httpBuilder, so I assumed XML would be the right content
type. But it looks like I'll just have to accept TEXT and parse the
body myself, which seems lame. Is there a better way of handling SOAP
responses with httpBuilder?
The ContentType.XML is fine, the issue is with how the SOAP response that your web service returns is formed. The web service is sending back the Territories results as an encoded string in the GetTerritoriesResult element and not as part of the actual XML response that HTTPBuilder automatically parses for you (this is not a problem with the way HTTPBuilder is handling it). Because the data you really want is in that encoded string you will need to parse the text node of the GetTerritoriesResult yourself.
response.success = { resp, xml ->
println "XML was ${resp.data.text}"
def territories = new XmlSlurper().parseText(
xml.Body.GetTerritoriesResponse.GetTerritoriesResult.text()
)
println "State were ${territories.State}"
println "City was ${territories.Territory.City}"
println "County was ${territories.Territory.County}"
}