Cannot convert “System.String” to Type “WebServiceProxy.ExternalID”
Working with an API, I believe I need to create a WebserviceProxy object and add the property "ExternalID" to it, but I can't seem to get the right code to do that.
This is the error I am getting...
Cannot convert argument "0", with value: "002374E4DBEC", for "LaunchClientApplication" to type "WebServiceProxy.ExternalId": "Cannot convert the "002374E4DBEC" value of type "System.String" to type "WebServiceProxy.ExternalId"."
At C:PowerShellScriptsCrawler.ps1:72 char:50
+ $guid = $OSSNBranchWS.LaunchClientApplication <<<< ($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
+ CategoryInfo : NotSpecified: (:) , MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
This is my code...
### Crawler
### SQL Login
$SQLUser = "USERNAME"
$SQLPassword = "PASSWORD"
$SQLServer = "SQLSERVERDB"
$SQLDBName = "SQLDB"
$SqlQuery = "select a.externalID as Acct_Number, d.externalId as Ext_Device_ID
from bm_account a inner join
bm_device d on a.accountId = d.accountId
where a.externalId='9999999999'
order by Acct_Number,Ext_Device_ID"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; User ID = $SQLUser; Password = $SQLPassword;"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$rowCount = $SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$FTCSTBExternalIDs = $DataSet.Tables[0]
$Domain = 'DM'
$UserName = 'USERNAME'
$Password = 'PASSWORD'
$UsernameDomain = $Domain+''+$UserName
$SecurePassword=ConvertTo-SecureString -String $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential $UsernameDomain,$SecurePassword
$OSSNBranchWS = New-WebServiceProxy -Uri "http://mediaroomserver/ossNotificationsWS/UI.asmx?wsdl" -Namespace WebServiceProxy -Credential $Credential
$applicationUri = "page:http://mediaroomserver.com/FTCPFApps/STBScrollingMessages/MediaroomPage.aspx"
ForEach ($FTCSTBExternalID in $FTCSTBExternalIDs)
{
$msg_time = Get-Date -UFormat "%Y-%m-%d %r"
$message = $msg_time+' - FTC Account Number: "'+$FTCSTBExternalID.Acct_Number+'", Device ID: "'+$FTCSTBExternalID.Ext_Device_ID+'"' | Out-File $log_file -Append
$guid = $OSSNBranchWS.LaunchClientApplication($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
}
It looks like I need to change "$FTCSTBExternalID" into the WebserviceProxy object and add the property "ExternalID" to it, and add "$FTCSTBExternalID.Ext_Device_ID" to it. But I cannot seem to get that right.
Any help would be greatly appreciated.
Thanks.
powershell powershell-v2.0
add a comment |
Working with an API, I believe I need to create a WebserviceProxy object and add the property "ExternalID" to it, but I can't seem to get the right code to do that.
This is the error I am getting...
Cannot convert argument "0", with value: "002374E4DBEC", for "LaunchClientApplication" to type "WebServiceProxy.ExternalId": "Cannot convert the "002374E4DBEC" value of type "System.String" to type "WebServiceProxy.ExternalId"."
At C:PowerShellScriptsCrawler.ps1:72 char:50
+ $guid = $OSSNBranchWS.LaunchClientApplication <<<< ($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
+ CategoryInfo : NotSpecified: (:) , MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
This is my code...
### Crawler
### SQL Login
$SQLUser = "USERNAME"
$SQLPassword = "PASSWORD"
$SQLServer = "SQLSERVERDB"
$SQLDBName = "SQLDB"
$SqlQuery = "select a.externalID as Acct_Number, d.externalId as Ext_Device_ID
from bm_account a inner join
bm_device d on a.accountId = d.accountId
where a.externalId='9999999999'
order by Acct_Number,Ext_Device_ID"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; User ID = $SQLUser; Password = $SQLPassword;"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$rowCount = $SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$FTCSTBExternalIDs = $DataSet.Tables[0]
$Domain = 'DM'
$UserName = 'USERNAME'
$Password = 'PASSWORD'
$UsernameDomain = $Domain+''+$UserName
$SecurePassword=ConvertTo-SecureString -String $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential $UsernameDomain,$SecurePassword
$OSSNBranchWS = New-WebServiceProxy -Uri "http://mediaroomserver/ossNotificationsWS/UI.asmx?wsdl" -Namespace WebServiceProxy -Credential $Credential
$applicationUri = "page:http://mediaroomserver.com/FTCPFApps/STBScrollingMessages/MediaroomPage.aspx"
ForEach ($FTCSTBExternalID in $FTCSTBExternalIDs)
{
$msg_time = Get-Date -UFormat "%Y-%m-%d %r"
$message = $msg_time+' - FTC Account Number: "'+$FTCSTBExternalID.Acct_Number+'", Device ID: "'+$FTCSTBExternalID.Ext_Device_ID+'"' | Out-File $log_file -Append
$guid = $OSSNBranchWS.LaunchClientApplication($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
}
It looks like I need to change "$FTCSTBExternalID" into the WebserviceProxy object and add the property "ExternalID" to it, and add "$FTCSTBExternalID.Ext_Device_ID" to it. But I cannot seem to get that right.
Any help would be greatly appreciated.
Thanks.
powershell powershell-v2.0
Looping through a DataTable can be awkward, but there are examples to be found, like here. Sometimes it is easier to convert the DataTable to a regular PowerShell object first. You can do this with something like$FTCSTBExternalIDs = $DataSet.Tables[0] | Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors
– Theo
Jan 18 at 14:40
I still get the same error.
– Jason Cannon
yesterday
Maybe I need to use the $OOSNBranchWS, since that is the WebServiceProxy object? If so, how?
– Jason Cannon
yesterday
add a comment |
Working with an API, I believe I need to create a WebserviceProxy object and add the property "ExternalID" to it, but I can't seem to get the right code to do that.
This is the error I am getting...
Cannot convert argument "0", with value: "002374E4DBEC", for "LaunchClientApplication" to type "WebServiceProxy.ExternalId": "Cannot convert the "002374E4DBEC" value of type "System.String" to type "WebServiceProxy.ExternalId"."
At C:PowerShellScriptsCrawler.ps1:72 char:50
+ $guid = $OSSNBranchWS.LaunchClientApplication <<<< ($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
+ CategoryInfo : NotSpecified: (:) , MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
This is my code...
### Crawler
### SQL Login
$SQLUser = "USERNAME"
$SQLPassword = "PASSWORD"
$SQLServer = "SQLSERVERDB"
$SQLDBName = "SQLDB"
$SqlQuery = "select a.externalID as Acct_Number, d.externalId as Ext_Device_ID
from bm_account a inner join
bm_device d on a.accountId = d.accountId
where a.externalId='9999999999'
order by Acct_Number,Ext_Device_ID"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; User ID = $SQLUser; Password = $SQLPassword;"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$rowCount = $SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$FTCSTBExternalIDs = $DataSet.Tables[0]
$Domain = 'DM'
$UserName = 'USERNAME'
$Password = 'PASSWORD'
$UsernameDomain = $Domain+''+$UserName
$SecurePassword=ConvertTo-SecureString -String $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential $UsernameDomain,$SecurePassword
$OSSNBranchWS = New-WebServiceProxy -Uri "http://mediaroomserver/ossNotificationsWS/UI.asmx?wsdl" -Namespace WebServiceProxy -Credential $Credential
$applicationUri = "page:http://mediaroomserver.com/FTCPFApps/STBScrollingMessages/MediaroomPage.aspx"
ForEach ($FTCSTBExternalID in $FTCSTBExternalIDs)
{
$msg_time = Get-Date -UFormat "%Y-%m-%d %r"
$message = $msg_time+' - FTC Account Number: "'+$FTCSTBExternalID.Acct_Number+'", Device ID: "'+$FTCSTBExternalID.Ext_Device_ID+'"' | Out-File $log_file -Append
$guid = $OSSNBranchWS.LaunchClientApplication($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
}
It looks like I need to change "$FTCSTBExternalID" into the WebserviceProxy object and add the property "ExternalID" to it, and add "$FTCSTBExternalID.Ext_Device_ID" to it. But I cannot seem to get that right.
Any help would be greatly appreciated.
Thanks.
powershell powershell-v2.0
Working with an API, I believe I need to create a WebserviceProxy object and add the property "ExternalID" to it, but I can't seem to get the right code to do that.
This is the error I am getting...
Cannot convert argument "0", with value: "002374E4DBEC", for "LaunchClientApplication" to type "WebServiceProxy.ExternalId": "Cannot convert the "002374E4DBEC" value of type "System.String" to type "WebServiceProxy.ExternalId"."
At C:PowerShellScriptsCrawler.ps1:72 char:50
+ $guid = $OSSNBranchWS.LaunchClientApplication <<<< ($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
+ CategoryInfo : NotSpecified: (:) , MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
This is my code...
### Crawler
### SQL Login
$SQLUser = "USERNAME"
$SQLPassword = "PASSWORD"
$SQLServer = "SQLSERVERDB"
$SQLDBName = "SQLDB"
$SqlQuery = "select a.externalID as Acct_Number, d.externalId as Ext_Device_ID
from bm_account a inner join
bm_device d on a.accountId = d.accountId
where a.externalId='9999999999'
order by Acct_Number,Ext_Device_ID"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; User ID = $SQLUser; Password = $SQLPassword;"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$rowCount = $SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$FTCSTBExternalIDs = $DataSet.Tables[0]
$Domain = 'DM'
$UserName = 'USERNAME'
$Password = 'PASSWORD'
$UsernameDomain = $Domain+''+$UserName
$SecurePassword=ConvertTo-SecureString -String $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential $UsernameDomain,$SecurePassword
$OSSNBranchWS = New-WebServiceProxy -Uri "http://mediaroomserver/ossNotificationsWS/UI.asmx?wsdl" -Namespace WebServiceProxy -Credential $Credential
$applicationUri = "page:http://mediaroomserver.com/FTCPFApps/STBScrollingMessages/MediaroomPage.aspx"
ForEach ($FTCSTBExternalID in $FTCSTBExternalIDs)
{
$msg_time = Get-Date -UFormat "%Y-%m-%d %r"
$message = $msg_time+' - FTC Account Number: "'+$FTCSTBExternalID.Acct_Number+'", Device ID: "'+$FTCSTBExternalID.Ext_Device_ID+'"' | Out-File $log_file -Append
$guid = $OSSNBranchWS.LaunchClientApplication($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
}
It looks like I need to change "$FTCSTBExternalID" into the WebserviceProxy object and add the property "ExternalID" to it, and add "$FTCSTBExternalID.Ext_Device_ID" to it. But I cannot seem to get that right.
Any help would be greatly appreciated.
Thanks.
powershell powershell-v2.0
powershell powershell-v2.0
asked Jan 18 at 13:56
Jason CannonJason Cannon
11
11
Looping through a DataTable can be awkward, but there are examples to be found, like here. Sometimes it is easier to convert the DataTable to a regular PowerShell object first. You can do this with something like$FTCSTBExternalIDs = $DataSet.Tables[0] | Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors
– Theo
Jan 18 at 14:40
I still get the same error.
– Jason Cannon
yesterday
Maybe I need to use the $OOSNBranchWS, since that is the WebServiceProxy object? If so, how?
– Jason Cannon
yesterday
add a comment |
Looping through a DataTable can be awkward, but there are examples to be found, like here. Sometimes it is easier to convert the DataTable to a regular PowerShell object first. You can do this with something like$FTCSTBExternalIDs = $DataSet.Tables[0] | Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors
– Theo
Jan 18 at 14:40
I still get the same error.
– Jason Cannon
yesterday
Maybe I need to use the $OOSNBranchWS, since that is the WebServiceProxy object? If so, how?
– Jason Cannon
yesterday
Looping through a DataTable can be awkward, but there are examples to be found, like here. Sometimes it is easier to convert the DataTable to a regular PowerShell object first. You can do this with something like
$FTCSTBExternalIDs = $DataSet.Tables[0] | Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors– Theo
Jan 18 at 14:40
Looping through a DataTable can be awkward, but there are examples to be found, like here. Sometimes it is easier to convert the DataTable to a regular PowerShell object first. You can do this with something like
$FTCSTBExternalIDs = $DataSet.Tables[0] | Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors– Theo
Jan 18 at 14:40
I still get the same error.
– Jason Cannon
yesterday
I still get the same error.
– Jason Cannon
yesterday
Maybe I need to use the $OOSNBranchWS, since that is the WebServiceProxy object? If so, how?
– Jason Cannon
yesterday
Maybe I need to use the $OOSNBranchWS, since that is the WebServiceProxy object? If so, how?
– Jason Cannon
yesterday
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54255490%2fcannot-convert-system-string-to-type-webserviceproxy-externalid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54255490%2fcannot-convert-system-string-to-type-webserviceproxy-externalid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Looping through a DataTable can be awkward, but there are examples to be found, like here. Sometimes it is easier to convert the DataTable to a regular PowerShell object first. You can do this with something like
$FTCSTBExternalIDs = $DataSet.Tables[0] | Select-Object * -ExcludeProperty ItemArray, Table, RowError, RowState, HasErrors– Theo
Jan 18 at 14:40
I still get the same error.
– Jason Cannon
yesterday
Maybe I need to use the $OOSNBranchWS, since that is the WebServiceProxy object? If so, how?
– Jason Cannon
yesterday