Create complex-type variables for a Web Service Task - web-services

In SSIS, I already have a Web Service Task using a WSDL for sending SMS. I am indeed able to send SMS using this task.
I want supply values to this task from the database, such as Mobile Number, Message body, User ID, etc.
How can I create a complex type user variable that can be passed as input to a Web Service task?

It looks like the only answer is to change the web service to accept only simple types as parameters. I have scoured the web and there seems to be no way to dynamically create complex types for consumption by the input values in the web service task.

The more 'easy' way is to use the script component for bypassing variables to a web service. Check http://amolpandey.com/2016/09/26/ssis-script-task-to-obtain-geo-cordinates-from-address-text-via-google-api/ & http://www.sqlmusings.com/2011/03/25/geocode-locations-using-google-maps-v3-api-and-ssis/.
Tested and working. Using this task you can bypass the SSIS variables/parameters.
Example: Getting ID, addreess, zipcode, city, country from a table with an execute SQL Task. Change Resultset:Full result set on General tab. Then on resultset tab add Result_Name:0 & Variable_Name: User::YourObject. Then the next task will be a Forlooptask editor (Foreach ADO Enumerator ,Collection tab - Ado object source variable: User::YourObject, enumeration mode: rows in the first table, variable Mapping tab - Variable User::Id, 0 | address,1 etc.). Inside the Forlooptask editor you add a data flow task, which the source of this task will be a script component. If you be more specific about your logic,we may assist you more.

Okay so I came across the same problem. I needed to pass one parameter as complex type.
Create a Web Service task in your package.
Fill all the needed properties at General tab: HttpConnection and WSDFile
Fill properties in Input tab: Service, Method
Below click on Value, manually enter the value you need (mine is 2021-11-15)
Deploy and execute package to be sure everything is OK
After this easy steps go into folder where package is localated. Right click on package file (Package.dtsx) and select Open with > Notepad. With find function in notepad search the value you manually inserted.
The part which we are looking for looks in my case like this
<WSTask:ComplexValue>
<WSTask:ComplexProperty
WSTask:Name="date"
WSTask:Datatype="dateTime"
WSTask:ParamType="Primitive">
<WSTask:PrimitiveValue>2021-11-15</WSTask:PrimitiveValue>
</WSTask:ComplexProperty>
</WSTask:ComplexValue>
Finally I found what I was looking for. Now for the second part I needed to be that parameter changing by current date when I execute that package. In powershell I managed to write a code that change date part in string: <WSTask:PrimitiveValue>2021-11-15</WSTask:PrimitiveValue> to current date, everytime when the package is executed. The code looks like this:
$Now = Get-Date -Format "yyyy-MM-dd"
$Yesterday = (Get-Date).AddDays(-1).ToString("yyyy-MM-dd")
$file = ((Get-Content -path "C:\Package.dtsx" -Raw) -replace "<WSTask:PrimitiveValue>$Yesterday</WSTask:PrimitiveValue>", "<WSTask:PrimitiveValue>$Now</WSTask:PrimitiveValue>")
[System.IO.File]::WriteAllText("C:\Package.dtsx",$file)
# This part will execute the package #
dtexec.exe /f "C:\Package.dtsx"
After all this, I planned this script in Task Scheduler and it works.
In my case changing the type of request from complex to simple wasn't an option and all I needed was just one parameter to pass.
Hopes it gonna help somebody.

Related

Obtain folder name in test script

I'm writing API tests using Postman. I'm organizing them into folders by endpoint, and subfolders by test cases within the endpoint folders. There are multiple cases for each endpoint and for each case there are post calls that set up data prior the the csubject-endpoint call that I'm making assertions against.
I already have 100s of calls in this suite. The test runner, unfortunately, does not provide the folder names in its output, so it's difficult to see at a glance which particular case I am looking at when, for example, it reports a test fail.
Is there a convenient way to obtain the folder names for a given call in its test script? With this, I could prepend the case name to the test name, and that would make my tests vastly more readable.
I think a variable containing the current request path in the folder hierarchy would be the best, but for now I didn't find such a feature.
Instead I may suggest such a workaround solution:
In each folder prerequest scripts you set a variable:
pm.environment.set("folder", "folder1/folder1.1/")
the value of folder variable you have to maintain separately for each folder.
Then on a collection level you put a collection test like this:
pm.test("location: " + pm.environment.get("folder"), true)
After running your collection in the Runner you will get the output
from collection tests at the beginning of the test results for each request
showing the folder location.
The effort of setting folder variables pays off when you estimate the results of complex tests. I used to change the names of the requests but it is even more complicated.
UPDATE:
You can also find the info in results hovering over a gray shortcut of path on the left of the request status. A tooltip displays a full path, what in fact eliminates the need of the above solution if you only want to observe the results, but the solution can be useful if you want to make some logs containing the path.
I don't think that there is anything like that from within the application - The closet I can see is the pm.info.requestName function which references the request name that the test belongs too.
This is a basic use case but you could add this to the test name to give you a 'quick glance' and what was run against what request.
pm.test(`${pm.info.requestName} - Status code is 200`, () => {
pm.response.to.have.status(200)
})
If you take a look at Newman it might have something within the summary object that you could extract, in a script, to get the folder name but I've never done this.
Closest thing right now would be this:
I believe I included this in my logged bugs / feature requests out to their team.

Load testing with SOAP UI

I have a SOAP UI 4.5.1, I have made a load test, it is working fine. My problem is that I run the same request every time and I need to change the values of the soap request I am sending.
For e.g. I have a block of my soap request:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SHL</ns:ProviderId>
<ns:ProjectId>SampleAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
Provider ID: SHL
Project ID: SampleAssessment
Is there a way to make those values changing from some kind of interval?
For e.g.: Provider IDs [SHL, SLH, LHS]
Project IDs [SampleAssessment, TestAssessment, AnotherAssessment]
And with a load test I am making three request so that for the first request values looks like this:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SHL</ns:ProviderId>
<ns:ProjectId>SampleAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
for the second like this:
<ns:Assessment>
<ns:Project>
<ns:ProviderId>SLH</ns:ProviderId>
<ns:ProjectId>TestAssessment</ns:ProjectId>
</ns:Project>
</ns:Assessment>
and so on...
Is there a way to make this happen with SOAP UI?
From my experience, you will need to use a Groovy Script step.
For example, if you have a step before your request that is a script, you can use something like:
context.setProperty("ProviderId", "SHL")
Then in your request, use:
<ns:ProviderId>${ProviderId}</ns:ProviderId>
Of course, this doesn't buy you much by itself. There are few ways to vary what the context.setProperty("ProviderId", "SHL") line will set. You can create a collection and iterate over it using something like:
def providers = ['ABC', 'DEF', 'GHI', 'JKL']
providers.each() {
context.setProperty("ProviderId", it)
testRunner.runTestStepByName( "nameofteststep" )
}
Where "nameofteststep" is the name of the Soap Request test step. This might sound odd, but if you right click the test step and disable it, the groovy script will still be able to execute it but it will not run sequentially. By that I mean that the groovy script will run it 4 times, but it won't run a fifth time when the script is complete because it is after the script. Then you just need to keep in mind that each load test thread makes four requests, but I am pretty sure that the SoapUI statistics will take this into account for you... might want to keep an eye out for it, though.
Alternatively, you could check the 'threadIndex' and set a the context variable based on that. A bit like this here: Log ThreadCount.
You could also use a collection without a loop and increment an index that you save as a testcase property and send the string corresponding to the index.
Personally, I think the first way is the most straightforward but I can provide an example of the other ones if you like.
There is a simple way of doing this without writing a groovy script.
After creating a test case you should include the below test steps:
1-Data source
2-Request
3-Loop
Data source will read an excel file (or other data source methods such as XML, groovy, JDBC, gird .. however the excel is the simplest one).
You should include the datas (that you need to change within the request)
Within the test request you need the right click and select "get data" . please notice that your test request should be as below
<ns:ProviderId>${ProviderId}</ns:ProviderId>
Then the last step is the "Loop" . This for returning to the first step until the data ends.
I hope this helps.

retrieving 'pre windows 2000 logon' name from LDAPMessage object in win32api C++

I've been asked to look at windows service which retrieves data from an Active Directory tree using the win32 LDAP API and outputs JSON data to a text file. It works fine but I need to modify it so that the i get the 'pre windows 2000' login name. The service is written in c++.
The service already successfully retrieves various other attribute strings using:
PTSTR *pszValues=ldap_get_values(pLdap,pEntry,szAttribute);
and:
if (_tcscmp(szAttribute,TEXT("uUsnChanged"))==0) // uSNChanged is an example of an attribute
pItemInfo->uUsnChanged=_tcstoui64(pszValues[0],NULL,10); // pItemInfo is a struct defined elsewhere to hold the results for any given entry
i looked on http://msdn.microsoft.com/en-us/library/ms679021(v=VS.85).aspx to see if there is an attribute for 'pre windows 2000' login or something similar in the hope that I could just add this as another 'szAttribute' (to replace "uUsnChanged" in this example) and had no luck. Looking at the API i have been unable to come up with a way of getting this information.
i found the attribute 'sAMAccountName' which i thought would provide the information needed but it only gives me the name part of the DOMAIN/name format. Typical, it's the other part i want!
does anyone have any ideas on how to get the 'pre windows 2000' string from 'pEntry'?
#JPBlanc We are getting the correct nETBIOSName attribute now when running it on the test server. The app works on the assumption that there is a maximum of one nETBIOSName attribute per DC. It finds it by doing the following:
gets the default host using ldap_init(NULL,0)
get the 'configuration naming context' using ldap_search_s(pLdap,NULL,LDAP_SCOPE_BASE,NULL,pszAttrs,FALSE,&pResults); passing in the connection handle as the first parameter
retrieves the 'configurationNamingContext' attribute using ldap_get_values(pLdap,pEntry,TEXT("configurationNamingContext"));
concatenates "CN=Partitions," to the beggining of the string giving something like "CN=Partitions,CN=Configuration,DC=domain,DC=com,DC=au"
it then performs a search using ldap_search_s(pLdap,szPartitionNC,LDAP_SCOPE_SUBTREE,TEXT("(nETBIOSName=*)"),pszAttrs,FALSE,&pResults);
then it loops through the results looking for anything with a 'nETBIOSName' attribute and once it finds one it breaks out of the loop and returns the value.
Do you know if this is sufficient to work in any AD configuration?
Be careful, the Domain part of the 'pre windows 2000 domain' can be completly different from the user Principal Name (user#domain) use to logon onto Active-Directory. the DOMAIN is the Primary Domain Controleur name or the Netbios domain name. DOMAIN is created during domain creation, by default it's part of the DNS name, but it can be completly changed during domain creation.
You can find it with nETBIOSName attribute :
ldifde -f netbios.ldf -d "CN=Partitions,CN=Configuration,DC=your-DNS-Name" -r "(netbiosname=*)"
A best filter would be
(&(objectcategory=crossref)(dnsHostName=<DomainDNSName>)(netbiosname=*))
SAM-Account-Name Attribute (sAMAccountName)

Error inserting new record with Flex 4 via ColdFusion 9 with Apptacular extension

I have a little problem with using Flex 4 with Coldfusion 9. I hope you can tell me what I have to fix.
I use Coldfusion 9, hosted on my development machine.
I created a table in MySQL database with 2 columns: idPlayer as integer and auto increment. 2nd column is Name.
I use a ColdFusion Builder, Apptacular, to generate solid CFC service for me. It generates PlayerService.cfc here.
Now I use Flash Builder 4's data wizard to generate data service class from PlayerService.cfc. I create a form on update method of that service.
Ok, now look at the generated code.
// Please uncomment the below line if Data Management is enabled for Player and update is used as the create function.
// var player:Player = new Player();
So I uncommented the code and run the form. After fill the data, and click update, the pop up appear like this:
Unable to invoke CFC - Field 'idPlayer' doesn't have a default value
For details, turn on Robust Exception Information in the ColdFusion Administrator
So I don't know how Apptacular generate the code to work as ORM. But it should have some way or workaround to let the system act with idPlayer has no default value to insert other columns and generate idPlayer as auto-increment value (as I set in MySQL).
Could you help me solve this?
I don't know what your Player.cfc looks like (that's where the error is actually happening), but you'll need to set the generator attribute of the id property to let Hibernate know that the database is supposed to take care of that for you. You'll most likely have the exact same error if you tried to save the object via ColdFusion, so test your Service using CF first, and then move onto Flash so that you know if your issue is really with your Flex integration, or with your CF app.

Can I unit test Informatica Powercentre workflows?

Can I unit test Informatica Powercentre workflows?
EDIT:
More specifically, can I mock sources and target and test the steps in between? Eg. If I have a workflow with a Oracle source and a text file target can I test it without Oracle and a text file.?
No you can't.
When you create and save a mapping Informatica validates if the mapping is syntactically valid. It will give you an error message if it's not. Look for the errors in the bottom panel. You can validate a mapping by going to Mappings Menu > Validate.
You can validate a workflow similarly : Workflows Menu > Validate.
To run the workflow it is necessary that you have the source and target available and connected. If you don't want to write to target or don't want to do full volume testing you can use "Enable Test Load" at the Session level (Edit > Properties > Enable Test Load) and set "Number of rows to test".
Yes, you can run the work flow and test the output target table.
(From the work flow manager, right click on a work flow, and click "run work flow from start".
Once the work flow is successful, view the data in the target to see of the mappings and transformations are working fine.
Just like any other Unit testing, you'll need to identify the records in your source (and target) and the expected results in the target before you run your work flow.
Eg If I want to test a mapping which has the SCD type2 logic, you can run the work flow twice and update the source columns as needed and after running the work flow, check if the current record has been updated correctly and if the new row for a history version of the record has been updated correctly.
What we're trying to do in Informatica is build a source file, build an expected output file and then run a workflow to produce an actual output file. We then do a bytecode comparison of our expected output file versus our actual output file. What we're actually testing for here is whether or not our mapping logic is implemented as we believe it should be implemented.
The following python script will do the testing:
import filecmp
import csv
import sys
testRepository = open('testRepository.txt','rb')
testReader = csv.reader(testRepository)
print 'Test Number\tResult'
for test in testReader:
print test[0] + '\t\t' + str(filecmp.cmp(test[1], test[2]))
Not exactly mocking, but essentially will be what's necessary to correctly test that your mapping is correct. Validity of the mapping is checked my Informatica itself.