Benutzer:MovGP0/WCF/Contracts

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
   MovGP0        Über mich        Hilfen        Artikel        Weblinks        Literatur        Zitate        Notizen        Programmierung        MSCert        Physik      

  • Service can only use default constructor!
  • Service can implement multiple contracts
  • Static elements cannot be accessed by WCF

Service Contract

[Bearbeiten | Quelltext bearbeiten]
// default namespace is http://tempuri.org
// default name is interface name
[ServiceContract(Namespace = "http://myNamespace", Name = "MyContract")]
interface IMyContract 
{ 
   // default name is method name
   [OperationContract(Name = "MyOperation")] 
   string MyMethod(string text); 

   // Will not be part of the contract 
   string MyOtherMethod(string text); 
} 

class MyService : IMyContract 
{ 
   public string MyMethod(string text) 
   { 
      return "Hello " + text; 
   } 

   public string MyOtherMethod(string text) 
   { 
      return "Cannot call this method over WCF"; 
   } 
}

Message Contract

[Bearbeiten | Quelltext bearbeiten]