 |
 |

05-09-2011, 08:26 AM
|
|
Newcomer
|
|
Join Date: May 2011
Posts: 2
|
|
Value of type '1-dimensional array of String' cannot be converted to ArrayOfString
|
I have looked and googled every forum with no luck. I am using Express 10 environment and trying to call a webservice to upload documents. The last two parameters on InsertDocument function is of type BCOps.ArrayofString.
I have the following:
Code:
'Dim fieldnames As New List(Of String)
'fieldnames.Add("accountnumber")
'fieldnames.Add("filenetdocid")
'fieldnames.Add("filenetsystemid")
'fieldnames.Add("mimetype")
'fieldnames.Add("pagecount")
'fieldnames.Add("indexby")
'fieldnames.Add("indexdate")
'fieldnames.Add("captureby")
'fieldnames.Add("capturedate")
'fieldnames.Add("filetype")
'fieldnames.Add("doctype")
'fieldnames.Add("Account")
'fieldnames.Add("BABC Request ID")
'fieldnames.Add("BCR Num")
'fieldnames.Add("Display File Name")
'Dim fieldvalues As New List(Of String)
'fieldvalues.Add("")
'fieldvalues.Add("")
'fieldvalues.Add("")
'fieldvalues.Add("application/pdf")
'fieldvalues.Add("1")
'fieldvalues.Add("babc/system")
'fieldvalues.Add("")
'fieldvalues.Add("babc/system")
'fieldvalues.Add("")
'fieldvalues.Add("Loan Statements")
'fieldvalues.Add("Participation Settlement")
'fieldvalues.Add(Account)
'fieldvalues.Add(BABCRequestID)
'fieldvalues.Add(BCRNum)
'fieldvalues.Add(FileName)
Dim fieldnames() As String = {"accountnumber",
"filenetdocid",
"filenetsystemid",
"mimetype",
"pagecount",
"indexby",
"indexdate", "captureby",
"capturedate", "filetype", "doctype",
"Account", "BABC Request ID", "BCR Num", "Display File Name"}
Dim fieldvalues() As String = {"", "", "", "application/pdf", "1", "babc/system", "", "babc/system", "",
"Loan Statements", "Participation Settlement", Account, BABCRequestID, BCRNum, FileName}
Console.WriteLine("DEBUG: -----------------------------------------------------------------")
Dim fileDocId As Long = objClient.insertDocument(APP_NAME, APP_KEY, USER_NAME, ORG_ID, imgData, fieldnames, fieldvalues)
Console.WriteLine("DEBUG: -----------------------------------------------------------------")
I tried to do a Generic List and it still did not work. I went into the Advanced Properties of the Service Reference and changed collection type to Generic.List and still does not work. The Web Service Logic for insert document is as follows and I am hoping someone can help.
Code:
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
System.Runtime.Serialization.CollectionDataContractAttribute(Name:="ArrayOfString", [Namespace]:="http://tempuri.org/", ItemName:="string"), _
System.SerializableAttribute()> _
Public Class ArrayOfString
Inherits System.Collections.Generic.List(Of String)
End Class
Code:
Public Function insertDocument(ByVal appName As String, ByVal appKey As String, ByVal userName As String, ByVal orgID As Long, ByVal image() As Byte, ByVal fieldNames As BCOps.ArrayOfString, ByVal fieldValues As BCOps.ArrayOfString) As Long
Dim inValue As BCOps.insertDocumentRequest = New BCOps.insertDocumentRequest()
inValue.Body = New BCOps.insertDocumentRequestBody()
inValue.Body.appName = appName
inValue.Body.appKey = appKey
inValue.Body.userName = userName
inValue.Body.orgID = orgID
inValue.Body.image = image
inValue.Body.fieldNames = fieldNames
inValue.Body.fieldValues = fieldValues
Dim retVal As BCOps.insertDocumentResponse = CType(Me,BCOps.BCOpsSoap).insertDocument(inValue)
Return retVal.Body.insertDocumentResult
End Function
Code:
Partial Public Class insertDocumentRequestBody
<System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=false, Order:=0)> _
Public appName As String
<System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=false, Order:=1)> _
Public appKey As String
<System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=false, Order:=2)> _
Public userName As String
<System.Runtime.Serialization.DataMemberAttribute(Order:=3)> _
Public orgID As Long
<System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=false, Order:=4)> _
Public image() As Byte
<System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=False, Order:=5)> _
Public fieldNames As BCOps.ArrayOfString
<System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=false, Order:=6)> _
Public fieldValues As BCOps.ArrayOfString
If there is any other information I need to provide please let me know.
|
|

05-09-2011, 08:53 AM
|
 |
Fabulous Florist
Forum Leader * Guru *
|
|
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,419
|
|
You're passing String(). The web service code wants ArrayOfString. I know the name "ArrayOfString" makes it sound like it's a string array, but the only thing that's going to work with a string array is String().
You noticed that ArrayOfString inherits from List(Of String) and tried that class. Inheritance doesn't work in that direction. Let's use an analogy.
"Dog" is a base class, like List(Of String) is here. If I ask you to bring me a dog, you could bring me a poodle or a labrador and satisfy the criteria. "Labrador" is a derived class of Dog, like ArrayOfString is here. If I ask you for a Labrador, you can't meet my needs with a Great Dane even though it's still a dog; I asked for a specific kind of dog.
Derived types are considered more specific than base types. Even though it doesn't, ArrayOfString() could have added more properties or methods. If something asks for ArrayOfString(), the compiler wants to be sure that whatever it gets has all of the attributes of ArrayOfString(). List(Of String) isn't guaranteed to meet these needs, so it's illegal.
So you need to use ArrayOfString. Since it derives from List(Of String), all you have to do is take the code you wrote to use List(Of String) and replace the type with ArrayOfString. I'd expect this to work:
Code:
Dim fieldNamesArray() As String = { "filenetdocid", "filenetsystemid", ... }
Dim fieldNames As New ArrayOfString()
fieldNames.AddRange(fieldNamesArray)
The AddRange() method takes a collection of items and adds them all to the list. Alternatively, you could add each name individually:
Code:
Dim fieldNames As New ArrayOfString()
fieldNames.Add("filenetdocid")
fieldNames.Add("filenetsystemid")
...
It's obviously a bit more tedious.
See if that works.
|
|

05-09-2011, 12:09 PM
|
|
Newcomer
|
|
Join Date: May 2011
Posts: 2
|
|
|
This worked like a charm - thank you so much.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|