C# WCF服务中未接收到从Soap UI发送的附件数据

C# WCF服务中未接收到从Soap UI发送的附件数据,c#,wcf,soapui,soap-client,mtom,C#,Wcf,Soapui,Soap Client,Mtom,我有一个查找数据流的wcf服务 [MessageContract] public class NextService : INextService { [WebInvoke(Method = "POST", UriTemplate = "*")] public void Upload(Stream data) { try { _log.InfoFormat("--

我有一个查找数据流的wcf服务

[MessageContract]
public class NextService : INextService
{  
    [WebInvoke(Method = "POST", UriTemplate = "*")]
    public void Upload(Stream data)
    {
        try
        {
            _log.InfoFormat("-------------{0}------------------------------", data);
            


            var request = WebOperationContext.Current.IncomingRequest;
            WebHeaderCollection headers = request.Headers;
            _log.InfoFormat(request.Method + " ");// + request.UriTemplateMatch.RequestUri.AbsolutePath);
            foreach (string headerName in headers.AllKeys)
            {
                _log.InfoFormat(headerName + ": " + headers[headerName]);
            }

            if (File.Exists(@"c:\\test\\ViewDocumentOp.pdf"))
                File.Delete(@"c:\\test\\ViewDocumentOp.pdf");
            using (FileStream fs = new FileStream(@"c:\\test\\ViewDocumentOp.pdf", FileMode.CreateNew, FileAccess.Write))
            {
                CopyStream(data, fs);
            }

            StreamReader bodyReader = new StreamReader(data);
            string bodyString = bodyReader.ReadToEnd();
            int length = bodyString.Length;
            _log.InfoFormat("-------------------------------------------------------");

        }
        catch (Exception ex)
        {
            _log.ErrorFormat(" Error in UploadDoc {0} Message : {1}", ex.StackTrace, ex.Message);
        }
    }
下面是界面

 [ServiceContract]
    public interface INextService
    {
        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]
            void Upload(Stream data);
    }
我在绑定中添加了带有MTOM详细信息的webconfig

       <basicHttpBinding>
                <binding name="Encode" messageEncoding="Mtom" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
                         transferMode="Streamed">
              </binding>                  
         </basicHttpBinding>
    <service behaviorConfiguration="NextServiceBehavior" name="SupportingDocsFacade.NextService">
            <endpoint address="/Upload" binding="basicHttpBinding" bindingConfiguration="Encode"
              name="Basic" contract="SupportingDocsFacade.INextGenService" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
          </service>

我使用soapui来调用它 还有一个附件。SoapUI中显示的原始数据具有边界数据 我已在请求属性中启用了MTOM,如下所示

有些人认为数据没有到达Web服务。。上载服务中的日志打印为

-------------System.ServiceModel.Dispatcher.StreamFormatter+MessageBodyStream------------------------------


首先,我们不能直接将数据(调用服务)发布到Basichttpbinding创建的服务地址。这仅适用于Webhttpbinding创建的WCF rest样式服务。

如果我们使用Basichttpbinding来创建服务,我们应该使用基址来传递流数据,如文档中所述。

我们利用内联文件传递stream参数。请参见下面的屏幕截图。

如果有什么我能帮忙的,请随时告诉我