none
WCF REST json - write byte[] to shared folder RRS feed

  • Question

  • <?xml version="1.0"?>
    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>  
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
          <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </modules>    
      </system.webServer>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- This behavior enables API Key Verification -->
              <serviceAuthorization serviceAuthorizationManagerType="xxxmMobile.xxxmMobileAuthorizationManager, xxxmMobile"   />
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <standardEndpoints>
          <webHttpEndpoint>
            <!-- 
                Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
                via the attributes on the <standardEndpoint> element below
            -->
            <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json"
                              maxBufferPoolSize="2147483644"  maxBufferSize="2147483644" maxReceivedMessageSize="2147483644"
                               transferMode="Buffered"
                              >
              <readerQuotas maxDepth="64" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxArrayLength="2147483647"
                           ></readerQuotas>
            </standardEndpoint>
          </webHttpEndpoint>
        </standardEndpoints>
      </system.serviceModel>
    </configuration>

    hi, experts, my WCF REST json is located in a virtual directory in an application pool in IIS.

    the IIS is using anonymous because the wcf rest json server is for mobile devices (android + ios).

    android and ios devices post the domain, user id and password in json format.

    my customized serviceAuthorizationManager passes the domain , user id and password to domain controller to authenticate. 

    the problem is:

    mobile post files in base64 string, the wcf rest json server converts base 64 string to byte[] and write to a shared folder using another set of domain , user id and password

    I tried several coding to write files but not successful. 

    I tried to add web.config. it returns internal 500

    <system.web>
                <identity impersonate="true"                 
    />
             </authentication>
    </system.web>

    by my case, is it possible to impersonate and write files to share folder?


    • Edited by delaynomore Thursday, March 6, 2014 10:05 AM
    Thursday, March 6, 2014 10:03 AM

Answers

  • Hi,

    Since you meet the 500 error, please enable the wcf tracing to find error information.

    The following configuration taken from MSDN can be applied to enable tracing on your WCF service.

    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
            <listeners>
                 <add name="xml"/>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
            <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="Error.svclog" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>

    To view the log file, you can use "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\SvcTraceViewer.exe".

    Thanks.

    Friday, March 7, 2014 9:56 AM
  • Hi,

    From your description, I know that you want to write to a shared folder using another set of domain, user id and password. Then it should be something related with the security. 
    May I know whether your IT has setup trust relationship between the two domains? If not, based on my experience one domain's credential is not accepted in the other domain. Please try to setup trust relationship.

    For more information, please try to refer to:
    #Active Directory Domains and Trusts:
    http://technet.microsoft.com/en-us/library/cc770299.aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 13, 2014 7:07 AM
    Moderator

All replies

  • Hi,

    Since you meet the 500 error, please enable the wcf tracing to find error information.

    The following configuration taken from MSDN can be applied to enable tracing on your WCF service.

    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
            <listeners>
                 <add name="xml"/>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
            <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="Error.svclog" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>

    To view the log file, you can use "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\SvcTraceViewer.exe".

    Thanks.

    Friday, March 7, 2014 9:56 AM
  • Hi,

    From your description, I know that you want to write to a shared folder using another set of domain, user id and password. Then it should be something related with the security. 
    May I know whether your IT has setup trust relationship between the two domains? If not, based on my experience one domain's credential is not accepted in the other domain. Please try to setup trust relationship.

    For more information, please try to refer to:
    #Active Directory Domains and Trusts:
    http://technet.microsoft.com/en-us/library/cc770299.aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 13, 2014 7:07 AM
    Moderator