How to call web service in .net

Leave a comment

Today I have worked on calling web service from console application, and I have searched on google also, but it seems to be not much.

I have done with the following code to call web service.

Imports System.Net
Imports System.IO
Imports System.Text

Public Class ScheduleTrigger

    Public Shared Sub Main()
        Const Template As String = _
"<?xml version=""1.0"" encoding=""utf-8""?>" & vbCrLf & _
"<soap:Envelope xmlns:xsi="""" xmlns:xsd="""" xmlns:soap="""">" & vbCrLf & _
"  <soap:Body>" & vbCrLf & _
"    <RunResponse xmlns="""" />" & vbCrLf & _
"  </soap:Body>" & vbCrLf & _

        Dim url = New Uri("http://localhost/Schedule.asmx")

        Dim request As HttpWebRequest = WebRequest.Create(url)
        request.Method = "POST"
        request.ContentType = "text/xml; charset=utf-8"
        request.Headers.Add("SOAPAction", "")

        Using stream = New MemoryStream()
            Using writer = New StreamWriter(stream, Encoding.UTF8)
            End Using
            Dim bytes As Byte() = stream.ToArray()
            request.ContentLength = bytes.Length
            Using output = request.GetRequestStream()
                output.Write(bytes, 0, bytes.Length)
            End Using
        End Using

        Using response As HttpWebResponse = request.GetResponse()
            If response.StatusCode = HttpStatusCode.OK Then
                Console.Write("Success ")
                Console.WriteLine("Please Press Any Key to Exit!")
            End If

        End Using
    End Sub

End Class



Leave a comment

is able to convert legacy Khmer font to Khmer Unicode, and Khmer Unicode to legacy Khmer font.
I build this project in order to contribute with open source community in Cambodia, and sharevisionteam.
This project is converted from that built in C# 3.5 t, and due to there is no Khmer Unicode Converter, I have spent my free time to build it up and it’s developed in Java 6.

You can find the binary file and source code file at google code JKhmerConverter
And click here to download download JKhmerConverter

I’m so happy with my first contribute and I hope that it’s my help to society in IT.

Snippet code as below:

 * @author LEE
public class Main {

     * @param args the command line arguments
    public static void main(String[] args) {
        String str = "eRs‘og";
        LegacyToUnicode legacyToUnicode = new LegacyToUnicode();
        System.out.println(legacyToUnicode.convert(str, "Limon S1"));