Solved

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

Posted on 2013-12-18
7
1,487 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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