Solved

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

Posted on 2013-12-18
7
1,380 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
I need C# converted to VB.net 1 53
.net VBA word safemode 1 24
Closing all open child forms. 4 23
Copy/Clone an object. 9 15
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now