Powershell 通过 WSDL SOAP 连接创建条目时出错

Powershell Error creating entry through WSDL SOAP connection

因此,在 PowerShell 中通过 WSDL SOAP 提交内容时出现转换错误。 我正在尝试在名为 Kablink 的系统中创建条目,但是尽管该条目具有变量 $soapData 中的所有值等,但当我尝试实际创建时,我收到一条错误消息,提示无法将参数条目从一个值转换为另一个值,即使两者都是指定值相同。

    Cannot convert argument "entry", with value: "folder_addEntry.FolderEntry", for "folder_addEntry" to type "folder_addEntry.FolderEntry": "Cannot convert the "folder_addEntry.FolderEntry" value of type
    "folder_addEntry.FolderEntry" to type "folder_addEntry.FolderEntry"."

任何想法都将不胜感激,因为这让我发疯了。

下面是我正在使用的脚本

    $kablinkSoapUrl  = "http://servername/ssr/secure/ws/TeamingServiceV1?wsdl"
    $kablinkConnector = New-WebServiceProxy -Uri $kablinkSoapUrl -Credential $Credential -namespace "folder_addEntry"
    #Set Binder ID to Shift Rota entries folder
    $binderID = 155
    #write-host $soapData


    #Import Objects and Populate Default Values
    $soapDescription = New-Object ("folder_addEntry.Description")
    $soapDescription.text = "Some Description"
    $soapDescription.format = 0
    $soapAttachment = New-Object("folder_addEntry.attachmentsField")
    $soapAttachment.name = ""
    $soapAttachment.type = ""
    $soapAttachment.attachments = @()
    $soapCreate = New-Object ("folder_addEntry.Timestamp")
    $soapCreate.date = get-date
    $soapCreate.principal = ""
    $soapCreate.principalId = 2
    $soapModify = New-Object ("folder_addEntry.Timestamp")
    $soapModify.date = get-date
    $soapModify.principal = ""
    $soapModify.principalId = 2
    $soapRating = New-Object ("folder_addEntry.AverageRating")
    $soapRating.averageRating = ""
    $soapRating.ratingCount = ""
    $soapCustBool = New-Object ("folder_addEntry.CustomBooleanField")
    $soapCustBool = @()
    $soapCustDate = New-Object ("folder_addEntry.CustomDateField")
    $soapCustDate = @()
    $soapCustEven = New-Object ("folder_addEntry.CustomEventField")
    $soapCustEven = @()
    $soapCustLong = New-Object ("folder_addEntry.CustomLongArrayField")
    $soapCustLong = @()
    $soapCustStriArr = New-Object ("folder_addEntry.CustomStringArrayField")
    $soapCustStriArr = @()
    $soapCustStr = New-Object ("folder_addEntry.CustomStringField")
    $soapCustStr = @()

    #Construct Entry

    $soapData = New-Object -TypeName folder_addEntry.FolderEntry
    $soapData.attachmentsField = $soapAttachment
    $soapData.averageRating = $soapRating
    $soapData.creation = $soapCreate
    $soapData.customBooleanFields = $soapCustBool
    $soapData.customDateFields = $soapCustDate
    $soapData.customEventFields = $soapCustEven
    $soapData.customLongArrayFields = $soapCustLong
    $soapData.customStringArrayFields = $soapCustStriArr
    $soapData.customStringFields = $soapCustStr
    $soapData.definitionId = "8a8ab38c62d40d5c0162fc8330eb01ad"
    $soapData.description = $soapDescription
    $soapData.entityType = "fileEntry"
    $soapData.eventAsIcalString = 0
    $soapData.family = "file"
    $soapData.id = ""
    $soapData.modification = $soapModify
    $soapData.parentBinderId = 155
    $soapData.permaLink = ""
    $soapData.title = "PowerShell Entry"
    $soapData.docLevel = 1
    $soapData.docNumber = ""
    $soapData.href = ""
    $soapData.preDeleted = 0
    $soapData.preDeletedBy = ""
    $soapData.preDeletedWhen = ""
    $soapData.reservedBy = ""
    $soapData.workflows = @()

    # Print Soap Data
    $soapData
    # Submit Entry
    $kablinkConnector.folder_addEntry("",$soapData,"")

提前致谢。

在创建 $kablinkConnector 变量时添加了 -class "folder_getEntry" 使行

    $kablinkConnector = New-WebServiceProxy -Uri $kablinkSoapUrl -Credential $Credential -namespace "folder_addEntry" -class "folder_getEntry"

现在可以使用了