为WCF服务创建REST和SOAP端点?

时间:2016-06-20 11:23:45

标签: wcf rest soap

我需要一个带有两个端点的服务。当我使用1个端点创建服务时,它工作正常,但是当我添加2个端点时,它会抱怨端点未找到。 没有地址扩展的端点工作正常,但没有地址('下载') 这是我的配置:

服务器                                                       

  <serviceBehaviors>

    <behavior name="MessageStreamBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"   httpHelpPageEnabled="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>

  </serviceBehaviors>
</behaviors>

<bindings>
  <basicHttpBinding>      

    <!--stream for video upload-->
    <binding name="httpLargeMessageStream"
                maxReceivedMessageSize="4294967295"
                openTimeout="00:01:00" closeTimeout="00:30:00" sendTimeout="00:30:00"
                transferMode="Streamed">
      <security mode="Transport" />
    </binding>
  </basicHttpBinding>

  <webHttpBinding>
    <!--stream for video download-->
    <binding name="webHttpLargeMessageStream"
                maxReceivedMessageSize="4294967295"
                openTimeout="00:01:00" closeTimeout="00:30:00" sendTimeout="00:30:00"
                transferMode="Streamed">
      <security mode="Transport" />
    </binding>
  </webHttpBinding>



</bindings>
<services>

  <!--service for streamservice; video upload and download-->
  <service name="Trigger.CSSD.Service.Services.MediaService" behaviorConfiguration="MessageStreamBehavior" >
    <endpoint name="restDownloadHttpStream"
              behaviorConfiguration="webHttpBehavior" address="download"
              binding="webHttpBinding" bindingConfiguration="webHttpLargeMessageStream"
              contract="Trigger.CSSD.Service.Services.IDownloadMediaService" />


    <endpoint name="uploadHttpStream" 
             binding="basicHttpBinding" bindingConfiguration="httpLargeMessageStream"
             contract="Trigger.CSSD.Service.Services.IUploadMediaService" />

  </service>

</services>

客户端

  <endpoint address="https://cssd-services:44300/MediaService.svc"
        binding="basicHttpBinding" bindingConfiguration="basicHttpStream"
        contract="MediaService.IUploadMediaService" name="basicHttpStream" />

  <endpoint address="https://cssd-services:44300/MediaService.svc/download" 
       binding="webHttpBinding" bindingConfiguration="webHttpStream" behaviorConfiguration="webHttpBehavior"
       contract="MediaService.IDownloadMediaService" name="webHttpStream" />

</client>

服务 [服务合约]     公共接口IDownloadMediaService     {         [OperationContract的]       // [ContentType(“video / mp4”)]       // [WebGet(UriTemplate =“media / {name}”)]         Stream GetMedia(String name);

}

[ServiceContract]
public interface IUploadMediaService
{
    //http://msdn.microsoft.com/en-us/library/ms751463.aspx
    [OperationContract]
    FileUploadResponseMessage UploadFile(FileUploadMessage message);
}

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]     公共类MediaService:IDownloadMediaService,IUploadMediaService     {...... }

有什么建议?感谢。

0 个答案:

没有答案