我在 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/