Problem with wsdl in application


I am having a problem using a wsdl file and am receiving the following error:

"Unable to generate a temporary class (result=1).
error CS0029: Cannot implicitly convert type 'ParcelForce.ContentData' to 'ParcelForce.ContentData[]'"

I have had a look on the Microsoft site and got the following :

"You can generate the proxy class manually by using WSDL.exe and then change the proxy class in which the data type was inappropriately created as a two-dimensional array (for example, "CustomType[][]") so that it is a single-dimensional array (for example, "CustomType[]"). "

I have generated the proxy class manually but I am unsure what to change (code below):

    <System.Web.Services.Protocols.SoapDocumentMethodAttribute("printLabel", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)> _
    Public Function printLabel(<System.Xml.Serialization.XmlElementAttribute([Namespace]:="")> ByVal PrintLabelRequest As PrintLabelRequest) As <System.Xml.Serialization.XmlElementAttribute("PrintLabelReply", [Namespace]:="")> PrintLabelReply
        Dim results() As Object = Me.Invoke("printLabel", New Object() {PrintLabelRequest})
        Return CType(results(0), PrintLabelReply)
    End Function

Best Regards,

Who is Participating?
Miguel OzSoftware EngineerCommented:
OK, I think your problem is located in the lines below:
 Private parcelContentsField()() As ContentData
Public Property ParcelContents() As ContentData()()

Replace with:
 Private parcelContentsField() As ContentData
Public Property ParcelContents() As ContentData()

Notice that you may have some issues especially with unbounded arrays as explained here. My suggestion will be to use other schema code generator like
Miguel OzSoftware EngineerCommented:
You need to search for 'ParcelForce.ContentData'  in your proxy code and check in the WSDL whether is being used as an array, then you can change to ParcelForce.ContentData[]
If more help required, please post the whole proxy code and the WSDL. The posted code does not contain 'ParcelForce.ContentData'
ross13Author Commented:

I have had a look at the wsdl file:
      <xs:complexType name="ContentData">
          <xs:element name="Name" type="xs:string" />
          <xs:element name="Data" type="xs:string" />

and I have checked the proxy and it looks like a class has been created:
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.18020"),  _
 System.SerializableAttribute(),  _
 System.Diagnostics.DebuggerStepThroughAttribute(),  _
 System.ComponentModel.DesignerCategoryAttribute("code"),  _
 System.Xml.Serialization.XmlTypeAttribute([Namespace]:="")>  _
Partial Public Class ContentData
    Private nameField As String
    Private dataField As String
    Public Property Name() As String
            Return Me.nameField
        End Get
            Me.nameField = value
        End Set
    End Property

I am a bit unsure what to change. Any help would be appreciated.

Best Regards,

ross13Author Commented:
Thanks for that. I will give it a try.
ross13Author Commented:
Thanks for the help.

Best regards,

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.