Solved

Object cannot be stored in an array of this type - Web Service

Posted on 2013-12-18
7
1,446 Views
Last Modified: 2013-12-22
I have a vb.net win app that calls a web service.

In the Request Section in my case s_Request I want to pass some parameters before I call the web service.
I am not sure how. Tried this but fails:
 
s_Request.Matnr.SetValue("I", 0)

Error: Object cannot be stored in an array of this type

I want to pass: Sign, Option, Low values but not sure how.

Here is some code generated when I added the web service:
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:sap-com:document:sap:soap:functions:mc-style")>  _
    Partial Public Class MatnrRan
        Inherits Object
        Implements System.ComponentModel.INotifyPropertyChanged
       
        Private signField As String
       
        Private optionField As String
       
        Private lowField As String
       
        Private highField As String
       
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, Order:=0)>  _
        Public Property Sign() As String
            Get
                Return Me.signField
            End Get
            Set
                Me.signField = value
                Me.RaisePropertyChanged("Sign")
            End Set
        End Property
       
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, Order:=1)>  _
        Public Property [Option]() As String
            Get
                Return Me.optionField
            End Get
            Set
                Me.optionField = value
                Me.RaisePropertyChanged("Option")
            End Set
        End Property
       
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, Order:=2)>  _
        Public Property Low() As String
            Get
                Return Me.lowField
            End Get
            Set
                Me.lowField = value
                Me.RaisePropertyChanged("Low")
            End Set
        End Property
       
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, Order:=3)>  _
        Public Property High() As String
            Get
                Return Me.highField
            End Get
            Set
                Me.highField = value
                Me.RaisePropertyChanged("High")
            End Set
        End Property
       
        Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
       
        Protected Sub RaisePropertyChanged(ByVal propertyName As String)
            Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent
            If (Not (propertyChanged) Is Nothing) Then
                propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
            End If
        End Sub
    End Class

Thank you
0
Comment
Question by:iosifrn
  • 4
  • 3
7 Comments
 

Author Comment

by:iosifrn
ID: 39728044
If it would be without array for parameter I would call like this:
                s_Request.INPUT = New Get_Prod_Details.ZINPUT
                s_Request.INPUT.PLANT = reader(2).ToString()
That works fine.

But this:
       s_Request.IT_COMPONENT = New Get_Prod_Details.BAPI_ORDER_COMPONENT(1) {}
       s_Request.IT_COMPONENT..... dont know how to set value on this.

Can you give me a sample?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39729204
For your example, I would think that it should be like this:
s_Request.Matnr.Sign = "+"
s_Request.Matnr.Option = "A"
s_Request.Matnr.Low = "45

Open in new window

"
0
 

Author Comment

by:iosifrn
ID: 39729292
If I try that the compiler says that:
Sign is not a member of "System.Array"

And of course same for the others.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 39729323
I work with C# more than VB.NET, and the () is something that I would overlook, since C# uses [] for arrays.

What errors, if any, do you get with this code?

s_Request.Matnr.Sign(0) = "+"
s_Request.Matnr.Option(0) = "A"
s_Request.Matnr.Low(0) = "45

Open in new window

0
 

Author Comment

by:iosifrn
ID: 39729362
When I try: s_Request.Matnr.Sign(0) = "I"

I get the same error: Sign is not a member of "System.Array"
Not sure why s_Request.Matnr does not show the : Sign, Option or Low in the IntelliSense dropdown list.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 39729420
What type of web service are you working with?

How did you add the web service reference?
0
 

Author Comment

by:iosifrn
ID: 39735268
I solved it.
It needed an object of the same type.
Something like:

Dim add_MatNr As New Master_Data_Details.MatnrRan()
add_MatNr.Sign = "I"

then: s_Request.Matnr.SetValue(add_MatNr, 1)

Thanks anyway for helping.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question