请教一个WCF返回格式的问题

GentlerMan CSDN会员 GentlerMan 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
目前返回的格式是
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<InvokeResponse xmlns="http://localhost/BOI/">
<InvokeResult>
<InvokeResult>true</InvokeResult>
<result>OK</result>
</InvokeResult>
</InvokeResponse>
</s:Body>
</s:Envelope>


而目标想得到的目标值是
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<boi:InvokeResponse xmlns:boi="http://localhost/BOI/">
<boi:InvokeResult>
<boi:InvokeResult>true</boi:InvokeResult>
<boi:result>OK</boi:result>
</boi:InvokeResult>
</InvokeResponse>
</s:Body>
</s:Envelope>


请问下这个前缀如何设置?

主要疑问点就是如何在节前前面加上那个点缀?

以下附带了目前使用代码:
namespace WcfServiceLibrary
{

public delegate string DisplayContent(string content);
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“Service1”。

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, Namespace = "http://localhost/BOI/")]
[XmlSerializerFormat]
public class WServiceInstance : IService_Contract
{
public DisplayContent AddContent;

public BoiResult Invoke(string form, string token, string funcName, string parameters)
{
var jsonres = AddContent(form + ";" + token + ";" + funcName + ";" + parameters);
var data = new BoiResult();
data.InvokeResult = true;
data.result = jsonres;
return data;
}
}

[DataContract(Namespace = "")]
[XmlSerializerFormat]
public class BoiResult
{
[DataMember]
public bool InvokeResult;

[DataMember]
public string result;
}
}


namespace WcfServiceLibrary
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService_Contract”。
[ServiceContract(Namespace = "http://localhost/BOI/")]
[XmlSerializerFormat]
public interface IService_Contract
{
[OperationContract(Action = "", Name = "Invoke")]
BoiResult Invoke(string form, string token, string funcName, string parameters);
}
}

...全文
评论 1
收藏 已收藏
分享
返回顶部
GentlerMan CSDN会员
Web Services 12,164 成员 16,322 内容