Solved

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

Posted on 2013-12-18
7
1,574 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
Independent Software Vendors: 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

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!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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