Basics of CSS to modify your profile at M2E

Here is my effort to explain how to use CSS to modify your profile.

For your profile you will like to modify it in two ways either by giving some background image or by giving it some background color.

For background image:

  • You can specify maximum two images
    • One that will appear behind Your Profile Name bar
    • Second that will appear behind the rest of your profile
    • You can specify one image to appear behind above both as well
    • So select your image
    • Either upload it to some site like photobucket etc or if it is on some site and you are sure that you can use it from there, save the link with you.

For background color:

Now you have the things that we require so lets jump in to CSS. In CSS we define classes that get implemented on different sections of page. We will not go in to CSS details but will look in to CSS that can be used at M2E. In your Edit Profile layout, click any layout other than default and in text box above you will get CSS, lets play with it so that you can have your own look and feel.

Any thing that is written in between /* and */ are comments and don’t affect the layout.

First of all in our CSS we have

body {
background:url(http://www.mysite.com/mypic.jpg) center repeat-y;
/* custom cursor for IE, Firefox */
cursor: url(http://sites.google.com/site/ikbalouch/myself/icur.cur), auto;
/* scrollbar colours */
scrollbar-arrow-color:#43260C;
scrollbar-track-color:#E9E2CF;
scrollbar-shadow-color:#E9E2CF;
scrollbar-face-color:#E9E2CF;
scrollbar-highlight-color:#E9E2CF;
scrollbar-darkshadow-color:#ffffff;
scrollbar-3dlight-color:#ffffff;
padding-top: 0px; /* distance between top of page and content */
padding-bottom: 0px; /* distance between bottom of page and content */
}

body is the main class that get implemented at the whole page,

In above class the important properties is background:

For background if you want to have some color than simply make it:

Background: #FFFFFF     /* Replace FFFFFF with hexcode for your color */

Else if you want some image

background:url(http://www.mysite.com/mypic.jpg) /* Replace image url with url of image u selected */

Other class that we need to look into is:

div.content {
background: url(http://www.mysite.com/mypic2.jpg);
padding: 6px;
}

This class applies to your entire profile except the header bar that contains your Profile Name, so if you want two different images one for profile name bar and other for rest of the profile than in above class give url of the image you want to appear for main profile else if you want to let the image that was specified in body class than make background: transparent;

Other important class is:

div, td {
background: transparent;
font-family: Arial; /* almost global font */
font-size: 11px;
color: #6A6962;
}

In this class make background transparent and you can change the font or size of font or color of font for your profile.

Now we need to look in to:

div.page_header {
background: url(http://www.mysite.com/mypic2.jpg) repeat-x;
text-align: center;
line-height: 42px;
font-size: 16px;
font-weight: bold;
font-style: italic;
text-decoration: underline;
color: #000000;
background-color: #FFFFFF;
padding: 0px 0px 0px 0px;
}

This class applies to the Profile Name bar, if you want to have different image for it specify it in background property otherwise make it background: transparent;

text-align property let you specify that either you want to see your name in center, left or right side.

You can specify font styles, weight, decoration in above class, background-color will be applied, if for instance the image you specified doesn’t exist than background-color will be visible.

Another class of our interest is:

td.header {
padding: 2px 2px 2px 2px;
border: 1px dotted #000000;
border-bottom: none;
background-image: none;
background-repeat: repeat-x;
color: #FFFFFF;
background: #FFFFFF;
background: url(http://www.mysite.com/mypic2.jpg);
}

This class applies on the titles of boxes that appear under your picture, so if you want to give them some other image as background specify its url in last line otherwise remove this line and specify the background color in the background line above last line.

For the tabs like Profile, Comments, Gifts etc if you want some image to appear in them than set the background property as background:url(http://www.mysite.com/image.jpg); in td.profile, td.profile_tab a, td.profile_tab a:hover and td.profile_tab2 a, td.profile_tab2 a:hover classes. If you want to have some color simply use background: #FFFFF and if nothing than make background: transparent.

td.profile_photo applies to your display image.

I hope I have explained most of the things that you need to customize your profile, if still you find any confusion, post it here or message me or write on my profile, I will surely get you out of it.

Advertisements

CSharp Calling Different Web Services

Note: I have moved to blog at my own domain, so kindly visit this post over there for recent updates or comments. http://www.imranbalouch.com/blog/index.php/2010/05/csharp-calling-different-web-services/

If you are developing an application that has to call different webservices and at run time the application get to know that which method of which web service it has to call than you can use the following code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Security.Permissions;
using System.Web.Services.Description;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace CallbackWindowsService
{
public class DynamicWebService
{
[SecurityPermissionAttribute(SecurityAction.Demand, Unrestricted = true)]
internal static ReturnedObject CallWebService(string webServiceAsmxUrl, string userName, string password, string serviceName, string methodName, object[] args)
//internal static object CallWebService(string webServiceAsmxUrl, string serviceName, string methodName, object[] args)
{
System.Net.WebClient client = new System.Net.WebClient();
ReturnedObject retObj = new ReturnedObject();
try
{
if (userName.Length > 0)
{
client.Credentials = new NetworkCredential(userName, password);
}
System.IO.Stream stream = null;
// Connect To the web service
try
{
stream = client.OpenRead(webServiceAsmxUrl + “?wsdl”);
}
catch (Exception ex)
{
//”Unable to connect to the remote server”
retObj.ServiceIssues = Convert.ToInt64(ServiceIssues.ServiceNotAvailable);
retObj.ErrorMessage = ex.Message;
retObj.ReturnObject = null;
return retObj;
}
// Now read the WSDL file describing a service.
ServiceDescription description = ServiceDescription.Read(stream);
///// LOAD THE DOM /////////
// Initialize a service description importer.
ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
importer.ProtocolName = “Soap12”; // Use SOAP 1.2.
//importer.ProtocolName = “default”;
importer.AddServiceDescription(description, null, null);
// Generate a proxy client.
importer.Style = ServiceDescriptionImportStyle.Client;
// Generate properties to represent primitive values.
importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;
// Initialize a Code-DOM tree into which we will import the service.
CodeNamespace nmspace = new CodeNamespace();
CodeCompileUnit unit1 = new CodeCompileUnit();
unit1.Namespaces.Add(nmspace);
// Import the service into the Code-DOM tree. This creates proxy code that uses the service.
ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1);
if (warning == 0) // If zero then we are good to go
{
// Generate the proxy code
CodeDomProvider provider1 = CodeDomProvider.CreateProvider(“CSharp”);
// Compile the assembly proxy with the appropriate references
string[] assemblyReferences = new string[5] { “System.dll”, “System.Web.Services.dll”, “System.Web.dll”, “System.Xml.dll”, “System.Data.dll” };
CompilerParameters parms = new CompilerParameters(assemblyReferences);
CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1);
// Check For Errors
if (results.Errors.Count > 0)
{
String errMessage = String.Empty;
foreach (CompilerError oops in results.Errors)
{
errMessage += oops.ErrorText + “…”;
}
retObj.ServiceIssues = Convert.ToInt64(ServiceIssues.AssemblyCompilingError);
retObj.ErrorMessage = errMessage;
retObj.ReturnObject = null;
return retObj;
}
// Finally, Invoke the web service method
object wsvcClass = results.CompiledAssembly.CreateInstance(serviceName);
MethodInfo mi = wsvcClass.GetType().GetMethod(methodName);
object obj = mi.Invoke(wsvcClass, args);
retObj.ReturnObject = obj;
retObj.ServiceIssues = Convert.ToInt64(ServiceIssues.ProcessedSuccessfully);
}
else
{
retObj.ServiceIssues = Convert.ToInt64(ServiceIssues.NullObject);
retObj.ErrorMessage = “Response Object cannot be created.”;
retObj.ReturnObject = null;
}
return retObj;
}
else
{
retObj.ServiceIssues = Convert.ToInt64(ServiceIssues.ServiceImportWarning);
String errormsg = String.Empty;
switch (warning)
{
case ServiceDescriptionImportWarnings.NoCodeGenerated:
errormsg = “Service Warning: No Code Generated”;
break;
case ServiceDescriptionImportWarnings.NoMethodsGenerated:
errormsg = “Service Warning: No Methods Generated”;
break;
case ServiceDescriptionImportWarnings.RequiredExtensionsIgnored:
errormsg = “Service Warning: Required Extensions Ignored.”;
break;
case ServiceDescriptionImportWarnings.WsiConformance:
errormsg = “Service Warning: Service does not conform to the WS-I Basic Profile.”;
break;
default:
errormsg = “Service Warning: Unknown warning occured with code, ” + warning.ToString() + “.”;
break;
}
retObj.ErrorMessage = errormsg;
retObj.ReturnObject = null;
return retObj;
}
}
catch (Exception ex)
{
retObj.ServiceIssues = Convert.ToInt64(ServiceIssues.UnknownException);
retObj.ErrorMessage = ex.Message;
retObj.ReturnObject = null;
return retObj;
}
}
public DynamicWebService()
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(SSLResult);
}
public Boolean SSLResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
}
public class ReturnedObject
{
public ReturnedObject()
{
}
public object ReturnObject
{
get;
set;
}
public Int64 ServiceIssues
{
get;
set;
}
public String ErrorMessage
{
get;
set;
}
}
public enum ServiceIssues
{
ServiceNotAvailable = 1,
ProcessedSuccessfully = 2,
ClientReturnedNULLObject = 3,
ServiceImportWarning = 4,
AssemblyCompilingError = 5,
UnknownException = 6,
NullObject = 7
}
}

If the webservice you are calling is accepting some object as input parameter you will get an exception that YourObjectType can not be converted to YourObjectType’.

To resolve this issue, replace the following line:

object obj = mi.Invoke(wsvcClass, args);

with

ParameterInfo[] pm = mi.GetParameters();
object ob;
object[] y = new object[1];
YourObjectType objResponse = null;
if (args.Length > 0)
{
objResponse = (YourObjectType)args[0];
}
if (objResponse != null)
{
foreach (ParameterInfo paraminfo in pm)
{
ob = results.CompiledAssembly.CreateInstance(paraminfo.ParameterType.Name);
//Some Junk Logic to get the set the values to the properties of the custom Object
foreach (PropertyInfo propera in ob.GetType().GetProperties())
{
if (propera.Name == “Property1″)
{
propera.SetValue(ob, objResponse.Property1, null);
}
else if (propera.Name == ” Property2″)
{
propera.SetValue(ob, objResponse.Property2, null);
}
}
y[0] = ob;
}
}
object obj = mi.Invoke(wsvcClass, y);

In this above code you will be getting parameters of method and loop on them, create object of the type which WebService is expecting, assign values to the object and call Invoke method.

Happy Development

=================================================================================
Updated On: 20th July 2011
An Update in this context, recently i came across a web service that was written in php and was using Soap as protocol, so the above code was generating NoCodeGeneratedWarning, so i gave it a quick fix.
Before line
if (warning == 0) // If zero then we are good to go
I placed this line of code,
if (warning == ServiceDescriptionImportWarnings.NoCodeGenerated)
{
importer.ProtocolName = “Soap”;
warning = importer.Import(nmspace, unit1);
}
It was the quickest fix i can do for it, however we can put this protocol name in database for each service and assign it accordingly.
Cheers
===============================================================================

SQL CLR UDF returning result set

Note: I have moved to blog at my own domain, so kindly visit this post over there for recent updates or comments. http://www.imranbalouch.com/blog/index.php/2010/05/sql-clr-udf-returning-result-set/

SQL CLR Integration is a very nice feature provided by Microsoft especially if you need to do some complex calculations or deal with objects.

Today we will be creating a User Defined Function,UDF, using CLR, which will return a result set/table and hence will be a Table Value Function, TVF.

Our UDF will be accepting a query parameter, which will hit database and get some XML values and later on deserialize them and return the values in table.

First of all in VS create a SQL Project and add a User Defined Function in it.

public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction(DataAccess = DataAccessKind.Read,
FillRowMethodName = “getDeserializedData_Fill”,
// define columns returned
TableDefinition = “ResquestId bigint, RequestDetailId bigint, Name nvarchar(50), Address nvarchar(50 “
)]
public static IEnumerable getDeserializedData(String sqlQuery)
{
ArrayList resultCollection = new ArrayList();
if (sqlQuery == null || sqlQuery == “”)
{
sqlQuery = “SELECT TOP (10) R.REQUESTID AS REQUESTID, R.REQUESTTYPEID_FK AS REQUESTTYPEID, REQUESTDETAILID, RD.XMLPACKET FROM REQUESTS1 R WITH (NOLOCK)JOIN REQUESTDETAILS1 RD WITH (NOLOCK) ON RD.REQUESTID_FK = R.REQUESTID WHERE RD.REQUESTSTATUSIDINTERNAL_FK = 1”;
}
using (SqlConnection conection = new SqlConnection(“context connection = true;”))
using (SqlCommand command = new SqlCommand(sqlQuery, conection))
{
conection.Open();
SqlDataReader dReader = command.ExecuteReader();
if (dReader != null && dReader.HasRows)
{
DataTable dTable = new DataTable();
dTable.Load(dReader);
foreach(DataRow dRow in dTable.Rows)
{
resultCollection.Add(GetGenericClass(dRow));
}
}
}
return resultCollection;
}

In above code we created a UDF with DataAccessKind.Read to tell that our function will be accessing data only to read it, Fill row method tells the name of method which will be populating the rows of our table and Table Definition tells that which columns will be present in the returning table.

getDeserializedData is our main function that will accept a String type parameter named query, they query which will get data from database. Any UDF that is a TVF must have return type as IEnumerable. Laterally we opened a connection and fetched data from database, and pass one by one row to our GetGenericClass method which return an object of our generic class which we than add in to an ArrayLIst. Our GenricClass is as

using System;
using System.Collections.Generic;
using System.Text;
namespace CLRSQLInregration
{
[Serializable]
public class GenericClass
{
public Int64 ResquestId
{
get;
set;
}
public Int64 RequestDetailId
{
get;
set;
}
public String Name
{
get;
set;
}
public String Address
{
get;
set;
}
}
}

Another Class that we will use is CustomerClass like:

using System;
using System.Collections.Generic;
using System.Text;
namespace CLRSQLInregration
{
[Serializable]
public class CustomerClass
{
public String Name
{
get;
set;
}
public String Address
{
get;
set;
}
}
}

We have marked the class as Serializable, so that we can serialize and deserialize the objects of this class.

Our GetGenericClass method is like:

public static GenericClass GetGenericClass(DataRow dRow)
{
GenericClass objGeneric = new GenericClass();
objGeneric.ResquestId = Convert.ToInt64(dRow[“REQUESTID”]);
objGeneric.RequestDetailId = Convert.ToInt64(dRow[“REQUESTDETAILID”]);
InternalResponse objResponse = null;
if (dRow[“XMLPACKET “] != DBNull.Value)
objResponse = (CustomerClass)Serializer.DeSerializeObject(Convert.ToString(dRow[“XMLPACKET “]), typeof(CustomerClass));
if (objResponse != null)
{
objGeneric.Name = objResponse.Name;
objGeneric.Address = objResponse.Address;
}
}

This method simply deserializes the XML Packet in the row and take values from the object and assign values to our GenericClass object.

Our datafill method is be like:

public static void getDeserializedData_Fill(object obj, out Int64 ResquestId, out Int64 RequestDetailId, out String Name, out String Address)
{
GenericClass objResponse = (GenericClass)obj;
if (objResponse != null)
{
ResquestId = objResponse.ResquestId;
RequestDetailId = objResponse.RequestDetailId;
Name = objResponse.Name;
Address = objResponse.Address;
}
}

This fill method will execute when return resultCollection; code of getDeserializedData method is called.

After all this u need to deploy the CLR assembly and call the UDF and here you go.

Whenever Serialization is involved in CLR, we need to create a Serializer class for our project as well, which can be created by using sgen.exe file of VS or in project properties, go to build events and in post build event command line specify the following line:

“D:Program FilesMicrosoft Visual Studio 8SDKv2.0Binsgen.exe” /force “$(TargetPath)”

It will create the serializer class for your project which you have to add in your CLR assemblies of SQL.

Creating Report Template in Visual Studio

Note: I have moved to blog at my own domain, so kindly visit this post over there for recent updates or comments. http://www.imranbalouch.com/blog/index.php/2010/04/creating-report-template-in-visual-studio/

We have been doing report development using SQL Server 2008 Reporting Services and all of reports normally followed a standard pattern, so I thought to design a report template so that we can have all standards while developing a new report. Following are the steps that I found from net for it:

  • Add a new report to your project
  • Using the report designer place any objects (text boxes, tables, lines, etc) on the report that you want as a template.
  • Give the report a name (anything that you can remember in the future, for instance if you want landscape reports and you create a landscape template you should then call the report LandscapeTemplate.rdl)
  • Save this .rdl file to: C:Program FilesMicrosoft Visual Studio 9.0Common7IDEPrivateAssembliesProjectItemsReportProject

The next time you add a report item you will notice this item in the Templates section.

For older version of SSRS use the Microsoft Visual Studio 8 directory:C:Program FilesMicrosoft Visual Studio 8Common7IDEPrivateAssembliesProjectItemsReportProject

And here you go, ALL IZ WELL… (Y)

Calling SQl2008 Reporting Server WebService Programmatically

Note: I have moved to blog at my own domain, so kindly visit this post over there for recent updates or comments. http://www.imranbalouch.com/blog/index.php/2010/04/calling-sql2008-reporting-server-webservice-programmaticall/

In our web application we have a lot of reports and many of them take hell lot of time, so we decided to make a page from where user can select report and provide parameters and save the request, later on our windows service can get report from sql reporting server’s web service and email the report in desired format to the user.

While doing a test, I created a windows service and used following code to get the report:

ReportExecutionService.ReportExecutionServiceSoapClient rsExec = new ReportingServiceTesting.ReportExecutionService.ReportExecutionServiceSoapClient();

      System.Net.NetworkCredential clientCredentials = new System.Net.NetworkCredential("me", "me", "me");
      rsExec.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
      rsExec.ClientCredentials.Windows.ClientCredential = clientCredentials;

      string historyID = "";
      string reportPath = "Reports/MyOrders";

      ReportExecutionService.ExecutionInfo execInfo = new ReportExecutionService.ExecutionInfo();
      ReportExecutionService.TrustedUserHeader trusteduserHeader = new ReportingServiceTesting.ReportExecutionService.TrustedUserHeader();

      ReportExecutionService.ExecutionHeader execHeader = new ReportExecutionService.ExecutionHeader();
      ReportExecutionService.ServerInfoHeader serviceInfo = new ReportingServiceTesting.ReportExecutionService.ServerInfoHeader();
      rsExec.LoadReport(trusteduserHeader, reportPath, historyID, out serviceInfo, out execInfo);

      ReportExecutionService.ParameterValue[] executionParams;
      executionParams = new ReportExecutionService.ParameterValue[5];
      executionParams[0] = new ReportExecutionService.ParameterValue();
      executionParams[0].Name = "@pCompanyId";
      executionParams[0].Value = "1";
      executionParams[1] = new ReportExecutionService.ParameterValue();
      executionParams[1].Name = "@pUserId";
      executionParams[1].Value = "1";
      executionParams[2] = new ReportExecutionService.ParameterValue();
      executionParams[2].Name = "@pLanguageId";
      executionParams[2].Value = "1";
      executionParams[3] = new ReportExecutionService.ParameterValue();
      executionParams[3].Name = "@pOrganizationId";
      executionParams[3].Value = "1";
      executionParams[4] = new ReportExecutionService.ParameterValue();
      executionParams[4].Name = "@pThemeId";
      executionParams[4].Value = "1";

      rsExec.SetExecutionParameters(execHeader,trusteduserHeader, executionParams, "en-us",out execInfo);

      //string historyID = null;
      string deviceInfo = null;
      string extension;
      string encoding;
      string mimeType;
      ReportExecutionService.Warning[] warnings = new ReportingServiceTesting.ReportExecutionService.Warning[1];
      warnings[0] = new ReportingServiceTesting.ReportExecutionService.Warning();
      string[] streamIDs = null;
      string format = "EXCEL";
      Byte[] result;
      rsExec.Render(execHeader,trusteduserHeader, format,
        deviceInfo,out result, out extension,
        out mimeType, out encoding,
        out warnings, out streamIDs);
      String fileName = "me.xls";
      FileStream stream = File.OpenWrite(fileName);
      stream.Write(result, 0, result.Length);
      stream.Close();

and our configuration file has settings like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="ReportExecutionServiceSoap" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
      <customBinding>
        <binding name="ReportingService2005Soap12">
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
            messageVersion="Soap12" writeEncoding="utf-8">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </textMessageEncoding>
          <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
            maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
            realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
            useDefaultWebProxy="true" />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="http://myServer/ReportServerSQL2008/ReportExecution2005.asmx"
        binding="basicHttpBinding" bindingConfiguration="ReportExecutionServiceSoap"
        contract="ReportExecutionService.ReportExecutionServiceSoap"
        name="ReportExecutionServiceSoap" />
    </client>
  </system.serviceModel>
</configuration>

When I run my windows service I came across folloing error:

System.ServiceModel.FaultException: System.Web.Services.Protocols.SoapException: An internal error occurred on the report server. See the error log for more details. —> Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: An internal error occurred on the report server. See the error log for more details. —> System.ArgumentNullException: Value cannot be null.
Parameter name: value
at Microsoft.ReportingServices.WebServer.ReportExecutionService.Initialize(TrustedUserHeader userHeader, String item)
at Microsoft.ReportingServices.WebServer.ReportExecutionService.LoadReport(String Report, String HistoryID, ExecutionInfo& executionInfo)

Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

I checked the log reports but couldn’t find any clue, I did googling but couldn’t find any solid solution and after getting tips and tricks from different posts I found following things I needed to do in:

historyId = null;

If you are getting some error regarding SnapshotId, be sure that you have passed historyId as null.

After load report method:
execHeader.ExecutionID = execInfo.ExecutionID;

assign executionId of your current execution to header so that it can be used in other steps.

and while rendering the report through Render method pass TrustedUserHeader parameter as null.

This was the most hectic thing to find because System was throwing null value exception and it got fixed when I passed TrustedUserHeader as null. 😀

After doing these tweaks the windows service got the report from the web service.

ReportExecutionService.ReportExecutionServiceSoapClient rsExec = new ReportingServiceTesting.ReportExecutionService.ReportExecutionServiceSoapClient();

      System.Net.NetworkCredential clientCredentials = new System.Net.NetworkCredential("me", "me", "me");
      rsExec.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
      rsExec.ClientCredentials.Windows.ClientCredential = clientCredentials;

      string historyID = "";
      string reportPath = "/V3/Operations/OrderssByCustomers";

      ReportExecutionService.ExecutionInfo execInfo = new ReportExecutionService.ExecutionInfo();
      ReportExecutionService.TrustedUserHeader trusteduserHeader = new ReportingServiceTesting.ReportExecutionService.TrustedUserHeader();

      ReportExecutionService.ExecutionHeader execHeader = new ReportExecutionService.ExecutionHeader();
      ReportExecutionService.ServerInfoHeader serviceInfo = new ReportingServiceTesting.ReportExecutionService.ServerInfoHeader();
      rsExec.LoadReport(trusteduserHeader, reportPath, historyID, out serviceInfo, out execInfo);

      ReportExecutionService.ParameterValue[] executionParams;
      executionParams = new ReportExecutionService.ParameterValue[5];
      executionParams[0] = new ReportExecutionService.ParameterValue();
      executionParams[0].Name = "@pCompanyId";
      executionParams[0].Value = "1";
      executionParams[1] = new ReportExecutionService.ParameterValue();
      executionParams[1].Name = "@pUserId";
      executionParams[1].Value = "1";
      executionParams[2] = new ReportExecutionService.ParameterValue();
      executionParams[2].Name = "@pLanguageId";
      executionParams[2].Value = "1";
      executionParams[3] = new ReportExecutionService.ParameterValue();
      executionParams[3].Name = "@pOrganizationId";
      executionParams[3].Value = "1";
      executionParams[4] = new ReportExecutionService.ParameterValue();
      executionParams[4].Name = "@pThemeId";
      executionParams[4].Value = "1";

      rsExec.SetExecutionParameters(execHeader,trusteduserHeader, executionParams, "en-us",out execInfo);

      //string historyID = null;
      string deviceInfo = null;
      string extension;
      string encoding;
      string mimeType;
      ReportExecutionService.Warning[] warnings = new ReportingServiceTesting.ReportExecutionService.Warning[1];
      warnings[0] = new ReportingServiceTesting.ReportExecutionService.Warning();
      string[] streamIDs = null;
      string format = "EXCEL";
      Byte[] result;
      rsExec.Render(execHeader,trusteduserHeader, format,
        deviceInfo,out result, out extension,
        out mimeType, out encoding,
        out warnings, out streamIDs);
      String fileName = "me.xls";
      FileStream stream = File.OpenWrite(fileName);
      stream.Write(result, 0, result.Length);
      stream.Close();