Joseph Michael Pesch
VP Programming

ASP.Net Webservice via WebRequest with SOAP Message

by 27. January 2010 23:08

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Net.WebRequest req = System.Net.WebRequest.Create("https://api.somesite.com/somewebservice");
            req.Method = "POST";

            string cre = String.Format("{0}:{1}", "User.Name@WebSite.com", "MyPasswordHere");
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(cre);
            string base64 = Convert.ToBase64String(bytes);
            req.PreAuthenticate = true;
            req.Headers.Add("Authorization", "basic " + base64);

            StringBuilder SOAPRequestBody = new StringBuilder();
            SOAPRequestBody.Append("<?xml version=\"1.0\"?>");
            SOAPRequestBody.Append("<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">");
            SOAPRequestBody.Append("<S:Body>");
            SOAPRequestBody.Append("<ns2:getListInfo xmlns:ns2=\"http://service.somesite.com/\">");
            SOAPRequestBody.Append("</ns2:getListInfo>");
            SOAPRequestBody.Append("</S:Body>");
            SOAPRequestBody.Append("</S:Envelope>");

            req.ContentType = "application/soap+xml; charset=utf-8";
            req.ContentLength = SOAPRequestBody.Length;
            System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(req.GetRequestStream());
            streamWriter.Write(SOAPRequestBody);
            streamWriter.Close();
            System.IO.StreamReader streamReader = new System.IO.StreamReader(req.GetResponse().GetResponseStream());
            string strResponse = "";
            while (!streamReader.EndOfStream)
                strResponse += streamReader.ReadLine();
            streamReader.Close();

            System.Net.WebResponse resp = req.GetResponse();

        }

    }
}

Tags: ,

ASP.Net

Network Issues on Vista with VMware Workstation or Player

by 26. January 2010 16:33

 

Network Issues on Vista with VMware workstation.doc (87.50 kb)

1.            Click Start, click Run, type regedit, and then click OK.

2.            Click the following subkey:

HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}

3.            Browse through the 00xx subkeys until you find the REG_SZ VMNet subkey with a value of either
“\DosDevices\VMnet8” or “\DosDevices\VMnet1” (default values)

4.            On the Edit menu, point to New, and then click DWORD Value.

5.            Type *NdisDeviceType, and then press Enter. 

6.            On the Edit menu, click Modify.

7.            Type 1, and then click OK.

8.            Exit Registry Editor.

9.            Disable & re-enable the VMWare NICs

10.          Done

Note: If simply disabling and re-enabling the virtual NICs doesn’t fix the problem, immediately reboot.

 

 

Tags: ,

[None]

Email Current HTML Page with ASP.Net

by 24. January 2010 04:57

  /// <summary>
  /// Overridden to handle Confirmation of the order by
  /// capturing the HTTP output and emailing it.
  /// </summary>
  /// <param name="writer"></param>
  protected override void Render(HtmlTextWriter writer)
  {
    // *** Write the HTML into this string builder
    StringBuilder sb = new StringBuilder();
    StringWriter sw = new StringWriter(sb);
    HtmlTextWriter hWriter = new HtmlTextWriter(sw);
    base.Render(hWriter);
    // *** store to a string
    string PageResult = sb.ToString();
    // *** Write it back to the server
    writer.Write(PageResult);
    // *** Do something with the PageResult here like email it...
  }

Tags: ,

ASP.Net | C#

Outlook Corrupted PST File

by 19. January 2010 18:16

Try using: C:\Program Files\Microsoft Office\Office12\scanpst.exe to repair file.  For files larger that 2GB, use PST2GB tool to truncate file: http://www.microsoft.com/downloads/details.aspx?FamilyID=B33B1DFF-6F50-411D-BBDF-82019DDA602E&displaylang=en

Tags: ,

Outlook

Excel Macro to Re-Order Columns Based on Comma Delimited List

by 13. January 2010 18:24

This script will take the comma delimited values in the list variable, search for those values in the header row and reorder the columns in the corresponding order as the list.

Sub FormatFile()
    Dim iColTarget As Integer
    iColTarget = 0
    Dim iColSource As Integer
    Dim list As String
    list = "Date,Time,DNIS,ANI,Call Type,Duration,Hold Time,Handle Time,Rate,Cost,Disposition,Campaign,Agent,Comments,Number1,Number2,Number3,First_Name,Last_Name,Company,Street,City,State,Zip,Language,Impac Loan Number,Email Address,MailZip,MailAddress,MailCity,MailState,ContactComments"
    For Each listval In Split(list, ",")
      iColTarget = iColTarget + 1
      Rows(1).Select 'Select header row to search
      Cells.Find(What:=listval, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
      iColSource = ActiveCell.Column
      Debug.Print listval & ": is located in column: " & iColSource & "; moving to column: " & iColTarget
      If iColSource <> iColTarget Then
        Columns(iColSource).Select
        Selection.Cut
        Columns(iColTarget).Select
        Selection.Insert Shift:=xlToRight
      End If
    Next
End Sub

Tags: ,

[None]

About My Blog

by 1. January 2010 09:00

My blog focuses primarily on Microsoft technologies, primarily .Net based web and application development.  I have 20 years experience prgramming with Microsoft technologies, originally working with Visual Basic version 1, Access version 1, Excel macros and SQL Server.  To date I have worked with all versions of Visual Basic, all versions of the .Net framework and Visual Studio 2003, 2005, 2008 and 2010 (using both C# as well as VB.Net).  SQL Server versions 4 through 2008R2.  ODBC, ADO.Net, LINQ to SQL, EntityFramework, WCF Data Services.  I have also worked with Oracle and dabbled in MySql/PHP.  I have built many custom web site applications applications with web services and prefer using jQuery on the front end.

You can visit my Google+ profile here: My Google+ Profile

Tags: