由于EndpointDispatcher上的ContractFilter不匹配,无法处理操作

时间:2013-12-04 16:46:58

标签: web-services wshttpbinding contract mismatch

我正在尝试运行一个简单的Web服务,在触发时发送电子邮件,但在尝试设置时出现以下错误:

由于EndpointDispatcher上的ContractFilter不匹配,无法在接收方处理带有Action'localhost / IFabricService / StartMailRun'的消息。这可能是由于合同不匹配(发送方与接收方之间的操作不匹配)或发送方与接收方之间的绑定/安全性不匹配。检查发件人和收件人是否具有相同的合同和相同的约束(包括安全要求,例如邮件,传输,无)。'。

我的服务编码如下:

namespace Project.Fabric
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IFabricService
{
    [OperationContract(IsOneWay=true)]
    void StartMailRun(int id, string customerGuid);

}


// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
    bool boolValue = true;
    string stringValue = "Hello ";

    [DataMember]
    public bool BoolValue
    {
        get { return boolValue; }
        set { boolValue = value; }
    }

    [DataMember]
    public string StringValue
    {
        get { return stringValue; }
        set { stringValue = value; }
    }
}

}

这是从一个名为Project.Biz的类库中调用的,文件名为EmailBiz.cs 以下代码:

public void StartEmailRun(int id)
    {
        WS2007HttpBinding myBinding = new WS2007HttpBinding();
        myBinding.Security.Mode = SecurityMode.TransportWithMessageCredential;
        myBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;

        // Create the endpoint address.
        EndpointAddress ea = new EndpointAddress("https://fabric.metalearning.net/FabricService.svc");

        // Create the client.                       
        MetaLearning.Fabric.Console.ServiceReference1.FabricServiceClient svc = new MetaLearning.Fabric.Console.ServiceReference1.FabricServiceClient(myBinding, ea);


        // Specify a certificate to use for authenticating the client.
        svc.ClientCredentials.ClientCertificate.SetCertificate(
        StoreLocation.LocalMachine,
        StoreName.My,
        X509FindType.FindByThumbprint,
        "thumbprinthere");

        // Begin using the client.
        try
        {
            svc.Open();
            //this will need changed to include correct string of GUID and correct ID for email campaign.
            svc.StartMailRun(id, "a67f8076-82c6-427c-ac34-fb34aee59e0b");
            System.Console.ReadLine();

            // Close the client.
            svc.Close();
        }
        catch (Exception ex)
        {
        }  
    }

Fabric服务的web.config如下所示:

<system.serviceModel>
<services>
  <service behaviorConfiguration="ServiceCredentialsBehaviour" name="MetaLearning.Fabric.FabricService">
    <endpoint binding="ws2007HttpBinding" bindingConfiguration="WSHttpBinding_IFabricService" name="SecuredByClientCertificate" contract="MetaLearning.Fabric.IFabricService" />
  </service>
</services>
<bindings>
  <ws2007HttpBinding>
    <binding name="WSHttpBinding_IFabricService">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="Certificate" />
      </security>
    <!--<security mode="Transport"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
      <message clientCredentialType="Certificate" algorithmSuite="Default" />
    </security>--> 
    </binding>
  </ws2007HttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceCredentialsBehaviour">
      <!-- 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" />
      <serviceMetadata httpsGetEnabled="true" />
      <serviceCredentials>
        <serviceCertificate findValue="thumbprinthere" x509FindType="FindByThumbprint" storeLocation="LocalMachine" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
    <add binding="ws2007HttpBinding" scheme="https" />
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />

任何人都可以看到我忽略了会导致这个问题吗?

0 个答案:

没有答案