繁体   English   中英

MessageSecurityException没有为具有“http:// ...”操作的消息指定签名消息部分

[英]MessageSecurityException No signature message parts were specified for messages with the 'http://…' action

这是客户端和服务器使用的配置文件

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IPM_Service" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
            allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8080/PM_Service"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPM_Service"
          contract="IPM_Service" name="WSHttpBinding_IPM_Service">
        <identity>

        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

这是我得到错误的代码块。

            ProgrammingMaster_ServiceClient aClient = new ProgrammingMaster_ServiceClient();
            aClient.BeginProgrammingSession(0x01);
            aClient.Close();

第二行是异常发生的地方。 使用svcutil.exe工具创建ProgrammingMaster_ServiceClient

这是我用来启动服务器的代码。

public bool StartService(string aIp)
{
    string lsInstanceId = pFBlock.InstanceId.ToString();
    Uri loBaseAddr = new Uri(string.Format("http://localhost:808{0}/{1}", lsInstanceId, pFBlock.FBlockName));

    pLocalHost = new ServiceHost(typeof(Shadow_ProgrammingMasterService), loBaseAddr);

    Start(aIp);
    return IsHostOpen;
}

private void Start(string aIp)
{
    Shadow_ProgrammingMasterService.SetAPI(this);

    try
    {
        pLocalHost.AddServiceEndpoint(typeof(IProgrammingMaster_Service), new WSHttpBinding(), "PM_Service");

        ServiceMetadataBehavior loSmb = new ServiceMetadataBehavior();
        loSmb.HttpGetEnabled = true;
        pLocalHost.Description.Behaviors.Add(loSmb);
        try
        {
            pLocalHost.Open();
            IsHostOpen = true;
            pPM_Client = new ProgrammingMasterProxyClient(this, pOutput);
            pPM_Client.IpAddress = aIp;
            this.Subscribe(pPM_Client);
            pOutput.setComment("ProgrammingMasterService initialized");
        }
        catch (CommunicationException ce)
        {
            pOutput.setError(ce.Message);
            pLocalHost.Abort();
            IsHostOpen = false;
        }
    }
    catch (CommunicationException ex)
    {
        pOutput.setError(ex.Message);
        pLocalHost.Abort();
        IsHostOpen = false;
        //this.Unsubscribe(pOSTTSClient);
        //pOSTTSClient = null;
    }
}

谁有任何想法可能导致这个?

在您的情况下发生这种情况的原因很简单, WCF服务代码本身已被修改,重新编译(并且基本上部署在调试器中),而客户端(具有现在过时的服务引用)正在期待并且取决于受此更改影响的内容因此发生了冲突。

更新客户端的服务引用将更正此问题。

要继续,上述并不是说一旦客户端引用了服务本身就不能更改任何代码(不破坏客户端),但是,这样的问题表明服务的某些部分发生了重大变化。客户端依赖于,例如公开方法的签名,现有DataContract类型的现有DataMember属性等。

相比之下,您可以将现有服务调用的方法体改变为您心中的内容(客户端不关心服务如何工作,如何使其工作); 您还可以向现有复合DataContract类型添加新成员,以便新客户端可以轻松使用您的更新,从而阻止具有冗余的DataType2类型方案,等等。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM