C# SOAP : The specified type was not recognized: name ='arrayList'

标签 c# java web-services soap wsdl

我在 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# 编写的? 提前致谢。

最佳答案

我找到了解决方案 - 使用 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[],现在一切正常。

关于C# SOAP : The specified type was not recognized: name ='arrayList' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23108223/

相关文章:

c# - 如何从 .Net 中的超线程中获得最大 yield

c# - 在 .NET 4.5 beta 中获取 System.Net.Mail.MailMessage 作为 MemoryStream

java - 在这种情况下如何向文件名添加特殊字符

web-services - 新网站域的新 SSL 证书

java - jax-ws 更改或包装 WSServlet

java - 如何使用 JAX-RS 标准客户端 API 处理来自 Web 服务的错​​误 JSON 内容类型?

c# - 使用 Moq 部分模拟类内部方法

c# - 以编程方式断开和重新连接显示

JavaFX:加载文件后布局发生变化

java - Android 无法启动 Activity - java.lang.RuntimeException : Unable to start activity ComponentInfo