我需要建立一个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>
我得到了一个解决方案here,并将[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> 有什么办法可以去除和
发布于 2018-01-23 19:11:34
[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 "));
}..。
https://stackoverflow.com/questions/39331312
复制相似问题