【问题标题】:C# SOAP: The specified type was not recognized: name='arrayList'C# SOAP:无法识别指定的类型:name='arrayList'
【发布时间】:2014-04-16 11:31:41
【问题描述】:

我在 C# 中有一个客户端应用程序,它从外部 SOAP 服务调用一些方法。为了使用此服务,我从服务 WSDL 生成了代理类。 除了一项操作外,一切正常。 当我尝试调用此操作时,它会向我抛出 CommunicationException 并显示以下消息:

Error in deserializing body of reply message for operation 'my-operation-name'

InnerException 如下:

The specified type was not recognized: name='arrayList',
namespace='http://www.oracle.com/webservices/internal/literal', at <validationErrors
xmlns='http://view.label.com/types/'>.

我在 WSDL 文件中找到了这个元素的描述:

<element name="validationErrors" type="ns1:list" nillable="true" />

但我看不到对 arrayList 数据类型的任何引用。

这是来自服务的响应:

    <env:Envelope
     xmlns:env="http://www.w3.org/2003/05/soap-envelope"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:ns0="http://view.label.com/"
     xmlns:ns1="http://view.label.com/types/"
     xmlns:ns2="http://www.oracle.com/webservices/internal/literal">
   <env:Body>
     <ns0:getLabelResponseElement>
     <ns0:result>
     <ns1:statusMessage>Error while reading xml label request.</ns1:statusMessage>
     <ns1:requestId/>
     <ns1:payload/>
     <ns1:labelId/>
     <ns1:status>Error</ns1:status>
     <ns1:validationErrors
       xsi:type="ns2:list"
       xsi:nil="1"/>
     <ns1:statusCode>LabelAssembler_03</ns1:statusCode>
    </ns0:result>
     </ns0:getLabelResponseElement>
    </env:Body>
    </env:Envelope>

能否请您指出此问题的可能根源?如果这是我的客户端应用程序部分的问题,或者是兼容性问题,因为该服务是用 Java 编写的,而我的客户端应用程序是用 C# 编写的? 提前致谢。

【问题讨论】:

  • 你能提供来自 web 服务的 SOAP 响应吗?
  • 我已经添加了响应的例子。

标签: c# java web-services soap wsdl


【解决方案1】:

我找到了解决方案 - 使用 svcutil.exe 生成的代理类为响应对象的成员之一生成奇怪的类型:

private list validationErrorsField;

这是:

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.oracle.com/webservices/internal/literal")]
public partial class list : collection
{
}

收集是:

/// <remarks/>
[System.Xml.Serialization.XmlIncludeAttribute(typeof(list))]
[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.oracle.com/webservices/internal/literal")]
public partial class collection
{

    private object[] itemField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("item", Order=0)]
    public object[] item
    {
        get
        {
            return this.itemField;
        }
        set
        {
            this.itemField = value;
        }
    }
}

所以我只是将这个有问题的类型更改为 string[],现在一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-18
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多