How to modify the response element name in soap message?

If we use data contract in WCF, the default soap message looke like:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body>
    <GetDataUsingDataContractResponse xmlns="http://tempuri.org/">
      <GetDataUsingDataContractResult xmlns:a="http://schemas.datacontract.org/2004/07/WcfService10" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <a:BoolValue>false</a:BoolValue>
        <a:StringValue>test</a:StringValue>
      </GetDataUsingDataContractResult>
    </GetDataUsingDataContractResponse>
  </s:Body>
</s:Envelope>

If we want to use a coustome element name instead of "GetDataUsingDataContractResponse ", "GetDataUsingDataContractResult ", "a:BoolValue"

How can we achieve this?

One possible way would be MessageParameter

[return: System.ServiceModel.MessageParameterAttribute(Name="Output")]

http://msdn.microsoft.com/en-us/library/system.servicemodel.messageparameterattribute.aspx

Or use message contract, the output would be: 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body>
    <CompositeType xmlns="http://tempuri.org/">
      <BoolValue>false</BoolValue>
      <StringValue>test</StringValue>
    </CompositeType>
  </s:Body>
</s:Envelope>

However, this is not excatly what I want. I looking for something like this:

How to: Control Parameter and Return Value Formatting for a Web Service Method

http://msdn.microsoft.com/en-us/library/a561tby9.aspx

There should be a solution which allow us fully control the format of soap message returned by an WCF operation. Still looking for it.......

(it is regret that can't don further rearching before move to a new question)

 

转载于:https://www.cnblogs.com/LeoTang/archive/2012/07/27/2611821.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值