2012-04-11 3 views
2

Ich habe ein großes Problem. Ich versuche, einen Webdienst zu erstellen, der mit einer verteilten Transaktion arbeiten wird.
Der gesamte folgende Code befindet sich auf der Serverseite des Webdienstes (der Webdienst, der von einem Client aufgerufen wird).
schrieb ich in meinem Schnittstelle:Das TransactionFlowAttribute-Attribut ist auf Obligatorisch gesetzt, aber die Bindung des Kanals ist nicht mit einem TransactionFlowBindingElement konfiguriert.

[ServiceContract] 
public interface IClientOperations 
{ 

    [OperationContract] 
    [ServiceKnownType(typeof(TriggerExecInput))] 
    [ServiceKnownType(typeof(TriggerExecOutput))] 
    [TransactionFlow(TransactionFlowOption.Mandatory)] 
    TriggerExecOutput TriggeredProfileDataUpdate(TriggerExecInput triggerInputData, bool isST3StatusActive); 

Und dies in der Datei web.config:

<services> 
    <service name="ClientOperationsService" behaviorConfiguration="ServiceBehavior"> 
    <endpoint address="" binding="wsHttpBinding" 
       bindingConfiguration="wsHttpBinding_Common" contract="SL.STAdmin.Applications.WebAPI.IClientOperations"/> 
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/> 
    </service> 
</services> 

<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpBinding_Common" transactionFlow="true"> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="ServiceBehavior"> 
     <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
     <serviceMetadata httpGetEnabled="true"/> 
     <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

Wenn ich Recht, die SVC-Datei klicken und klicken Sie auf "Ansicht im Browser" ich der folgende Fehler

Exception Details: System.InvalidOperationException: At least one operation on the 'ClientOperations' contract is configured with the TransactionFlowAttribute attribute set to Mandatory but the channel's binding 'BasicHttpBinding' is not configured with a TransactionFlowBindingElement. The TransactionFlowAttribute attribute set to Mandatory cannot be used without a TransactionFlowBindingElement. 

Ich habe andere .svc-Dateien, die keine Transaktionen verwenden. Sie alle funktionieren gut. Ich verstehe nicht, warum es immer noch versucht, die BasicHttpTransaction zu verwenden, wenn ich es anweisen, den anderen Bindungstyp zu verwenden.

Hat jemand eine Idee, was ich falsch mache? Vielen Dank im Voraus.

+0

'BasicHttpTransaction' ist keine Bindung, ich denke du meinst' BasicHttpBinding' –

Antwort

0

Fügen Sie diese in Ihrem <system.serviceModel> Element Ihrer web.config:

<protocolMapping> 
    <add scheme="http" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Common"/> 
</protocolMapping> 
0

Sie müssen ein paar Dinge tun, arbeiten, um die Transaktion zu erhalten. Fügen Sie den transactionflow zu Ihrem Betrieb

[OperationContract] 
[TransactionFlow(TransactionFlowOption.Mandatory)] 
void TransactionSupported(int id, string name); 

Danach können Sie eine operationbehavior zu Ihrer Implementierung

[OperationBehavior(TransactionScopeRequired = true)] 
public void TransactionSupported(int id, string name) 
{ 
    ... 
} 

In Ihrer Konfigurationsdatei hinzufügen, müssen Sie den Transaktionsfluss zu Ihrem Host hinzufügen Bindung

<system.serviceModel> 
    ... 
    <bindings> 
     <netNamedPipeBinding> --> Your binding (don't use basicHttpBinding) 
     <binding transactionFlow="true"/> 
     </netNamedPipeBinding> 
    </bindings> 
    </system.serviceModel> 

Und last but not least müssen Sie den Transaktionsfluss Ihres Clients einstellen, damit es funktioniert. In meinem Beispiel tue ich dies in meinem Code in meinem Komponententest, ich denke, Sie können dies auch in Ihrer Konfiguration Ihres Clients tun, in Ihrer Konfigurationsdatei.

var factory = new ChannelFactory<IService>(callback, 
       new NetNamedPipeBinding() { TransactionFlow = true }, 
       new EndpointAddress("net.pipe://localhost/ping")); 
Verwandte Themen