我有一个 SOAP 服务,它返回一个复杂类型的数组。PHP 中 NuSOAP 中的定义如下所示:
// The type itself
$server->wsdl->addComplexType(
"Clip",
"complexType",
"struct",
"all",
"",
array(
"Id" => array(
"name" => "id",
"type" => "xsd:int"
)
// ---snip---
)
);
// The type of the array
$server->wsdl->addComplexType(
"ClipList",
"complexType",
"array",
"sequence",
"",
array(
"clip" => array(
"name" => "clip",
"type" => "tns:Clip",
"minOccurs" => "0",
"maxOccurs" => "unbounded"
)
),
array(),
"tns:Clip"
);
// The service
$server->register(
"GetClipList",
array(),
array(
"clips" => "tns:ClipList"
),
"urn:MyNamespace",
"urn:MyNamespace#GetClipList",
"rpc",
"encoded",
"Retrieves a list of all clips."
);
现在,在我的 VisualStudio2010 C# 项目中,我添加了一个基于生成的 WSDL 的新服务。VS 创建了一个代理类供我使用,其中包含一个ClipList
具有单个数据成员类型的类Clip[]
。
到现在为止还挺好。现在,当我调用GetClipList()
我的代理时,我得到一个CommunicationException
告诉我它不能将 type 的对象分配给 typeClip[]
的对象ClipList
。
所以我假设它将返回的数据反序列化为 aClip[]
并且现在想要满足GetClipList
方法的返回类型(这将是ClipList
)。
GetClipList()
将代理中的返回值更改为Clip[]
手动时,应用程序运行良好。但出于明显的原因,我想避免更改自动生成的类。
那么,为什么它不实例化 aClipList
并填充数据成员呢?或者,为什么 VS 不生成代理类以便GetClipList
直接返回一个Clip[]
.