0

我一直在努力解决这个错误:

接收对 ....8332/Service1.svc 的 HTTP 响应时出错。这可能是由于服务端点绑定未使用 HTTP 协议。这也可能是由于服务器中止了 HTTP 请求上下文(可能是由于服务关闭)。有关更多详细信息,请参阅服务器日志。

我追踪了错误,显然这与绑定或连接有关,我无法弄清楚如何解决。..我把课程和配置文件放在下面。请指导我。提前谢谢。

    [DataContract]
    public class filepack
    {
        string  filesize = "0";
        int  accesspermitid =0;
         System.IO.Stream str ;


         [DataMember]
         public System.IO.Stream Filestr
         {
             get { return str; }
             set { str = value; }
         }

        [DataMember]
        public string Filesize
        {
            get { return filesize; }
            set { filesize = value; }
        }

        [DataMember]
        public int Accesspermitid
        {
            get { return accesspermitid; }
            set { accesspermitid = value; }
        }


    }

  <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />

        </startup>

        <system.serviceModel>

            <behaviors>
                <endpointBehaviors>

                    <behavior name="debugbeh">
                        <dataContractSerializer />
                    </behavior>
                </endpointBehaviors>
            </behaviors>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_IService1" maxBufferSize="500000000"
                        maxReceivedMessageSize="500000000">
                        <security mode="None">
                            <message algorithmSuite="Default" />
                        </security>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:8332/Service1.svc" behaviorConfiguration="debugbeh"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
                    contract="vcpservice.IService1" name="BasicHttpBinding_IService1" />
            </client>

        </system.serviceModel>
    </configuration>







    <?xml version="1.0"?>
    <configuration>

      <system.diagnostics>
        <trace autoflush="true" />
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true">
            <listeners>
              <add name="sdt"
                  type="System.Diagnostics.XmlWriterTraceListener"
                  initializeData="c:\\logclientHOST.svclog"  />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>

      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="mybinding" closeTimeout="00:10:00" maxBufferPoolSize="52428800"
              maxBufferSize="500000000" maxReceivedMessageSize="500000000" />
          </basicHttpBinding>
        </bindings>
        <diagnostics>
          <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
        </diagnostics>
        <behaviors>
          <endpointBehaviors>
            <behavior name="NewBehavior0">
              <dataContractSerializer />
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"
                httpGetBinding="webHttpBinding" httpGetBindingConfiguration="" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <dataContractSerializer maxItemsInObjectGraph="2147483646" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>

    </configuration>
4

2 回答 2

1

您无法发送流。您需要在发送之前将流具体化为一个真实的数据对象(例如字符串或字节数组),或者如果您真的想要流式传输(我怀疑),您可以阅读this

于 2013-03-19T15:46:21.917 回答
0

这个问题似乎可以通过从类中删除流并单独返回来解决!但我不知道它如何帮助解决它!

于 2013-03-24T16:14:01.990 回答