ExtJS Streaming通过WCF basicHttp服务

时间:2012-03-21 00:29:28

标签: wcf web-services extjs stream streaming

嗨Recetly我试图创建一个简单的web服务,能够通过ExtJS fileupload组件流式传输数据我已经用webHttp配置成功完成了这个,但是我想用basicHttpBinding或更好的wsHttpBinding来做。

我仍然得到415不支持的媒体类型,到目前为止我还没有找到答案。这是我的web.config:

    

  <basicHttpBinding>
    <binding maxReceivedMessageSize="67108864" transferMode="Streamed"/>
  </basicHttpBinding>

</bindings>

<behaviors>

    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="True"/>
        <serviceDebug includeExceptionDetailInFaults="False"/>
      </behavior>
    </serviceBehaviors>

</behaviors>


<services>
  <service name="WebApp.Service1" >
    <endpoint
      address=""
      binding="basicHttpBinding"
      contract="WebApp.Service1" />

  </service>
</services>

我的服务也被定义为

  [ServiceContract(Namespace = "")]
    public class Service1
    {
        [OperationContract]
        public bool DoWork(Stream data)
        {
            MultipartParser parser = new MultipartParser(data);
            StreamedResponse response = new StreamedResponse();
            response.Success = true;
            return true;
        }
    }

这仅用于测试目的,只是为了使其工作。实际上我想把它包装成一个Wrapped Request和响应,但这是另一个故事。

哦,是的,我的Ext代码是这样的:

var fp = new Ext.FormPanel({
    renderTo: 'fi-form',
    fileUpload: true,
    width: 500,
    frame: true,
    title: 'File Upload Form',
    autoHeight: true,
    bodyStyle: 'padding: 10px 10px 0 10px;',
    labelWidth: 50,
    defaults: {
        anchor: '95%',
        allowBlank: false,
        msgTarget: 'side'
    },
    items: [{
        xtype: 'fileuploadfield',
        id: 'form-file',
        emptyText: 'Select an image',
        fieldLabel: 'Photo',
        name: 'data',
        buttonText: '',
        buttonCfg: {
            iconCls: 'upload-icon'
        },
        listeners: {
            'fileselected': function () {

            if (fp.getForm().isValid()) {
                fp.getForm().submit({
                    url: '/Service1.svc/DoWork',
                    waitMsg: 'Uploading your photo...',

                    success: function (fp, o) {
                        msg('Success', 'Processed file "' + o.result.file + '" on the server');
                    }
                });
            }
        }

        }
    }],
    buttons: [{
        text: 'Save',}, {
        text: 'Reset',
        handler: function () {
            fp.getForm().reset();
        }
    }]
});

0 个答案:

没有答案