Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to configure additional WCF operation attributes
xomega
#1 Posted : Sunday, August 19, 2012 5:28:10 PM(UTC)
xomega



Xomega model gives you full control over the way WCF service contracts are generated from your service model by allowing you to specify any additional WCF service or operation attributes right in the model. Here is what it takes to specify such attributes:
  1. Make sure that the module element that contains your logical type declares a prefix for the "http://www.xomega.net/wcf" namespace, e.g. xmlns:wcf="http://www.xomega.net/wcf"
  2. Add a config element inside the element for either your operation for the operation-level or your object for service-level attributes respectively.
  3. Add a wcf:operation-attributes or wcf:service-attributes element inside the config element as appropriate.
  4. For each attribute that you want to define add the corresponding element in the wcf namespace to the wcf:operation-attributes or wcf:service-attributes element accordingly.
  5. If the WCF attribute doesn't have a default constructor, then add each constructor parameter as a nested element inside the attribute's element.
  6. To configure the properties of the WCF attribute set the corresponding XML attribute on the WCF attribute's element.
  7. Generate the WCF Service Contracts and make sure your service or operation was generated using the correct WCF attributes.

Below is a snippet that demonstrates this example.
Code:
<object name="flight">
  <fields>
    <field name="number" type="invoice number" key="serial" required="true"/>
    <field name="origin" type="airport code"/>
    <field name="destination" type="airport code"/>
  </fields>
  <operations>
    <operation name="search flights">
      <input>
        <param name="airlines" type="" list="true"/>
        <struct name="origin" ref="location struct"/>
        <struct name="destination" ref="location struct"/>
      </input>
      <output list="true">
        <param name="flight" type="flight number" required="true"/>
        <param name="origin" type="airport code"/>
        <param name="destination" type="airport code"/>
        <param name="departure" type="time"/>
        <param name="schedule" type="day of week" list="true"/>
      </output>
      <config>
        <wcf:operation-attributes>
          <wcf:OperationContract ProtectionLevel="System.Net.Security.ProtectionLevel.None"/>
          <wcf:OperationBehavior Impersonation="ImpersonationOption.NotAllowed"/>
          <wcf:TransactionFlow>
            <wcf:transactions>TransactionFlowOption.NotAllowed</wcf:transactions>
          </wcf:TransactionFlow>
        </wcf:operation-attributes>
      </config>
    </operation>
  </operations>
  <config>
    <wcf:service-attributes>
      <wcf:ServiceContract SessionMode="SessionMode.Allowed"/>
    </wcf:service-attributes>
  </config>
</object>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.