【发布时间】:2017-08-29 11:13:59
【问题描述】:
与我之前的帖子有关
Getting the response result as an array and not a object in web service
我写了一个web服务,服务的响应信息如下
s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<signOnResponse xmlns="http://tempuri.org/">
<signOnResult xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:string>NA</a:string>
<a:string>NA</a:string>
<a:string>NA</a:string>
<a:string>10</a:string>
</signOnResult>
</signOnResponse>
</s:Body>
</s:Envelope>
我需要更改响应如下
s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<signOnResponse xmlns="http://tempuri.org/">
<signOnResult>NA</signOnResult>
<signOnResult>NA</signOnResult>
<signOnResult>NA</signOnResult>
<signOnResult>10</signOnResult>
</signOnResponse>
</s:Body>
</s:Envelope>
我编写的 web 方法返回字符串数组。
为了获得对我首选结构的响应,我正在研究是否可以更改 XML 序列化的格式以给出响应。但我找不到合适的解决方案。我也尝试实现 IClientMessageInspector。
注意:用php编写的客户端可以读取不在string对象下的XML结构。它只能读取下面的 XML。并且无法对客户端代码进行任何更改。
s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<signOnResponse xmlns="http://tempuri.org/">
<signOnResult>NA</signOnResult>
<signOnResult>NA</signOnResult>
<signOnResult>NA</signOnResult>
<signOnResult>10</signOnResult>
</signOnResponse>
</s:Body>
</s:Envelope>
提前致谢
【问题讨论】:
标签: c# xml web-services wcf