开发者

Is it possible to change the result attribute of a wcf webservice?

开发者 https://www.devze.com 2023-03-25 02:13 出处:网络
I have a problem with the response method of the Soap serve开发者_开发问答r. It is a .net WCF webservice

I have a problem with the response method of the Soap serve开发者_开发问答r. It is a .net WCF webservice

The following code:

[ServiceContract()]
public interface IService1
{
    [OperationContract()]
    List<DealerLead> GetDealerLeads(List<DealerLeadsRequest> accountnummerString);
}

Will return this:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <GetDealerLeadsResponse xmlns="http://tempuri.org/">
         <GetDealerLeadsResult xmlns:a="http://schemas.datacontract.org/2004/07/SoapTest"     xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

But how can i change it to this:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
  <GetDealerLeadsResponse xmlns="http://tempuri.org/">
     <AOtherMethodName xmlns:a="http://schemas.datacontract.org/2004/07/SoapTest" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

So only the method result name must be changed, is this possible with WCF?

Thanks in advance


If you want to control the name of the SOAP operation, you can use

[OperationContract(Name = "AOtherMethodName")]

If you really want to control the format of the message on the wire, you'll need to define a message contract

0

精彩评论

暂无评论...
验证码 换一张
取 消