Solved

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

Posted on 2013-12-18
7
1,598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

628 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