Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在.NET中使用Web服务(Visual Studio 2012)_C#_Vb.net_Web Services_Visual Studio 2012 - Fatal编程技术网

C# 在.NET中使用Web服务(Visual Studio 2012)

C# 在.NET中使用Web服务(Visual Studio 2012),c#,vb.net,web-services,visual-studio-2012,C#,Vb.net,Web Services,Visual Studio 2012,在Visual Studio 2012中创建对JAX(Java Web服务库)提供的远程Web服务的服务引用时,在生成的存根中没有正确创建“简单”复杂对象 正确创建了包含多个子元素的复杂对象。。例如: <xs:complexType name="condition"> <xs:sequence> <xs:element name="fieldId" type="xs:int" minOccurs="0"/> <xs:element n

在Visual Studio 2012中创建对JAX(Java Web服务库)提供的远程Web服务的服务引用时,在生成的存根中没有正确创建“简单”复杂对象

正确创建了包含多个子元素的复杂对象。。例如:

<xs:complexType name="condition">
  <xs:sequence>
    <xs:element name="fieldId" type="xs:int" minOccurs="0"/>
    <xs:element name="operator" type="xs:string" minOccurs="0"/>
    <xs:element name="value1" type="xs:string" minOccurs="0"/>
    <xs:element name="value2" type="xs:string" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>
这似乎已经用单个多维字符串数组取代了数据行的数组

没有编译错误,但在尝试使用此服务时,出现运行时错误:

error CS0030: Cannot convert type 'string[]' to 'string'
error CS0029: Cannot implicitly convert type 'string' to 'string[]'
我可以编辑生成的引用文件,将GetType(String)更改为GetType(String())

 <System.Xml.Serialization.XmlArrayAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable:=True, Order:=47), _
     System.Xml.Serialization.XmlArrayItemAttribute("dataValue", GetType(String()), Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
    Public Property results() As String()()
        Get
            Return Me.resultsField
        End Get
        Set(value As String()())
            Me.resultsField = value
            Me.RaisePropertyChanged("results")
        End Set
    End Property
_
公共属性结果()为字符串()()
收到
Return Me.resultsField
结束
设置(值为字符串())
Me.resultsField=值
Me.RaisePropertyChanged(“结果”)
端集
端属性
这会导致代码不会抛出运行时错误,但从webservice返回的项为空。结果似乎是一个空白字符串数组(在本例中为6个),而它应该是一个多维数组(6个字符串数组的列表),包含填充的字符串

我可能会编辑生成的引用文件,以强制生成数据行。如果有一种简单的方法可以在自动生成的存根中自动实现这一点,我更愿意这样做

我不熟悉在.NET中使用Web服务的复杂性。如果您有任何关于如何使其发挥作用的建议,我们将不胜感激


我已成功使用其他语言的此Web服务,无需手动干预。

尝试使用
svculity
生成代理类。我假定您指的是svcutil。使用默认设置,这将生成与Visual Studio相同的客户端存根和相同的问题。我将查看是否有任何svcutil参数可以更改生成的代码。
Private results()() As String
error CS0030: Cannot convert type 'string[]' to 'string'
error CS0029: Cannot implicitly convert type 'string' to 'string[]'
 <System.Xml.Serialization.XmlArrayAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable:=True, Order:=47), _
     System.Xml.Serialization.XmlArrayItemAttribute("dataValue", GetType(String()), Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
    Public Property results() As String()()
        Get
            Return Me.resultsField
        End Get
        Set(value As String()())
            Me.resultsField = value
            Me.RaisePropertyChanged("results")
        End Set
    End Property