WCF服务通过https返回404,但在http上正常工作

时间:2018-04-15 16:58:28

标签: c# wcf sharepoint

我正在尝试通过WCF进行大型文件上传服务。但是在https上它会返回404错误。我尝试了很多配置,但它没有帮助。什么可能是错的?

<bindings>
    <webHttpBinding>
        <binding name="UploadBinding" transferMode="Streamed"  maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            <security mode="Transport"></security>
        </binding>
    </webHttpBinding>
</bindings>
<services>
    <service behaviorConfiguration="UploadServiceBehaviour" name="MyNameSpace.UploadWebService">
        <endpoint address="" behaviorConfiguration="FileWebEndPoint" binding="webHttpBinding" bindingConfiguration="UploadBinding" contract="MyNameSpace.UploadWebService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
</services>
<behaviors>
    <endpointBehaviors>
        <behavior name="FileWebEndPoint">
            <webHttp />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="UploadServiceBehaviour">
            <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
    </serviceBehaviors>
</behaviors>

代码:

[OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "UploadFile", RequestFormat = WebMessageFormat.Json,
       ResponseFormat = WebMessageFormat.Json)]
    public void Upload(Stream fileContents)
    {
        string uploadFolder = @"C:\\test";

        string FilePath = Path.Combine(uploadFolder, Guid.NewGuid().ToString());
        int length = 0;
        using (FileStream writer = new FileStream(FilePath, FileMode.Create))
        {
            int readCount;
            var buffer = new byte[8192];
            while ((readCount = fileContents.Read(buffer, 0, buffer.Length)) != 0)
            {
                writer.Write(buffer, 0, readCount);
                length += readCount;
            }
        }
    }

当我向我的服务发出GET请求时(https://domain.com/_vti_bin/UploadWebService.svc/UploadFile)返回

  

没有频道正在积极收听&#34; https://domain.com/_vti_bin/UploadWebService.svc/UploadFile"。其中一个原因可能是错误的URI地址。确保将消息发送到的地址与服务侦听的地址匹配。

0 个答案:

没有答案