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

GentlerMan 2021-05-25 09:22:52
目前返回的格式是
<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);
}
}

...全文
2518 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Null_Reference 2021-05-27
  • 打赏
  • 举报
回复
命名空间不一致!!!

12,166

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧