WCF Service SSRS works via URL on my browser but not on WCF Client?

165 Views Asked by At

On my client with NTLM authentication with username and password I can login on browser and but reports via WCF SSRS consuming don't work.

Please see the code attached.

Generate Report Function

 public byte[] GenerateReport(string reportName, ReportingService.ExportFormat format,IList<MyApplicationService.ParameterValue> parameters, out string mimeType)
        {
            byte[] output;
            string extension, encoding;
            const string reportDirectory = "/Reports/";
            MyApplicationService.Warning[] warnings;
            string[] streamIds;


     
                 ReprotServ.ReportExporter.Export("basicHttpEndpoint", new NetworkCredential("Username", "Password"),
              reportDirectory + reportName, parameters.ToArray(), format, out output, out extension, out mimeType, out encoding, out warnings, out streamIds);

            return output;
        }



public static void Export(
                      string wcfEndpointConfigName, System.Net.NetworkCredential clientCredentials, string report, ParameterValue[] parameters,
                      ExportFormat format, out byte[] output, out string extension, out string mimeType, out string encoding, out Warning[] warnings, out string[] streamIds)

        {
            var webServiceProxy = new MyApplicationService.ReportExecutionServiceSoapClient(wcfEndpointConfigName);

            try
            {

                webServiceProxy.ClientCredentials.Windows.AllowedImpersonationLevel =
                             System.Security.Principal.TokenImpersonationLevel.Impersonation;
                webServiceProxy.ClientCredentials.Windows.ClientCredential = clientCredentials;

                // Init Report to execute
                ServerInfoHeader serverInfoHeader;
                ExecutionInfo executionInfo;
                ExecutionHeader executionHeader = webServiceProxy.LoadReport(null, report, null, out serverInfoHeader, out executionInfo);


                // Attach Report Parameters
                webServiceProxy.SetExecutionParameters(executionHeader, null, parameters, null, out executionInfo);

                // Render
                serverInfoHeader =
                    webServiceProxy.Render(executionHeader, null, GetExportFormatString(format), null,
                                           out output, out extension, out mimeType, out encoding, out warnings,
                                           out streamIds);
                webServiceProxy.Close();
            }
            catch (CommunicationException e)
            {

                webServiceProxy.Abort();
                throw new CommunicationException(e.Message);


            }
            finally
            {
                webServiceProxy.Close();

            }

Web Config File

    <system.serviceModel>
    <bindings>
      <basicHttpBinding>
          <binding name="ReportExecutionServiceSoap" receiveTimeout="10:00:00" sendTimeout="10:00:00" allowCookies="true" maxReceivedMessageSize="5242880">
              <security mode="TransportCredentialOnly">
                  <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
                  <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
          </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://xyz:80/ReportServer/ReportExecution2005.asmx" 
        binding="basicHttpBinding" bindingConfiguration="ReportExecutionServiceSoap"
        contract="MyApplicationService.ReportExecutionServiceSoap" name="basicHttpEndpoint" />
    </client>
  </system.serviceModel>

For More clarification here is the picture attached with error message. enter image description here

Things which I have done.

  1. Stopped using using keyword.. // Nothing worked .
  2. Service is working on my browser so how can it be faulted.
  3. Tried .Net Tracing didn't get any help since the error message remain the same.
  4. Tried using WCFTestClient.exe also data is there but via client writing code it gives me error.
  5. State is sometimes Opened, Mostly faulted but endpoint written via quick watch shows its null as shown in picture below. But I get something in URL address.

Can some one guide me. I been stuck here for weeks.

0

There are 0 best solutions below