I have a project to write a script that connects to a Web Service and retrieve information of selected records. Unfortunately there is no PowerShell support from the vendor. Their documents only provides .Net examples. The web service that I am trying to retrieve information is for HP Trim v7. Maybe some of you are familiar.
Here is the .Net example from vendor
Example – Title Word search
// Construct a request object
TrimRequest request = new TrimRequest();
// Construct a RecordStringSearchClause, with type
// TitleWord, and argument "reef"
RecordStringSearchClause clause = new RecordStringSearchClause();
clause.Type = RecordStringSearchClauseType.TitleWord;
clause.Arg = "reef";
// Construct a record search, and put our search clause in it
RecordSearch search = new RecordSearch();
search.Items = new RecordClause[] { clause };
// Put our search operation into our TrimRequest
request.Items = new Operation[] { search };
// Send it off. Whatever comes back will be in response
Engine engine = new Engine();
engine.Credentials = new System.Net.NetworkCredential(username, password);
TrimResponse response = engine.Execute(request);
And here is my PowerShell code
$url = "http://localhost/trimws/trim.asmx"
$Engine = New-WebServiceProxy -Uri $url -Class "proxy" -Namespace "Connection" -UseDefaultCredential
$RecordStringSearchClause = New-Object Connection.RecordStringSearchClause
$ClauseType = New-Object Connection.RecordStringSearchClauseType
$ClauseType.value__ = 4 ##Record Number
$RecordStringSearchClause.Type = $ClauseType
$RecordStringSearchClause.Arg = "39299763"
$RecordSearch = New-Object Connection.RecordSearch
$RecordClause = New-Object Connection.RecordClause ## doesn't work
$RecordSearch.Items = New-Object Connection.RecordClause { $RecordStringSearchClause } ## doesn't work
$RecordSearch.Items = $RecordStringSearchClause
$TrimRequest = New-Object Connection.TrimRequest
$TrimRequest.Items = $RecordSearch
$Engine.Execute($TrimRequest) ## returns nothing
Could any body help me to convert above .Net code into PowerShell script? (if technically possible)