Search code examples
c#wcfsoapweb-config

Add namespace to WCF method


I have this WCF project I want to add 'tem' prefix to method not input like these lines XML code

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> 
<soapenv:Header/><soapenv:Body>
<tem:FetchServiceInfoByBillId>
<USER_NAME>username</USER_NAME>
</tem:FetchServiceInfoByBillId>
</soapenv:Body>
</soapenv:Envelope>

Here is the interface

[ServiceContract(Namespace ="")]
public interface IOnlineService
{
  [OperationContract]
  [return: MessageParameter(Name = "Error_code")]
  string FetchServiceInfoByBillId(string USER_NAMES);

}

and I get these XML with this interface

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> 
<soapenv:Header/><soapenv:Body>
<FetchServiceInfoByBillId>
<USER_NAME>username</USER_NAME>
</FetchServiceInfoByBillId>
</soapenv:Body>
</soapenv:Envelope>

If I use [ServiceContract] instead of [ServiceContract(Namespace ="")] I get 'tem' before method and input but I just want it before the method name


Solution

  • After some days of searching, I figure out the solution with this link. Also, it didn't because the client had problems with the output