0

重複としてマークしないでください。何度もトライしましたがだめでした。

ストリーム コンテンツを取得し、画像を静的な名前で保存しています。しかし、画像ファイル名、拡張子パラメーターをその投稿 URL に送信できません。

私のコードは以下のようなものです

私の Web.Config

<?xml version="1.0" encoding="UTF-8"?>

<system.web>
    <compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
    <services>
        <service name="PracticeWcfService1.Service1" behaviorConfiguration="ServiceBehaviour">

            <endpoint name="RestClient"
                      address="RestType"
                      binding="webHttpBinding"
                      contract="PracticeWcfService1.IService1"
                      behaviorConfiguration="PracticeWcfService1.Service1ehaviour" >
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>

            <endpoint name="RestClientWithSecure"
                      address="RestTypeWithSecure"
                      binding="webHttpBinding"
                      contract="PracticeWcfService1.IService1"
                      bindingConfiguration="PracticeWcfService1.Services.ClientServicesEndpointBinding"
                      behaviorConfiguration="PracticeWcfService1.Service1ehaviour" >
                <!--bindingConfiguration used to give the security mode like HTTPS-->
                <!--behaviorConfiguration used to define type of endpointBehaviors-->
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>

            <endpoint  name="SoapClient"
                address="SoapType"
                binding="basicHttpBinding"
                contract="PracticeWcfService1.IService1">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>

            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>

            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:33333/Service1.svc" />
                </baseAddresses>
            </host>

        </service>
    </services>
    <bindings>
        <webHttpBinding>
            <binding name="PracticeWcfService1.Services.ClientServicesEndpointBinding" transferMode="Streamed" maxBufferSize="2147483647"
                     maxReceivedMessageSize="2147483647" openTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:10:00">
                <security mode="Transport">
                </security>
            </binding>
        </webHttpBinding>
    </bindings>
    <behaviors>
        <endpointBehaviors>
            <behavior name="PracticeWcfService1.Service1ehaviour">
                <webHttp/> <!--helpEnabled="true" automaticFormatSelectionEnabled="true"-->
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehaviour">
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances="250"/>
            </behavior>

        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="true" />
</system.webServer>

IService1 インターフェイス:

[OperationContract]
        string RecieveImage(string fileName, Stream ImageStream);

Service1.svc.cs 内

    [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "UploadFile/{fileName}")] 
            public string RecieveImage(string fileName, Stream ImageStream)
                using (FileStream fs = new FileStream(@"\\192.168.1.2\Common\Pratap\" + fileName + ".jpeg", FileMode.Create))
                {
                    ImageStream.CopyTo(fs);
                    ImageStream.Close();
                }
            }
            catch (Exception ex)
            {
                throw new WebFaultException<string>(ex.Message, System.Net.HttpStatusCode.BadRequest);
            }
            return "Successsfully recieved.";

サービス ビュー マークアップ:

<%@ ServiceHost Language="C#" Debug="true" Service="PracticeWcfService1.Service1" CodeBehind="Service1.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory"%>

私の問題をクリアしてください...

4

0 に答える 0