[英]How to remove the outerXML from WCF service response
我需要构建一个WCF服务。 我成功了。 它给了我以下输出结果。
结果输出:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
<AmountResponse>
<Status>-8</Status>
<ErrorCode>-8</ErrorCode>
<Amount>0</Amount>
</AmountResponse>
</string>
此服务将由金融机构使用。 他们要求稍微改变结果。
需要删除 <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
和</string>
我在这里得到了一个解决方案并将[XmlSerializerFormat]
添加到我的界面。 完成后,结果显示为:
<string>
<AmountResponse>
<Status>-8</Status>
<ErrorCode>-8</ErrorCode>
<Amount>0</Amount>
</AmountResponse>
</string>
从这个结果我想删除<string>
和</string>
,使它看起来像:
<AmountResponse>
<Status>-8</Status>
<ErrorCode>-8</ErrorCode>
<Amount>0</Amount>
</AmountResponse>
有什么办法可以删除<string>
和</string>
吗?
[ServiceContract(Namespace = "")]
[XmlSerializerFormat]
public interface IHelloWorldService
{
[OperationContract]
[WebGet(BodyStyle = WebMessageBodyStyle.Bare)]
Stream Form();
...
public class HelloWorldService : IHelloWorldService
{
public Stream Form()
{
WebOperationContext.Current.OutgoingResponse.ContentType =
"text/html";
return new MemoryStream(Encoding.UTF8.GetBytes("A working class hero is something to be "));
}
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.